[Bug 3842] [XQuery] 4.14 Variable Declaration: circularity

http://www.w3.org/Bugs/Public/show_bug.cgi?id=3842





------- Comment #4 from jmdyck@ibiblio.org  2006-10-19 02:35 -------
(In reply to comment #3)
>
> No, I don't think there's any uncertainty. The sentence clearly describes a
> relation between variables, not between variable names.

I disagree re "clearly". True, it uses the word "variable" and not "variable
name", but it also refers to "$x" and "$y", which are variable names (or,
strictly speaking, *contain* variable names), not variables. (You could avoid
that particular problem by referring to, say, "V<sub>1</sub>" and
"V<sub>2</sub>", i.e., by making them look as different as possible from
concrete variable references, but I don't think it would increase the clarity
that much; the problem is that on the whole, the spec doesn't make that much of
a distinction between variables and variable names.)

> The fact that two variables can have the same name is completely irrelevant.

That might be worth saying in the spec, but I think I have a better
suggestion...


> A more pendantic definition might be
> 
> A variable binding $x "depends on" a variable binding $y or a function f2 if a
> variable reference bound to $y or a function call bound to f2 appears
> in the initializing expression of $x. A function f1 "depends on" a variable
> binding $y or a function f2 if a variable reference bound to $y or a function
> call bound to f2 appears in the body of f1. If a variable binding depends
> on itself by any combination of direct or transitive dependencies, a static
> error is raised [XQST0054].

Well, if we're getting pedantic, then:

-- The only bolded occurrence of "variable binding" (in 4.14) strongly suggests
that a variable declaration is not a variable binding. So a "variable binding"
is exactly what the definition of "depends on" should *not* be concerned with.
(Moreover, the spec seems generally undecided on whether a "variable binding"
is a static or dynamic thing, and whether it binds a variable to a value or an
expression.)

-- According to 3.1.2, a variable reference is not "bound to" a variable
binding, it "matches" or "refers to" a variable binding.

-- There's no basis for the phrase "a function call bound to [the function]
f2". (Mind you, I don't think the spec provides any verb for that relation.)

> ... but I would have thought any reader capable of understanding that would
> also understand the text that Don proposed.

I think the second one, despite my pedantic objections, would have given me
less uncertainty about your intent than the first one did.

However, I think you can do better (convey your intent without uncertainty, and
without pedantry): instead of making "depends on" a relation on variables and
functions (or variable bindings and functions), make it a relation on variable
declarations and function declarations. E.g.:

     A variable declaration V1 "depends on" a variable declaration V2
     or a function declaration F2 if a use of V2 or F2 appears in the
     initializing expression of V1.
     etc.
     [or maybe "reference to" instead of "use of"]

This gets away from the not-that-well-defined notions of "variable" and
"variable binding", and instead couches the definition (as much as possible) in
the nice solidly static world of syntax, where it's clear that (e.g.)
    let $x := 42 return $x
does not contain a variable declaration or a use of one, and so does not enter
into the "depends on" relation.

Received on Thursday, 19 October 2006 02:35:48 UTC