Hi Benito, Yes, that's true. The semantics for scripting is different even though the same symbol is used. This is mostly the reason why I distinguish between binding and assignment for pedagogical purposes, although I do agree with Mike's point that in the end understanding the semantics of a language matters more than the terminology used.
In some scripting extensions, Zorba's for example, assignments are statements, and mean that there is a change of snapshot following a side effect (actually changing the value of a variable), and this side effect is subsequently visible everywhere else in the program (for example through a global variable). This is different from a binding, in that binding a value to a variable merely organizes dynamic contexts in various scopes in which other expressions are evaluated. I visualize the difference like so: side effects due to assignments propagate linearly, left-to-right, in time, whereas variable bindings propagate top-down in an arborescent manner, in a functional way. Kind regards, Ghislain On Mon, Nov 21, 2016 at 10:12 PM Benito van der Zander <[email protected]> wrote: > Hi, > > > You may find some resources that somewhat misleadingly define ":=" > as the "assignment operator," a phrase that is not found in any XQuery > or XPath specification. Calling ":=" the "assignment operator" is > incorrect in two respects. First, ":=" is involved in the *binding*, > not *assigning*, of values to variables—an important distinction in > functional and declarative languages like XQuery, in which a variable, > once bound to a value, cannot be altered, or reassigned a different > value. Second, the ":=" cannot be described as an *operator* because > it does not produce an output sequence of items, in contrast to > operators like "+" (an arithmetic operator), "and" (a boolean > operator), and "/" (an operator for connecting steps in a path > expression). > > > although some implementations have a scripting extensions, where there > actually is an assignment operator, which does both these things. > > > > Cheers, > Benito > > > > On 11/21/2016 06:40 PM, Joe Wicentowski wrote: > > Hi Ghislain, > > Thanks very much for your reply! If ":=" is not an "operator," by > your helpful definition, then is there a category like "symbol," > "delimiter," or at worst, "thingy," that it *does* rightly belong to? > I'm looking to fill in the blank in the following sentence, which > builds on your summary: > > ":=" has no formal name in the XPath and XQuery specifications but > is used extensively in clauses and declarations that bind variables. > Specifically, it is used in let and group-by clauses (which produce > tuples) as well as variable and context item declarations (which > contribute to the dynamic context). Rather than leaving this important > symbol nameless, let's call it the "binding ____." > > I'm also thinking of a parenthetical note or footnote like this: > > You may find some resources that somewhat misleadingly define ":=" > as the "assignment operator," a phrase that is not found in any XQuery > or XPath specification. Calling ":=" the "assignment operator" is > incorrect in two respects. First, ":=" is involved in the *binding*, > not *assigning*, of values to variables—an important distinction in > functional and declarative languages like XQuery, in which a variable, > once bound to a value, cannot be altered, or reassigned a different > value. Second, the ":=" cannot be described as an *operator* because > it does not produce an output sequence of items, in contrast to > operators like "+" (an arithmetic operator), "and" (a boolean > operator), and "/" (an operator for connecting steps in a path > expression). > > (For some resources that use the term "assignment operator," see > viahttps://www.google.com/search?q=%22assignment+operator%22+xquery.) > > It's funny, "/" didn't have a name in XPath 1.0, but got one in XPath > 3.0 - "path operator." Perhaps it's time for ":=" to get a name? > > Thanks again, > Joe > > > Syntactically, ":=" is not an operator because it does not produce an output > sequence of items like "+" or "and" or "/". It is part of let and group-by > clauses (which produce tuples) as well as variable and context item > declarations (which contribute to the dynamic context). > > From a pedagogical perspective, I would simply call it a variable binding, > the important part being not to call it "assignment" to make clear that it > is a functional and declarative language. > > > [email protected]http://x-query.com/mailman/listinfo/talk > > >
_______________________________________________ [email protected] http://x-query.com/mailman/listinfo/talk
