Post Reply 
im somewhst bsffled again
11-26-2015, 07:17 PM
Post: #1
im somewhst bsffled again
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?

I work with android Prime only for now on my
Galaxy Tab Pro/Note 2
Find all posts by this user
Quote this message in a reply
11-26-2015, 08:02 PM (This post was last modified: 11-26-2015 08:11 PM by ji3m.)
Post: #2
RE: im somewhst bsffled again
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?

I work with android Prime only for now on my
Galaxy Tab Pro/Note 2
Find all posts by this user
Quote this message in a reply
11-26-2015, 08:32 PM
Post: #3
RE: im somewhst bsffled again
(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...

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
11-27-2015, 06:27 AM
Post: #4
RE: im somewhst bsffled again
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

Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)