chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] csc doesn't like functions with :'s, csi doesn't car


From: felix winkelmann
Subject: Re: [Chicken-users] csc doesn't like functions with :'s, csi doesn't care
Date: Mon, 4 Apr 2005 08:24:20 +0200

On Apr 2, 2005 2:10 AM, Damian M Gryski <address@hidden> wrote:
> 
>    The compiler and interpreter act differently on functions
>    with trailing colons in their names.
> 
>    See the below transcript.
> 
>    Expected output: hello, world
>    Actual output: Error: call of non-procedure: fn:with:colon:
> 
> --- 8< --- cut here --- 8< --- cut here --- 8< ---
>       jolt:work$ cat colon.scm
>       (define (fn:with:colon: msg) (display msg))
>       (fn:with:colon: "hello, world\n")
>       jolt:work$ csi -script colon.scm
>       hello, world
>       jolt:work$ csc colon.scm
>       jolt:work$ ./colon
>       Error: call of non-procedure: fn:with:colon:
> 
>       colon.scm: 2    ###fn:with:colon
> --- 8< --- cut here --- 8< --- cut here --- 8< ---
> 
>    Removing the trailing colon from the function name works.
> 

Keywords (i.e. symbols starting with "#:" or ending with ":" (depending
on the keyword-mode) are considered to be self-evaluating. Internally
keywords are still symbols, with their (global) value slot being a pointer
to the same symbol/keyword. The compiler "optimizes" unquoted keyword
symbol accesses into a literal reference. The interpreter on the other
hand simply retrieves the value slot, so this example works in the
interpreter but not in the compiler.

I'll change the compiler to issue a warning on keyword assignments,
but this will not change the general situation. Is this a serious problem
for you?


cheers,
felix




reply via email to

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