Greetings,
I'm using 'Mozart Compiler 1.3.1 (20040617) playing Oz 3' in a Win2K
environment.
According to Section 5.5 of the Oz Docuemntation it is possible to have
identically-named variables at different scopes. Access to the outer-scoped
variable is possible [in certain contexts] via the '!' operator which
'suppresses' the inner-scoped variable.
The following code uses this approach, but it doesn't seem possible to
access the outer variable to assign it a value; instead, the program fails
[diagnostic given in code comment]:
functor
import
System Application
define
proc {ComputeStatistics}
N = 5.0
local
AVGDEV = {NewCell 5.0}
in
% Access to 'local' AVGDEV ok
AVGDEV := @AVGDEV / N
%
% How to access to 'outer' AVGDEV ? This approach
% fails with:
%
% %** Tell: 1.0 = <Cell>
%
% message
%
!AVGDEV = @AVGDEV
end
end
proc {ShowStatistics}
{System.printInfo "n: "#N#"\n"}
{System.printInfo "avgdev: "#AVGDEV#"\n"}
end
N AVGDEV
in
{ComputeStatistics}
{ShowStatistics}
{Application.exit 0}
end
If this line:
!AVGDEV = @AVGDEV
is commented out and the program run, then it blocks, indicating that the
outer variable exists [and is entirely separate to the inner variable, as
one would expect]. However, according to the diagnostics, it is the the
inner variable that is being referred to on the left hand side [at least
that is how I interpret it].
My questions:
* Have I misread / misunderstood the documention on this
topic ?
* How would I go about accessing the outer variable in
the above example ?
Any help appreciated.
Cheers,
Anthony Borla
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users