Re: Semantics of boolean operators

Well, the choice of my variable was random. I tried to make a point
about semantics, not syntax. I didn't say that your semantics was wrong.
I simply pointed out that your semantics may not be intuitive in some cases.
If you use your semantics, you should make it clear with examples in the
language description because it's an important issue.
For example, the following query (using your variables) would give wrong results:

for $book in //book
where $book/author/firstname/text() = "John"
   and $book/author/lastname/text() = "Smith"
return $book/title

The correct query should be:

for $book in //book
where some $a in $book/author satisfies
                 ( $a/firstname/text() = "John"
                   and $a/lastname/text() = "Smith" )
return $book/title

or even:

for $a in //book/author
where $a/firstname/text() = "John"
   and $a/lastname/text() = "Smith"
return $a/../title

In both cases the paths return singletons or empty answers.
The point I tried to make was that there is an alternative semantics:
if a path expression returns multiple elements, then it may make more
sense to expect the programmer to use explicit existential quantification.
So the semantics of [[ E1 = E2 ]] can also be:
size([[ E1 ]])=1 and size([[ E2 ]])=1 and element([[ E1 ]])=element([[ E2 ]])
where 'element' returns the singleton element.
Best regards
Leonidas Fegaras


> X-Sender: usajnr@157.189.12.7
> X-Mailer: QUALCOMM Windows Eudora Version 5.1
> Date: Wed, 20 Jun 2001 13:50:08 -0400
> From: Jonathan Robie <Jonathan.Robie@SoftwareAG-USA.com>
> Mime-Version: 1.0
> Content-Type: text/plain; charset="us-ascii"; format=flowed
> Content-Length: 696
> 
> At 05:18 PM 6/19/2001 -0500, Leonidas Fegaras wrote:
> 
> >In section 6.2.4.1 (boolean operators) you expressed the semantics of
> >boolean operators using (simulated) existential quantification.
> >This may not work very well for the following query:
> >
> >for $a in //book
> >where $a/author/firstname/text() = "John"
> >   and $a/author/lastname/text() = "Smith"
> >return $a/title
> 
> I also find that part of the non-intuitive nature of the above query is due 
> to the poor choice of variable name. Would the results be as surprising 
> with an appropriate variable name?
> 
> for $book in //book
> where $book/author/firstname/text() = "John"
>    and $book/author/lastname/text() = "Smith"
> return $book/title
> 
> Jonathan
> 
> 

Received on Wednesday, 20 June 2001 14:36:00 UTC