putting defstruct into the Maxima manual



A few years later....

Since build_info uses it .... how about ....

On 10/7/2009 7:34 AM, Richard Fateman wrote:

Could someone find a place for this and put it into the manual and
online info? Thanks. RJF

..................

Maxima includes a technique to establish records or structures with
named fields.
It uses the following functions: defstruct and new.  It uses the
operator @ .
Here's an example.

   defstruct(f(x,y,z)); /* declare f to be a record with 3 fields, x,y,z */
   myrecord: new(f);    /* myrecord is an instance of f */
   myrecord at y:45;       /*  change myrecord as seen below. */
   myrecord;  ==>    f(x,45,z)

accessing is done this way...

myrecord at y ==>  45.


  Initializers also possible

  defstruct(f(x,y=3.14159, z));
  ff:new(f)    ==>   f(x,3.14159,z)
  ff at y:2.71828 ==>   ff is  f(x,2.71828,z).



It is generally better to use more descriptive field names, ones that
are not likely to be assigned values.  If you use x as field name there is a danger that

you would assign it a value, like x:10.  But then ff at x means  ff at 10.