Re: Reviewing named and optional parameters Daphne Preston-Kendal 09 Jun 2021 08:55 UTC

On 8 Jun 2021, at 07:17, Peter Bex <xxxxxx@more-magic.net> wrote:

> One nitpick: at the end you mention:
> "in Chicken [keywords] are symbols, but in DSSSL and other
> implementations they are a disjoint type"

I’m referring there to the magic constants #!key, #!rest, and #!optional, not to keyword datums themselves. I have 5.2.0 here:

#;1> #!key
Error: unbound variable: #!key
#;1> '#!key
#!key
#;2> (symbol? '#!key)
#t
#;3> '#!zoo
Error: invalid `#!' token: "zoo"
#;3> (define #!key 'zoo)
#;4> #!key
zoo

> This used to be true, but since 5.1.0 (released in July 2019) we've
> successfully managed to turn them into a disjoint type.  The conflation
> of symbols and keywords was made possible due to a godawful hack that
> interfered with read/write invariance which we've now thankfully dropped
> completely by making them disjoint.  This surfaced several bugs in macros
> and also pointed out that people were using forms like (define foo: ...)
> which would result in a keyword being bound, so that it would no longer
> self-evaluate.

This is useful to know, thank you. I think Chicken's experiences here could be more generally instructive.

> Also, you state that in Gauche, keywords respond #t to symbol?, but
> I do not see this in 0.9.6 on Debian.  However, if I invoke "gosh"
> with an unrecognised switch like "-h", I see GAUCHE_KEYWORD_IS_SYMBOL
> and GAUCHE_KEYWORD_DISJOINT in the list of environment variables.
> It looks like this influences the behaviour of keywords, and it also
> mentions that the former environment variable is to make it "fully R7RS
> conformant".  Maybe worth a second look.

I have 0.9.10 (installed from Homebrew on Mac) and this seems to be the default behaviour:

gosh> :key
:key
gosh> (symbol? :key)
#t

However, it's also good to know that this is apparently customizable!

Thank you for the helpful reply!

> Cheers,
> Peter

Daphne