Post Reply 
At this point, if I were to vote for new features....
06-27-2017, 04:39 AM
Post: #1
At this point, if I were to vote for new features....
...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
Find all posts by this user
Quote this message in a reply
06-27-2017, 07:03 PM
Post: #2
RE: At this point, if I were to vote for new features....
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!
Find all posts by this user
Quote this message in a reply
06-27-2017, 07:19 PM (This post was last modified: 06-28-2017 01:19 PM by compsystems.)
Post: #3
RE: At this point, if I were to vote for new features....
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/~pari...ffectation

http://www-fourier.ujf-grenoble.fr/~pari...tml#htoc86
Find all posts by this user
Quote this message in a reply
06-27-2017, 11:31 PM
Post: #4
RE: At this point, if I were to vote for new features....
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
Find all posts by this user
Quote this message in a reply
06-28-2017, 01:41 AM
Post: #5
RE: At this point, if I were to vote for new features....
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
Find all posts by this user
Quote this message in a reply
06-28-2017, 02:19 AM
Post: #6
RE: At this point, if I were to vote for new features....
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 :-)
Find all posts by this user
Quote this message in a reply
06-28-2017, 08:47 AM
Post: #7
RE: At this point, if I were to vote for new features....
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.
Find all posts by this user
Quote this message in a reply
06-28-2017, 05:06 PM
Post: #8
RE: At this point, if I were to vote for new features....
(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!

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
Post Reply 




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