RE: [XQuery] semicolon separator after declarations

> >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