W3C home > Mailing lists > Public > www-ql@w3.org > January to March 2004

Re: IfExpr has a mandatory else clause

From: TAN Kuan Hui <kuanhui@xemantics.com>
Date: Mon, 26 Jan 2004 18:51:14 +0800
Message-ID: <003f01c3e3fa$53fc2af0$4445bada@pinecone>
To: "Bas de Bakker" <bas@x-hive.com>, "Torsten Grust" <Torsten.Grust@uni-konstanz.de>
Cc: <www-ql@w3.org>

Appreciate the clarifications.

Apart from syntactic niceties, having to code else () everytime
is not intuitive and unnecessarily annoying. The if-then-else
construct has to contend with a mindset precedence that has been
ordained in many languages (including SQL); functional
or procedural.

IMO, it is far from just being syntactic sugar, if the 
conditional construct has to be borrowed into the grammar 
then we should try to keep its semantics intact. Any programmer
this day has to operate in many languages simultaneously;
idiosyncrasies such as this can make a programming task
that little bit more confusing and error-prone. It can
be easily avoided, why not ?


----- Original Message ----- 
From: "Bas de Bakker" <bas@x-hive.com>
To: "Torsten Grust" <Torsten.Grust@uni-konstanz.de>
Cc: <www-ql@w3.org>
Sent: Monday, January 26, 2004 6:08 PM
Subject: RE: IfExpr has a mandatory else clause



Obviously the empty sequence.  I often find myself writing expressions
like

if (expr1) then expr2 else ()

so as a matter of convinience, one could allow omitting the else clause
if its value is the empty sequence.  This is simply a syntactic
shortcut.  It has also been proposed to allow "where" without "for" or
"let", achieving the same effect:

where (expr1) return expr2

Bas de Bakker
X-Hive Corporation

> -----Original Message-----
> From: Torsten Grust [mailto:Torsten.Grust@uni-konstanz.de]
> Sent: Monday, January 26, 2004 10:55
> To: TAN Kuan Hui
> Cc: Bas de Bakker; www-ql@w3.org
> Subject: Re: IfExpr has a mandatory else clause
> 
> 
> G'day all,
> 
>   grammar issues aside for a minute, I perceive XQuery as a
> _functional_ query language.  The IfExpr thus constitutes a
> conditional expression rather than a control flow construct (like in
> procedural programming languages).
> 
> As a conditional expression, IfExpr is required to evaluate to a
> well-defined value, regardless of the outcome of the tested
> condition.  This is why I find it quite natural that the `else' clause
> is mandatory.  What would be the value of an IfExpr in case the
> conditition evaluates to false?
> 
> Greetings,
>    --Torsten
> 
> On January 26 (17:49 +0800), TAN Kuan Hui wrote with possible
> deletions:
> |
> | Syntactically seems to parse but will this cause confusion ?
> | Using () instead of {} will also re-introduce the
> | ambiguity with an optional else clause although distinguishable.
> |
> | So is grammar ambiguity the reason that IfExpr has a
> | mandatory else clause ? Are there other design considerations ?
> | Appreciate any clarification.
> 
> 
> 
> --
>   | Dr. Torsten Grust                          
> Torsten.Grust@uni-konstanz.de |
>   |                                   
> http://www.inf.uni-konstanz.de/~grust/ |
>   | Database Research Group, University of Konstanz (Lake 
> Constance/Germany) |
>   |             (Please avoid sending me MS Word or 
> PowerPoint attachments.) |
> 
Received on Monday, 26 January 2004 05:51:06 GMT

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