Declarations for external variables not enforced
Thursday, 29 March 2012 · 4 messages · last reply 30 Mar 2012
CD
Charles Duffy29 Mar 2012 20:53 #
Howdy --
Using the REST interface, I'm currently able to do the following:
<rest:query xmlns:rest="http://basex.org/rest">
<rest:text>$foo</rest:text>
<rest:variable name="foo" value="bar"/>
</rest:query>...and get back "bar" as a result. Note the lack of a "declare variable $foo external" line.
I haven't read the spec to determine permissibility of this behavior, but it does come in handy at times (particularly, for permitting maximally terse one-liners). Is this something likely to go away in the future?
Thanks!
LW
Leo Wörteler30 Mar 2012 02:09 #
Hi,
Quoted text · Charles Duffy · 15 lines
Am 29.03.2012 18:53, schrieb Charles Duffy: > Using the REST interface, I'm currently able to do the following: > > <rest:query xmlns:rest="http://basex.org/rest"> > <rest:text>$foo</rest:text> > <rest:variable name="foo" value="bar"/> > </rest:query> > > ...and get back "bar" as a result. Note the lack of a "declare variable > $foo external" line. > > I haven't read the spec to determine permissibility of this behavior, > but it does come in handy at times (particularly, for permitting > maximally terse one-liners). Is this something likely to go away in the > future?
I don't think this "feature" will disappear any time soon, because it's so widely used and doesn't cause any problems. It isn't backed up by the spec though. Every free variable $x in a query is treated as if it was declared as
declare variable $x external;.
Hope that helps,
cheers, LeoCG
Christian Grün30 Mar 2012 02:12 #
I can just confirm Leo's observation. We (or anyone else) might need to detail this somewhere in our documentation.
Quoted text · Leo Wörteler · 33 lines
Am 30.03.2012 02:09 schrieb "Leo Wörteler" <lw at basex.org>: > Hi, > > Am 29.03.2012 18:53, schrieb Charles Duffy: > >> Using the REST interface, I'm currently able to do the following: >> >> <rest:query xmlns:rest="http://basex.org/**rest <http://basex.org/rest>"> >> <rest:text>$foo</rest:text> >> <rest:variable name="foo" value="bar"/> >> </rest:query> >> >> ...and get back "bar" as a result. Note the lack of a "declare variable >> $foo external" line. >> >> I haven't read the spec to determine permissibility of this behavior, >> but it does come in handy at times (particularly, for permitting >> maximally terse one-liners). Is this something likely to go away in the >> future? >> > > I don't think this "feature" will disappear any time soon, because it's so > widely used and doesn't cause any problems. It isn't backed up by the spec > though. Every free variable $x in a query is treated as if it was declared > as `declare variable $x external;`. > > Hope that helps, > cheers, Leo > ______________________________**_________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-**konstanz.de <BaseX-Talk at mailman.uni-konstanz.de> > https://mailman.uni-konstanz.**de/mailman/listinfo/basex-talk<https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk> >
J
jidanni30 Mar 2012 06:15 #
You'll be sorry not fixing this sooner rather than later.
What if the UNIX shell automatically exported every variable by default?
This would cause the worst kind of bugs. The ones that creep in while you aren't aware.
A program that worked fine in your polluted environment suddenly stops working when that environment is changed.
Stick with the spec and nobody will blame you.
Cut the corners and people will start (or worse not even) notice some things are unnecessary and remove them... result: unportable programs.
Written for BaseX 7.2. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery