Re: questionable syntax choices for XQuery

Volkmann, Mark wrote:

> The key part of that is "or newlines".  Most Ruby programmers only use 
> semicolons in order to put more than one expression on the same line, 
> which isn't common.

You gave Ruby as an example of a language that "doesn't require any kind 
of statement terminating character."  A newline in Ruby is a statement 
terminating character, so your argument is void.

Whether the statement terminating character is newline or semi-colon 
doesn't make much difference in terms of the grammar or parser.  They 
may make a difference in terms of ease of use or error proneness.  It is 
"natural" to put one statement on each line, so if the language enforces 
this (with an escape for lang lines) then a "visible" terminator would 
be reundant - and you don't really need to change the grammar.

Using newlines to terminate statements is especially nice for 
interactive use, where it is even easier to forget to add semi-colons. 
Qexo has an interactive mode that accepts expressions and declarations. 
  Semi-colons are optional after declarations.  Qexo accepts a line as a 
complete command if the parsing state isn't nested - i.e. we're not 
inside parentheses, braces, element constructors, or an incomplete 
binary operator.  This works pretty well.

However, extending this to non-interactive mode isn't fully compatible. 
    XQuery treats a (non-quoted) newline as equivalent to a space - i.e. 
as "whitespace".  Treating a newline as a "statement terminator" instead 
may be tempting, but it's not a no-brainer.

Note that XQuery is an expression language.  Apart from the prolog, the 
rested of a program is one bi nested expression.  XQuery doesn't really 
have "statements" in that sense, so a statement terminator isn't as 
useful.  This would be different in a language with side-effects.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

Received on Thursday, 22 April 2004 15:16:32 UTC