Discussion:
[xquery-talk] :=
Joe Wicentowski
2016-11-20 23:59:23 UTC
Permalink
Hi all,

I could've sworn that ":=" had a name like "binding operator," but as far as I can see from the XPath or XQuery specs, it gives no name or description to this symbol other than appearances in EBNFs for LetBinding, GroupingSpec, VarDecl, and ContextItemDecl -- as a literal ":=".

Does ":=" really have no name or plain English description in the spec?

If so, this is surprising given its prominence in the let clause. Having one would certainly be very useful when teaching the language.

Thanks,
Joe
_______________________________________________
***@x-query.com
http://x-query.com/mailman/listinfo/talk
Ghislain Fourny
2016-11-21 06:24:04 UTC
Permalink
Hi 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.

I hope these 2 cents help!

Kind regards,
Ghislain
Post by Joe Wicentowski
Hi all,
I could've sworn that ":=" had a name like "binding operator," but as far
as I can see from the XPath or XQuery specs, it gives no name or
description to this symbol other than appearances in EBNFs for LetBinding,
GroupingSpec, VarDecl, and ContextItemDecl -- as a literal ":=".
Does ":=" really have no name or plain English description in the spec?
If so, this is surprising given its prominence in the let clause. Having
one would certainly be very useful when teaching the language.
Thanks,
Joe
_______________________________________________
http://x-query.com/mailman/listinfo/talk
Joe Wicentowski
2016-11-21 17:40:26 UTC
Permalink
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 via
https://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.
_______________________________________________
***@x-query.com
http://x-query.com/mailman/l
Michael Kay
2016-11-21 18:02:38 UTC
Permalink
Actually most of the symbols in the language don't have names. For example "+" doesn't have a name. The */?/+ symbols that can follow an ItemType are collectively referred to as OccurrenceIndicators, but they don't have individual names. Most of the time we talk about symbols, we refer to them by the names of the characters that are used to spell them. The dollar sign that prefixes a variable name is just a dollar sign, so I guess that ":=" is just "colon-equals".

When you're writing tutorials, documentation, etc, it's always a tough call whether to stick rigidly to the terminology of the spec or to introduce terms of your own. I'll go either way depending on the merits of the case. Usually I try to stick to standard terminology but if the terminology in the spec is really bad then I'll introduce something new (for example I reckoned that no-one except the most avid spec-readers would know what an error message referring to a "transform expression" was talking about, so I called it a "copy-modify expression" instead).

Personally I find the distinction between assignment and binding rather precious. After all, we use the terms "variable" and "function" in both procedural and functional language to mean somewhat different things, and no-one minds. When I come to a new language, I find it easier if most of the terminology is familiar, even if the properties of the objects or operations that the terms refer to are a bit different.

Michael Kay
Saxonica
Post by Joe Wicentowski
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
":=" 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 ____."
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 via
https://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.
_______________________________________________
http://x-query.com/mailman/listinfo/talk
_______________________________________________
talk
Joe Wicentowski
2016-11-21 18:29:35 UTC
Permalink
Hi Mike,
Post by Michael Kay
Actually most of the symbols in the language don't have names. For example "+" doesn't have a name.
Fair point. But it is at least possible to track down or piece
together a plain English description of the "+" operator, e.g., at
https://www.w3.org/TR/xpath-functions-31/#func-numeric-add. Similarly,
the dollar sign that prefixes a variable name is explained in plain
English at https://www.w3.org/TR/xquery-31/#id-variables. I'm okay
with calling ":=" "colon-equals" or even not giving it a name. But
unlike the other unnamed symbols, ":=" has no plain English
definition, only an indirect, tertiary definition by way of the EBNF
notation for clauses that use it. I'm not saying that the spec is
obligated to provide a name or plain English description for all
symbols, but it does strike me that an agreed-upon description for
this one - prominent in the L of XQuery's signature expression - would
be useful to provide to people learning the language.

Thanks,
Joe
_______________________________________________
***@x-query.com
http://x-query.com/mailman/listinfo/talk
Liam R. E. Quin
2016-11-21 20:01:13 UTC
Permalink
Post by Joe Wicentowski
Hi Mike,
Post by Michael Kay
Actually most of the symbols in the language don't have names. For
example "+" doesn't have a name.
Fair point. But it is at least possible to track down or piece
together a plain English description of the "+" operator,
The - sign, however, has multiple uses as do ( and ) and so does the
full stop: referring to a full stop (or "period") in 3.14159 isn't
usual terminology and referring to a decimal point in $person/socks[. =
"black"] is both confusing and technically incorrect.

For my part I prefer to teach people using as little jargon as possible
and only add names for things when we're going to be referring to them
a lot. It's probably more useful for people to understand that :=
generally appears in binding expressions, in which a name on the left
is associated with something on the right, than to delve into the
grammar. But a lot depends on your teaching style and the audience, and
I haven't taught XQuery particularly.

If you'd like to give := a name, e.g. "the greybeard symbol", please
feel free to file a comment against XQuery 3.1 and/or XPath 3.1
(there's instruections in the editors' drafts e.g. at
https://www.w3.org/XML/Group/qtspecs/specifications/xquery-31/html/xque
ry-31.html
and the "Status" sections has pointers to bugzilla. If it will help
people in teaching we could add a note. But I think we'd want to hear
from multiple people, as this is the first request I've seen.

Of course, as Mike Kay suggested, you could also invent your own name
for it (sideways double-i?) and use that too!

Thanks,

Liam
--
Liam R. E. Quin <***@w3.org>
The World Wide Web Consortium (W3C)
_______________________________________________
***@x-query.com
http://x-query.com/mailman/listinfo/talk
Michael Dyck
2016-11-21 20:40:03 UTC
Permalink
Post by Joe Wicentowski
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?
Yup, Appendix A lets you call it a "symbol". (More specifically, a "terminal
symbol" or a "delimiting terminal symbol", but those are too cumbersome for
the blank in your sample sentence.)

-Michael
_______________________________________________
***@x-query.com
http://x-query.com/mailman/listinfo/talk
Benito van der Zander
2016-11-21 21:19:18 UTC
Permalink
Hi,
Post by Joe Wicentowski
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
Post by Joe Wicentowski
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
":=" 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 ____."
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 via
https://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.
_______________________________________________
http://x-query.com/mailman/listinfo/talk
Ghislain Fourny
2016-11-22 07:15:01 UTC
Permalink
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
Post by Joe Wicentowski
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
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
":=" 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 ____."
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.
Loading...