-
-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
prof:variables(): Show all variables? #1115
Comments
I would propose that The following query currently only outputs bindings of declare function local:foo($x) {
let $y := $x * $x
return
if($x gt 1) then (
for $i in 1 to $y
return $x
) else prof:variables()
};
for $a in 1 to 5
return local:foo($a) This could be fixed by generating the following code after all variables are resolved but before optimizing: declare function local:foo($x) {
let $y := $x * $x
return
if($x gt 1) then (
for $i in 1 to $y
return $x
) else prof:dump(
map {
'$x': $x,
'$y': $y
},
'Local Variables: '
)
};
for $a in 1 to 5
return local:foo($a) Even though the function disappears and |
I didn't think of that.. Sounds like a good idea! |
… is not yet bound.
One interesting case are closures, should all potentially reachable variables be referenced or only the actually captured ones? The first option seems preferable, but the closure would potentially become much bigger without the programmer knowing why... |
GH-1115: NPE in `prof:variables()` when variable is not yet bound.
Good point. Option 2 sounds more attractive to me; I think the output of this function should be as intuitive as possible. |
How about this? for $i in 1 to 5,
$j in 1 to 5
let $f :=
function($k) {
prof:variables(),
$i * $k
}
return $f($j) I would expect either |
A flag may indeed be the best choice. As |
prof:variables()
prof:variables()
: Show all variables?
prof:variables()
: Show all variables?
Do you know what's the most convenient way to access all potentially reachable variables? This is the current code... https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/query/var/QueryStack.java#L132-L141 |
Query:
Expected:
No variable bindings, some random squared number.
Got:
The text was updated successfully, but these errors were encountered: