chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-hackers] [PATCH] Make `define-constant` support singly-quot


From: Peter Bex
Subject: Re: [Chicken-hackers] [PATCH] Make `define-constant` support singly-quoted symbols
Date: Sun, 29 May 2016 16:00:29 +0200
User-agent: Mutt/1.5.23 (2014-03-12)

On Tue, May 24, 2016 at 03:41:09PM +1200, Evan Hanson wrote:
> Allows the following program to work correctly:
> 
>   (define-constant a 'frizzle)
>   (print a)
> 
> Previously, the second `a` would be replaced by an *unquoted* `frizzle`,
> resulting in an undefined variable reference (or, if the constant value
> were instead `(quote a)`, causing the compiler to enter an infinite
> loop). This patch makes sure constant values are quoted after evaluation
> so that collapsable literal constants (including symbols) are always
> treated as data when substituted into their usage sites.

I think this fix is not the correct way to do it: it changes "val" from
plain frizzle to (quote frizzle), causing "collapsable-literal?" to
return #f (a list isn't collapsable).  This happens also when val is a
fixnum, for example, so the first case in the cond is _never_ matched,
meaning the constant-table will stay empty.

I think the proper fix is simply to quote the value when it's being
inserted into the constant-table.  This is consistent with all the other
lists into which val is being inserted.

I believe the fix is trivial enough and the bug is nasty enough to
warrant a backport to master.  This is also attached.

Cheers,
Peter

Attachment: 0001-Allows-the-following-program-to-work-correctly.chicken-5.patch
Description: Text Data

Attachment: 0001-Allows-the-following-program-to-work-correctly.master.patch
Description: Text Data

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]