W3C home > Mailing lists > Public > public-qt-comments@w3.org > April 2004

RE: [XQuery] semicolon separator after declarations

From: Michael Kay <mhk@mhk.me.uk>
Date: Mon, 26 Apr 2004 19:34:55 +0100
To: "'Xavier Franc'" <xfranc@online.fr>, <public-qt-comments@w3.org>
Message-Id: <20040426183523.A1F2AA0FD1@frink.w3.org>

> >1. Semicolons at the end of declarations simplify parsing of the 
> >language - not only for recognition, but also for error detection, 
> >making it possible to give good error messages.
> >
> This is hardly a good reason for introducing them.
> Easiness-of-implementation considerations should not
> influence the design of a language, IMHO.

That's nothing to do with ease of implementation. You can only give good
error messages (and recover to report multiple errors in a single run) if
the language has sufficient redundancy. That's a question of language
design, not of how clever the implementation is. Redundancy in language
syntax (as with any other kind of input data) leads to better error
detection.

Without semicolons, when you write something like

import schema "ns.uri" "location.uri"
+3

you are going to get the error message

*** Type error: Cannot add a string and an integer

while

import schema "ns.uri" "location.uri"
3

will give you

*** Unexpected token "3" beyond end of expression 

With semicolons, the construct

import schema "ns.uri" "location.uri";
+3

will give you the much clearer error message

*** Syntax error: Expected 'at' or ';', found string literal "location.uri"

Michael Kay
Received on Monday, 26 April 2004 14:35:23 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:45:19 UTC