SRFI 4 lexical syntax John Cowan (06 Dec 2023 04:03 UTC)
Re: SRFI 4 lexical syntax Arthur A. Gleckler (06 Dec 2023 04:07 UTC)
Re: SRFI 4 lexical syntax John Cowan (06 Dec 2023 13:13 UTC)
Re: SRFI 4 lexical syntax Marc Feeley (07 Dec 2023 04:20 UTC)
Re: SRFI 4 lexical syntax John Cowan (07 Dec 2023 08:20 UTC)
Re: SRFI 4 lexical syntax Marc Nieper-Wißkirchen (07 Dec 2023 09:07 UTC)
Re: SRFI 4 lexical syntax Marc Feeley (07 Dec 2023 14:25 UTC)
Re: SRFI 4 lexical syntax Marc Nieper-Wißkirchen (07 Dec 2023 15:17 UTC)
Re: SRFI 4 lexical syntax Marc Feeley (07 Dec 2023 16:01 UTC)
Re: SRFI 4 lexical syntax Arthur A. Gleckler (07 Dec 2023 16:27 UTC)
Re: SRFI 4 lexical syntax Per Bothner (07 Dec 2023 17:20 UTC)

Re: SRFI 4 lexical syntax Per Bothner 07 Dec 2023 17:20 UTC

Were I designing a Lisp-like language from scratch, you would have an *expression* syntax for creating
immutable vectors using sub-expressions. There would be be no vector literal syntax. Instead, like
other modern languages, you would have "constant expressions": A vector constant is one where
all the sub-expressions are constant. Because the vector syntax creates immutable vectors,
it would be OK to create a single global instance that can be re-used.

Kawa uses square brackets for this: [a b c] is the same as (vector a b c) except the
result is immutable. For example: [3 (+ 9 12) 100] returns #(3 21 100).
To initialize a mutable vector you could use vector-copy:
     (vector-copy [3 (+ 9 12) 100]) is equivalent to (vector 3 (+ 9 12) 100)
Thus no need for the vector procedure, either.

This would be consistent with how SRFI-140 treats mutable vs immutable strings,
except that it is useful to allow mutable fixed-size vectors (while SRFI-140
does not support mutable fixed-size strings, as they are useless).

Unfortunately, as it is, we're stuck with different syntax for vector literals
and vector expressions.  I think for consistency, we must do the same for uniform vectors.
--
	--Per Bothner
xxxxxx@bothner.com   http://per.bothner.com/