Copy by value

gd shared this idea 10 years ago
Completed

I propose a prefix (e. g. %) which causes the variable or other expression after it to be evaluated when the command is issued, so that the definition in which it occurs will contain the current value of the expression and it will not be dependent on the variable (or variables in the expression). E. g.

    b=%a

would create a copy of a and make b a free object with the same value,

    r=%(random())

would give a random value to r which will not change in the future and

    b=%(b+a)

would increment the value of b (a free object) by a.


This would be useful for simple users to copy a variable and it would be necessary for the scripting system I propose.

Comments (3)

photo
1

Being able to save/copy by value would give powerful new options ... especially using and exploring 'semi-random' constructions and/or IterationList tools, sequences and loops ...

photo
1

Question: what is the difference to CopyFreeObject()

photo
1

b=%a

    SetValue(b,a)

    r=%(random())

SetVaue(r,random())

    b=%(b+a)
    SetValue(b,b+a)

© 2019 International GeoGebra Institute