syntax changes (srfi-107/108/109) Per Bothner (29 Dec 2012 21:43 UTC)
Re: syntax changes (srfi-107/108/109) John Cowan (30 Dec 2012 03:22 UTC)
Re: syntax changes (srfi-107/108/109) John Cowan (30 Dec 2012 03:37 UTC)

syntax changes (srfi-107/108/109) Per Bothner 29 Dec 2012 21:43 UTC

[Follow-ups to srfi-108@srfi.schemers.org to avoid duplication.]

I apologize for the lack of progress on these SRFIs.  (I had a security
bug I had to deal with in my day job, among other issues.)

Now that there appears to be consensus on the XML-style syntax
(rather than Scribble-style), I have started implementing SRFIs
108 and 109 in Kawa, which I hope will provide some practical
experience.

My first conclusion is that too many special characters are needed
for string literals:
   #&[Hello world!]
Starting a literal with '#', '&', and '[' seems rather cumbersome,
ugly, and error prone.  I realized there is no need for the
initial '#'.  Instead, I propose:
   &[Hello world!]           ;; string
   &URI[http://example.com/] ;; named constructor
This makes the top-level prefix and the nested prefix the same:
   &section[Read this &emph[first]!]

There is a seeming ambiguity, since in Scheme the character '&'
is a valid symbol character.  However, a symbol followed
immediately by either '{' or '[' is not defined by standard
Scheme, so this is a conflict-free extension.

However, it may be worth switching the roles of '{...}' and
'[...]'.  I'd value some feedback on these two options:

** Option curly-quotes (braces quote, bracket unquote) **

Examples:

&{Hello world!}
&{Hello &[name]!}
&section{News as of &(current-date)}
&itemlist[
   &item{First item}
   &item{Second item is &emph{important}}]

+ This matches Scribble, so may be more familiar to some.
Plus it would be easier to convert Scribble syntax to this syntax
or vice versa, or write a reader macro that does the conversion.

+ More familiar from LaTeX and texinfo.

+ Kawa has the following syntax for general QNames:
   prefix{namespace-uri}:local-name
Using curly braces for the literal namespace-uri seems more in the
same spirit as using curly braces for quoted text.

+ Kawa has this syntax for a vector constructor:
   [e1 e2 ... en]
This is the same as `#(,e1 ,e2 ... ,en), which is the same as
(vector e1 e2 .. en) except producing an immutable vector.
Using square brackets in the same-literal syntax to group
evaluated (unquoted) expressions seems more in the same spirit.

** Option square-quotes (brackets quote, braces unquote) **

Examples:

&[Hello world!]
&[Hello &{name}!]
&section[News as of &(current-date)]
&itemlist{
   &item[First item]
   &item[Second item is &emph[important]]}

+ Kawa's XML literals (the base for SRFI-107) uses curly
braces for unquoting, so this would be an incompatibility.
However, Kawa could allow either braces and brackets for
unquoting in XML literals, while deprecating the older
use of braces.

+ Aesthetically, I think this syntax looks slightly nicer,
based on my general experience - but not by much.

Input?  Other reasons to prefer one to the others?
Preferences?
--
	--Per Bothner
xxxxxx@bothner.com   http://per.bothner.com/