[xquery-talk] let's comment out a line in XQuery

David Lee dlee at calldei.com
Fri Dec 21 06:32:28 PST 2012


------------------
I think this has been batted around here before, but would somebody mind 
refreshing us as to whether there is any good reason plain {} doesn't 
generate () (an empty sequence)?
---------------

If you want historical rationality you will have to ask someone else.


If you want deductive logic ...

{ expr }  parses expr ... it returns whatever expr is.  If there is nothing there then thats nothing.    () is not nothing, its something.   So it would be silly and inconsistent if {} produced something rather than nothing.

The only time that I can see that it is actually inconvenient ("annoying"?) that {} produces nothing rather then something is in this particular case with comments embedded
within literal constructors.   Buy why single out () as the something it should produce ?   There is nothing special about the empty sequence that makes it the best candidate for a fillin for nothing.

Also there is the other use of {} which is in functions 

declare function x () { };


Which is rightfully an error because there is no expression and should be.
Although one could argue that it should be treated as 
declare function x () { ()};

But then one could argue that in C 

foo() { }

should be treated as
foo() { return NULL ; }

But that would be silly now wouldn't it ?


In the end I am not going to try to justify this rule in XQuery ... it just is the way it is.


-----------------------------------------------------------------------------
David Lee
Lead Engineer
MarkLogic Corporation
dlee at marklogic.com
Phone: +1 812-482-5224
Cell:  +1 812-630-7622
www.marklogic.com







More information about the talk mailing list