Post Reply 
Why x:=CAS("x") = 0 ?
03-27-2018, 12:52 PM
Post: #1
Why x:=CAS("x") = 0 ?
I know that doing this may not make much sense, since the use of CAS variables does not require the creation of an HP PPL variable with the same name, or even that they are created. But recently I could see how some people use it and I have doubts.

LOCAL x=CAS("x");
PRINT(x) → 0 //Why? recursivity?

LOCAL var1=CAS("x");
PRINT(var1) → x //Expected, usual practice

LOCAL x=CAS(CAS("x"));
PRINT(x) → x //Why???

I would like to know what this is due to and if there will be any correction in this regard.

Viga C | TD | FB
Visit this user's website Find all posts by this user
Quote this message in a reply
03-27-2018, 02:24 PM (This post was last modified: 03-27-2018 02:26 PM by Han.)
Post: #2
RE: Why x:=CAS("x") = 0 ?
When using CAS(), any variable references will first be resolved within the user's existing CAS environment. Then, variables are resolved using the local variables from the routine that called CAS(). At that instance, the local variable x has a default value of 0. You can test this by separating the declaration from the assignment.

When you use CAS(CAS()) the inner CAS() commands will try to use the outer CAS() command's local variables (and there are none).

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
03-28-2018, 02:47 AM
Post: #3
RE: Why x:=CAS("x") = 0 ?
It is an assignment in the same line of LOCAL, I would understand it if it were:
LOCAL x;
x:=CAS("x");
But this could also be possible:
LOCAL var1:=var1; → var1=0 ??

I do not really agree that it fails like that.

Regarding the double environment generated by CAS CAS, it seems to me that it is not working as expected, now it can be exploited but will should continue searching until it leaves the final nested environment?

Viga C | TD | FB
Visit this user's website Find all posts by this user
Quote this message in a reply
03-28-2018, 03:21 AM (This post was last modified: 03-28-2018 03:21 AM by Carlos295pz.)
Post: #4
RE: Why x:=CAS("x") = 0 ?
I'm considering name resolution, but something does not quite convince me.
http://www.hpmuseum.org/forum/thread-621...l#pid55671

Viga C | TD | FB
Visit this user's website Find all posts by this user
Quote this message in a reply
03-29-2018, 11:14 AM
Post: #5
RE: Why x:=CAS("x") = 0 ?
Great Mr. parisse, I invoke you, please destroy me with their words.

Viga C | TD | FB
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




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