Email list hosting service & mailing list manager

Self-evaluating keywords or not? Marc Nieper-Wißkirchen (16 Mar 2020 13:09 UTC)
Re: Self-evaluating keywords or not? Shiro Kawai (16 Mar 2020 13:45 UTC)
Re: Self-evaluating keywords or not? Marc Nieper-Wißkirchen (16 Mar 2020 13:54 UTC)
Re: Self-evaluating keywords or not? Shiro Kawai (16 Mar 2020 13:58 UTC)
Re: Self-evaluating keywords or not? Marc Feeley (16 Mar 2020 15:38 UTC)
Re: Self-evaluating keywords or not? Marc Nieper-Wißkirchen (16 Mar 2020 16:00 UTC)
Re: Self-evaluating keywords or not? Per Bothner (16 Mar 2020 16:47 UTC)
Re: Self-evaluating keywords or not? Marc Nieper-Wißkirchen (16 Mar 2020 16:53 UTC)
Re: Self-evaluating keywords or not? Shiro Kawai (16 Mar 2020 20:27 UTC)
Re: Self-evaluating keywords or not? Marc Nieper-Wißkirchen (16 Mar 2020 20:37 UTC)
Re: Self-evaluating keywords or not? Lassi Kortela (16 Mar 2020 21:17 UTC)
Re: Self-evaluating keywords or not? Marc Nieper-Wißkirchen (16 Mar 2020 21:31 UTC)
Re: Self-evaluating keywords or not? Shiro Kawai (16 Mar 2020 22:05 UTC)
Re: Self-evaluating keywords or not? Marc Nieper-Wißkirchen (17 Mar 2020 07:14 UTC)
Re: Self-evaluating keywords or not? Shiro Kawai (17 Mar 2020 07:46 UTC)
Re: Self-evaluating keywords or not? Marc Nieper-Wißkirchen (17 Mar 2020 08:05 UTC)
Re: Self-evaluating keywords or not? Shiro Kawai (17 Mar 2020 08:31 UTC)
Re: Self-evaluating keywords or not? Lassi Kortela (16 Mar 2020 22:18 UTC)
Re: Self-evaluating keywords or not? Per Bothner (16 Mar 2020 22:36 UTC)
Re: Self-evaluating keywords or not? Shiro Kawai (16 Mar 2020 22:42 UTC)
Re: Self-evaluating keywords or not? Marc Nieper-Wißkirchen (17 Mar 2020 07:22 UTC)
Re: Self-evaluating keywords or not? Shiro Kawai (16 Mar 2020 21:34 UTC)
Re: Self-evaluating keywords or not? Shiro Kawai (16 Mar 2020 21:43 UTC)
Re: Self-evaluating keywords or not? Lassi Kortela (16 Mar 2020 22:02 UTC)
Re: Self-evaluating keywords or not? Shiro Kawai (16 Mar 2020 22:06 UTC)
Re: Self-evaluating keywords or not? Shiro Kawai (16 Mar 2020 22:19 UTC)
Re: Self-evaluating keywords or not? Lassi Kortela (16 Mar 2020 22:24 UTC)
Re: Self-evaluating keywords or not? Marc Nieper-Wißkirchen (17 Mar 2020 07:28 UTC)
Re: Self-evaluating keywords or not? Per Bothner (16 Mar 2020 22:24 UTC)
Re: Self-evaluating keywords or not? Lassi Kortela (16 Mar 2020 22:56 UTC)
Re: Self-evaluating keywords or not? Per Bothner (17 Mar 2020 00:36 UTC)

Re: Self-evaluating keywords or not? Marc Feeley 16 Mar 2020 15:37 UTC

The point of the foo: (or :foo) syntax for keywords and the self-evaluation is to provide a lightweight and “visually” agreable syntax for calling a procedure with keyword arguments.  In this respect I find the following visually disagreable:

   (bar 42 'foo: 88 'baz: 99)
   (bar 42 '#:foo 88 '#:baz 99)

Self-evaluating keywords make the code more lightweight:

   (bar 42 foo: 88 baz: 99)
   (bar 42 #:foo 88 #:baz 99)

And between the two I find the “sharp prefix” syntax for keyword disagreable visually.  I question the motivation for introducing it.

In terms of the language spec, it adds a new sharp syntax (which conflicts with the uses of that syntax by existing Scheme systems) and also a self-evaluation rule.  Similarly the more pleasing colon suffix (or prefix) syntax adds a self evaluation rule and a change to the syntax of symbols.  But many Scheme implementations already support the colon suffix (or prefix) syntax, so it would be ill-advised for a programmer to use symbols that begin or end with a colon if they have any interest in sharing code with others (and we shouldn’t forget this is the reason we are discussing this SRFI).

Can someone explain advantages of the #:foo syntax I may have missed?

Marc

> On Mar 16, 2020, at 9:57 AM, Shiro Kawai <xxxxxx@gmail.com> wrote:
>
>
> On Mon, Mar 16, 2020 at 3:54 AM Marc Nieper-Wißkirchen <xxxxxx@nieper-wisskirchen.de> wrote:
> In that case
>
> (bar :foo x)
>
> and
> (bar ':foo x)
>
> would be equivalent.  The would forbid any extension of SRFI 177 to allow procedures taking keyword arguments and a variable number of arguments at the same time as the code of `bar' wouldn't be able to distinguish a keyword introducing an keyword argument from a regular argument, which happens to evaluate to a keyword.
>
>
> If we take semantics similar to Common Lisp, you don't need to distinguish them.  Actually you don't *want* to distinguish them.
>
>
>
> 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
>
>
> --
> Prof. Dr. Marc Nieper-Wißkirchen
>
> Universität Augsburg
> Institut für Mathematik
> Universitätsstraße 14
> 86159 Augsburg
>
> Tel: 0821/598-2146
> Fax: 0821/598-2090
>
> E-Mail: xxxxxx@math.uni-augsburg.de
> Web: www.math.uni-augsburg.de/alg/mitarbeiter/mnieper/