HP Forums
At this point, if I were to vote for new features.... - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: At this point, if I were to vote for new features.... (/thread-8580.html)



At this point, if I were to vote for new features.... - webmasterpdx - 06-27-2017 04:39 AM

...it'd be 2 things. A way to define macros (maybe remove the define functions and make it a macro instead). I've heard the argument for the define functions (a simpler way to program for beginners)....well, the macros will work just as well for them, and will provide more advanced programmers with a valuable capability. The second would be to be able to pass arguments by reference. Apart from being able to get arguments changed, it'll greatly speed up the passing of matrices or grobs which are currently passed by value.
Both of these features will not require any changes to hardware.
In most cases, as far as users are concerned, the define should return the same results as before, so the change would be unnoticable, and programs that call them should run faster.

Thx
-D


RE: At this point, if I were to vote for new features.... - parisse - 06-27-2017 07:03 PM

Inside the CAS, reference access to list (including matrices) is already available by reference using =< instead of :=
Example
m:=[1,2,3];
l:=m;
m[1]=<4;
l;
This is a feature for advanced users only, because sometimes the same list is used twice or more in a matrix!


RE: At this point, if I were to vote for new features.... - compsystems - 06-27-2017 07:19 PM

difference between := & =<


Possible error
Code:
m:=[1,2,3]; returns [1,2,3]
l:=m; returns [1,2,3]
m[1] =< 4; returns [4,2,3]
l; returns [1,2,3]  ? l should be [4,2,3]

Code:
m:=[1,2,3]; returns [1,2,3]
l:=m; returns [1,2,3]
m[1] := 4; returns [4,2,3]
l; returns [1,2,3] // ok

More info about (<=) cmd

http://www-fourier.ujf-grenoble.fr/~parisse/giac/doc/fr/cascmd_fr/cascmd_fr824.html#sec:diffaffectation

http://www-fourier.ujf-grenoble.fr/~parisse/giac/doc/fr/cascmd_fr/cascmd_fr066.html#htoc86


RE: At this point, if I were to vote for new features.... - webmasterpdx - 06-27-2017 11:31 PM

I'll need to look at this. With just a cursory look, it looks like indexing by reference, not passing by reference (different thing). However, it could be useful.
I didnt have time to look at it in detail....I will later.
Thx


RE: At this point, if I were to vote for new features.... - webmasterpdx - 06-28-2017 01:41 AM

OK, I played around with this and it really doesn't do anything.
When in CAS I type m(1)=<4;, it converts the line to m(1):=4;
Also, when you give code examples, please use the correct braces.
e.g. m:={1,2,3}; NOT m:=[1,2,3];
m(1), not m[1].....
None of your links worked....so what exactly is =< other than a replacement for := ?????
Thx
-D


RE: At this point, if I were to vote for new features.... - webmasterpdx - 06-28-2017 02:19 AM

OK, I think I've figured it out....
m:=[1 2 3];
l:=m;
m[1]=<4; is actually array_sto(4,at(m,0)); So, it gets stored in both m and l.
m returns [4 2 3]
l returns [4 2 3]

Now, if I do:
m[1]:=8; is actually at(m,0):=8; Here it only stores in m but not in l.
m returns [8 2 3]
l returns [4 2 3]

So, =< writes by reference, so when you type l:=m; it's just storing a reference to m in l....so the write causes both l and m to be written at once.
When := is used, only the variable m is written, so I think this operation causes m and l to be separated into 2 different vectors.

...or something like that :-)


RE: At this point, if I were to vote for new features.... - parisse - 06-28-2017 08:47 AM

Indeed, if you store in a list with :=, a copy of the list is created. This is of course inefficient but it prevents side-effects like for example if you create a matrix with 1 everywhere like this
l:=seq(1,3);
m:=seq(m,3);
and if you modify in place one coefficient:
m[1,2]=<3
you will modify a whole column.
That's the reason why =< should be used by advanced users only.


RE: At this point, if I were to vote for new features.... - toml_12953 - 06-28-2017 05:06 PM

(06-27-2017 07:03 PM)parisse Wrote:  Inside the CAS, reference access to list (including matrices) is already available by reference using =< instead of :=
Example
m:=[1,2,3];
l:=m;
m[1]=<4;
l;
This is a feature for advanced users only, because sometimes the same list is used twice or more in a matrix!

Now if only =< worked outside of CAS, I'd be a happy camper!