Using "get" inside a function



Hi, there seem to be two issues here:

1) the semantics of variable quoting
      and
2) the semantics of properties.

Both of them hinge on the difference between a *variable* (container) and
its *value* (thing contained).  With put('foo,...), you have given the
*container* a value.  If you now pass the contents of that container to a
function, the function has no way of knowing the properties of the
container.

Maxima does not give users the possibility of giving values properties, so
there are several possibilities:

1) you could pass the container itself (e.g. myfunc('foo) ), but then to get
its value within the function you would have to write ev(foo), not just foo.
2) you could have a separate array of properties, e.g. you say myprop[foo] :
234$
3) you could define your own objects of the form, e.g., [val, [prop1,val1],
[prop2,val2]...] etc.

I believe there is also an object system for Maxima, but I haven't used it
myself.

            -s

On Sun, Mar 6, 2011 at 14:29, Bruce Linnell <brlinnell at verizon.net> wrote:

>  Hi -
>
> I am trying to use "get" inside a function in order to make decisions based
> on the properties of the variable I've passed to the function.  I've used
> LISP as well as various versions of Macsyma/Maxima in the dim and distant
> past, but I've just started to use it again recently.  I'm using version
> 5.23.2 of XMaxima in Windows.  I am doing the following at the command line
> :
>
>
> g_ll:matrix([-1,0,0,0],[0,A^2/(1-K*r^2),0,0],[0,0,A^2*r^2,0],[0,0,0,A^2*r^2*sin(theta)^2]);
>     put(' g_ll,' Trank2LL,' Trank);
>  NOTE : I've intentionally put spaces after every ' in this email so that
> they can be seen (the ' is hard to see as 'T on my screen).  My actual code
> has no spaces.
>
> My function is currently (stripped down for testing, and to match the
> manual's example) :
>
>     TensorTrace (T) :=
>     block
>       (
>       [temp],
>       temp:get(' T,' Trank)
>       )$
>
> And the function call is : TensorTrace(g_ll);
>
>
> My problem is this : WITH a ' before the T (as shown), the debugger says
> that T is a 4x4 matrix with the correct terms, but T only has the properties
> [value], whereas (also within the debugger) g_ll has the properties [value,
> [user properties, Trank]].
>
> And WITHOUT a ' before the T, when I call the function I get a "get:
> argument must be a symbol or a string; found: errexp1" error message. But
> the example on (Adobe's) page 514 of the manual under get shows :
>         get(expr,'type)
> where expr is the variable passed to the function!
>
> I'm so confused!  Is there some other option besides ' T and T ?  Why
> doesn't it work without a ' like the example in the manual?
>
> Thanks in advance to all who reply.
> Bruce Linnell, PhD
>
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
>