CopyVar
09-09-2017, 11:58 AM
Post: #1
 webmasterpdx Senior Member Posts: 541 Joined: Sep 2015
CopyVar
Can anyone explain the difference between these 2 lines....in terms of what happens?
A:=B;
CopyVar(A,B);

The docs say the second line copys the storage area that B holds into A's storage area. I see no difference between that an A:=B;.....
Alternatively, give me an example where they would not be the same...

Ultimately, what I'm trying to figure out is defined in this post...

Thx
-Donald
09-09-2017, 01:39 PM
Post: #2
 Joe Horn Senior Member Posts: 1,579 Joined: Dec 2013
RE: CopyVar
(09-09-2017 11:58 AM)webmasterpdx Wrote:  Can anyone explain the difference between these 2 lines....in terms of what happens?
A:=B;
CopyVar(A,B);

The docs say the second line copys the storage area that B holds into A's storage area. I see no difference between that an A:=B;.....
Alternatively, give me an example where they would not be the same...

The difference is that CopyVar doesn't evaluate the source variable. Here's a CAS example:

aa:='1+2' <-- this stores the algebraic expression '1+2' into aa.
bb:=aa <-- this stores the evaluated result, 3, into bb.
CopyVar(aa,cc) <-- this stores the unevaluated expression '1+2' into cc.

<0|ΙΈ|0>
-Joe-
09-09-2017, 03:01 PM
Post: #3
 ji3m Member Posts: 149 Joined: Sep 2015
RE: CopyVar
This behaviour is actually quite insane. Is it xcas or just fancy thinking. It make assignment equivalentto eval. No language I know does this. It make programming a nightmare. Sorry but it's crazy stuff.
A:=B is not the same as evaluating argument in a function call.

I work with android Prime only for now on my
Galaxy Tab Pro/Note 2
09-09-2017, 10:04 PM
Post: #4
 webmasterpdx Senior Member Posts: 541 Joined: Sep 2015
RE: CopyVar
Thank you. Now I understand what they meant.
-Donald
09-11-2017, 03:12 PM
Post: #5
 Tim Wessman Senior Member Posts: 2,209 Joined: Dec 2013
RE: CopyVar
You are looking at this from a "programming language" perspective. However, neither the HP language nor the CAS is really a "programming language" but rather a math language to represent mathematics.

Most math languages and numerical systems do behave this way and you prevent evaluation through use of other functions, quoting arguments, etc.

TW

Although I work for the HP calculator group, the views and opinions I post here are my own.
 « Next Oldest | Next Newest »

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