[xquery-talk] Top N Most Common Mistakes

Torsten Grust grust at in.tum.de
Thu Aug 2 18:21:33 PDT 2007


Don,

consider the following XQuery expression:

	let $x := <x/> return $x is $x

which will return return true (`is' test for identical nodes).
Textual substitution of <x/> for all occurrences of $x leads
to
	<x/> is <x/>

which will return false (the two constructors construct two
distinct element nodes).  Referential transparency is lost
(we cannot replace $x with its value without changing the
meaning of the expression), the FP guys would say.

There are other issues (scoping, for example) which make plain
textual substitution of variables invalid -- concepts like bound
and free variables come into play, then.	

Cheers,
    --Torsten

On Aug 2, 2007 at 16:40, Smith, Donald T. wrote with possible deletions:
>> You still get the people who imagine that because variables are
> flagged
>> with a "$" sign they must work by textual substitution.
>
> I don't have the CS background to quite understand how variables work
> via textual substitution and how they work some other way. I do  
> know --
> from reading Michael Kay's books -- that XSLT is a functional language
> and that variables in XSLT can't be updated. I do understand quite  
> well
> template-based processing and recursive templates.
>
> If it's not too much of a digression into CS theory, could someone
> explain this point?

-- 
   | Prof. Dr. Torsten Grust                         grust at in.tum.de |
   |                                 http://www-db.in.tum.de/~grust/ |
   |     Database Systems - Technische Universität München (Germany) |



-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4182 bytes
Desc: not available
Url : http://x-query.com/pipermail/talk/attachments/20070802/71c05f73/smime.bin


More information about the talk mailing list