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

Mike Sokolov sokolov at ifactory.com
Fri Dec 21 06:38:09 PST 2012



On 12/21/2012 09:32 AM, David Lee wrote:
> ------------------
> 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.
>    
Actually I think () is the closest we have to null and void in xquery, 
so it seems consistent and logical to me :)
> 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 () { ()};
>    
Yes I would
> 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 ?
>
>    
Actually my compiler allows "void foo () { }" - why not?  A function 
that does nothing could be very useful sometimes.  "foo () { }" is bad 
because implicitly it is declared as returning int, yet does not return 
anything.


More information about the talk mailing list