W3C home > Mailing lists > Public > www-ql@w3.org > April to June 2004

Re: questionable syntax choices for XQuery

From: Per Bothner <per@bothner.com>
Date: Thu, 22 Apr 2004 12:16:30 -0700
Message-ID: <40881A0E.9080607@bothner.com>
To: "Volkmann, Mark" <Mark.Volkmann@AGEDWARDS.com>
Cc: "'www-ql@w3.org'" <www-ql@w3.org>

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 22 July 2006 00:10:19 GMT