On the disjoiintness of keywords and symbols, and compatibility...

Gauche used to have keywords disjoint from symbols, noted :foo.  It's not conforming rnrs, though, so we switched keywords
to be symbols (to be precise, of a subtype of the symbol type).   However, there's a library (gauche keyword), in which
all symbols beginning with ':' are pre-bound to itself.

So you can write:
  (import (gauche keyword))
  (foo :foo 1 :bar 2)

If you don't want to import (gauche keyword), you can still call keyword-accepting procedure by quoting keywords:
  (foo ':foo 1 ':bar 2)

If you want to bind a symbol beginning with ':' and want to use keywords as well:
  (import (except (gauche keyword) :foo))
  (define :foo "foo")
If you do this, you have to quote :foo if you mean it to be a keyword arguments, but you know what you're doing in
that scope.









On Sun, Jul 21, 2019 at 11:23 AM John Cowan <xxxxxx@ccil.org> wrote:



On Sun, Jul 21, 2019 at 4:52 PM Lassi Kortela <xxxxxx@lassi.io> wrote:

But are the different keyword _objects_ incompatible with each other?

No, not in any implementation I know of.  There is also the question of whether keywords are a kind of symbol or are disjoint: in Chicken they were historically a kind of symbol but are now disjoint to prevent people from trying to bind them.
 
The read syntax is different, but if a SRFI simply specifies that the
implementation must have _some_ syntax for keywords, whether it be foo:
or :foo or #:foo, and uses one of them for illustrative purposes but
implementations are allowed to use the others, would that cause problems?

As Arthur says, that would prevent code compatibility: as he doesn't say, it would also be bad for data portability, because keywords are datums in Lisps (except Racket) that have them.

The trouble with #! flags for this purpose is that they are file-global, making it hard to mix and match snippets.  They also don't work well for data (what does `read` assume?)

In short, it's all a big mess.


John Cowan          http://vrici.lojban.org/~cowan        xxxxxx@ccil.org
When I wrote it I was more than a little febrile with foodpoisoning
from an antique carrot that I foolishly ate out of an illjudged faith
in the benignancy of vegetables.  --And Rosta