Another option is to bound :foo to a symbol :foo.  Not only :foo, but make all possible keyword-like symbols effectively bound to itself in srfi-177 library.

It doesn't conflict with R7RS-small.  The drawback is that it can't be implemented portably.


On Mon, Mar 16, 2020 at 3:09 AM Marc Nieper-Wißkirchen <xxxxxx@nieper-wisskirchen.de> wrote:
Some Schemes have native keywords objects and a lexical syntax for keywords.  Commonly used lexical syntaxes are `:foo', `foo:' and `#:foo'.

In some systems, keywords are self-evaluating like numbers or strings.  In other words, `:foo' or `foo:' are expressions evaluating to the keyword with name `foo'. 

In other systems, keywords are not self-evaluating.  For example, `#:key' is not a valid expression, but `(quote #:key)' is, evaluating to the keyword with name `foo'.

I want to argue that the second alternative is the much better one because it leads to a simpler and more uniform semantics.

In an ordinary procedure call, the procedure and the arguments are evaluated and then the (evaluation of the) procedure is called with the (values of the) arguments.

If the keyword lexical syntax `:foo' is self-evaluating, the base case of the procedure call `(bar :foo x)' is therefore to evaluate `bar' , `:foo' and `x' and to do the call with the corresponding values.

As soon as procedures with keyword arguments are introduced, the R7RS-small rule of how `(bar :foo x)' is to be evaluated has to be changed.  In a strict sense, the resulting language is no more compatible with R7RS-small.

In the other case when `#:foo' is not self-evaluating, there is no clash with the semantics of R7RS-small.  In that case, `(bar #:foo x)' is new syntax (not existing in R7RS-small) and section 4.1.3 of R7RS-small has just to be extended without overriding previous behavior.

The conclusion is: If R7RS-large eventually gets lexical syntax for keywords, it should follow the `#:foo' and not the `:foo' model. SRFI-177 should be specified in a way that makes a smooth transition to the `#:foo' model possible.

Marc