HP Forums

Full Version: im somewhst bsffled again
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
In a single file we have


local loc_list := {1,2,3};
export glob_list := {5,6,7};

add2list (s)
begin
loc_list := prepend (loc_list,s) ; //fails, cant see local
glob_list := prepemd (glob_list); //works
end;

Also, the following works

add2list2 (s)
begin
local l2:= loc_list;
loc_list := prepend (l2,s);
end;

Should i not be baffled and confused?
Actually, i just re-read the earlier post about cas and interstitial locals.
[Bug accessing LOCAL var in shared scope]

So locals are cloaked by Romulans but function locals are not.

This really means that a wrapper needs to be written for every use of a
"cas" function in a large program or else too many variables need to be
exported.

What is seems like is that calls to cas functions are not
really compiled along with the ppl stuff but do a runtime lookup
in the global export table. ??


Im no longer baffled, just annoyed.

Strange things occur:

Type sin (x) in the cas window

and it changes the input to

SIN (x).

But sin is in the catalog. Why isnt it SIN if thats what it wants?
The keyboard enters sin () which immediately turns into SIN.
Is this entry override supposed to make it easier to understand?
(11-26-2015 08:02 PM)ji3m Wrote: [ -> ]This really means that a wrapper needs to be written for every use of a
"cas" function in a large program or else too many variables need to be
exported.

I have run into this quite a number of times (e.g. when coding an equation library) and have found that the idea in add2list2 is the simplest workaround.

Wait until you start using local CAS variables whose names are the same as existing variables...
Hello,

There is another thread somewhere about the same subject.
The problem is that the CAS does not see local (function or program) variables.

The fact that it "looks" like it sees the current function local variable is because during the call to the CAS, the variable in the cas function arguement is replaced by it's value to HIDE the fact that the CAS does not see it.

Cyrille
Reference URL's