You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
.STATIC sections nested inside sections are interesting.
Problem 1: The documentation says (in section 4.15.1) that plain .STATIC targets export all of their variables. However, the
export appears incomplete: we can access such a variable, but a
function defined inside the same .STATIC block does not retrieve
the variable's contents. No error is emitted, though.
Problem 2: If we export a function from a section and this
function binds a variable from a nested .STATIC section, the
binding dissappears outside of the defining section.
Example program (see comments for locations of Problem 1 and Problem 2):
## Uncomment the next line to see dynamic binding in action.
#public.b = $'top-level def'
section
.STATIC: # `.MEMO' works, too ;-)
a = $'sectioned, static def'
fa() =
return $(a)
## Use `a' and `fa' inside of static block.
println($"[section] [static] a = <$(a)>")
println($"[section] [static] fa: <$(fa)>")
## Use `a' and `fa' outside of static block.
println($"[section] a = <$(a)>")
## Problem 1: No error here, but "empty" result. We have
## just proven that `a' is visible, so `fa' ought to return
## `a's contents.
println($"[section] fa: <$(fa)>")
## Copy static `a' to non-static `b'.
b = $(a)
println($"[section] b = <$(b)>")
ga() =
return $(a)
gb() =
return $(b)
## Use `ga' and `gb' in the same scope as their definitions.
println($"[section] ga: <$(ga)>")
println($"[section] gb: <$(gb)>")
## `unbound variable' error triggered outside of `section'
## disappears if we add `a' to the export list. No need to
## export `b', though because of dynamic binding.
export ga gb
## Sectioned `b' has been "captured" by `gb'.
println($"gb: <$(gb)>")
## Problem 2: The next line fails with `unbound variable: public.a'.
println($"ga: <$(ga)>")
.STATIC
sections nested insidesection
s are interesting.Problem 1: The documentation says (in section 4.15.1) that plain
.STATIC
targets export all of their variables. However, theexport appears incomplete: we can access such a variable, but a
function defined inside the same
.STATIC
block does not retrievethe variable's contents. No error is emitted, though.
Problem 2: If we export a function from a
section
and thisfunction binds a variable from a nested
.STATIC
section, thebinding dissappears outside of the defining
section
.Example program (see comments for locations of Problem 1 and
Problem 2):
Output of
osh example.om
:The text was updated successfully, but these errors were encountered: