Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
/*
 * This file:
 *   http://anggtwu.net/MAXIMA/2025-methods.mac.html
 *   http://anggtwu.net/MAXIMA/2025-methods.mac
 *          (find-angg "MAXIMA/2025-methods.mac")
 * Author: Eduardo Ochs <eduardoochs@gmail.com>
 * See: http://anggtwu.net/eev-maxima.html#methods
 *      (find-maximamsg "59192342 202506 07" "Edrx: examples and screenshots")
 *      (find-maximamsg "59187622 202505 25" "Edrx: preliminary announcement")
 *      (find-es "maxima" "defstruct-ab")
 *
 * Methods for Maxima's "defstruct"s, inspired by Lua.
 * In Lua ":" is translated in this way:
 *
 *        o:f   (4, 5)
 *   ==>  o.f(o, 4, 5)
 *
 * In Maxima the "@@" - defined below - is translated in this way:
 *
 *         defstruct(ab(a, b));
 *         o :   new(ab(2, 3));
 *         o@@f   (4, 5);
 *   ==>  ab__f(o, 4, 5);
 *
 * The methods for a structure "ab" are stored in functions with names
 * starting with "ab__".
 *
 * «.core-tests»	(to "core-tests")
 * «.poly-tests»	(to "poly-tests")
*/


"@@4"(structname,o,method,Args) :=
   apply(concat(structname,"__",method), append([o],Args));

"@@" (o,method) :=
   buildq([o,method], lambda([[Args]], "@@4"(op(o),o,method,Args)));

infix("@@",200,201);



/* «core-tests»  (to ".core-tests")
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("2025-methods.mac");
"@@4"(ab,oab,f,[4,5]);            " ab__f(oab, 4, 5) "$

defstruct(ab(a,b));
oab : new(ab(2,3));
oab@@f;                           " lambda([[Args]], @@4(op(oab),oab,f,Args)) "$
oab@@f  (4,5);                    " ab__f(oab, 4, 5) "$

ab__f(o,x,y) := [o@a,o@b,x,y]$
oab@@f  (4,5);                        " [2, 3, 4, 5] "$

*/

/* «poly-tests»  (to ".poly-tests")
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("2025-methods.mac");
seqby(a,b,stp) := makelist(i, i,a,b,stp);
defstruct(poly(poly,var));
poly__hi   (p)     := hipow(p@poly, p@var)$
poly__coef (p,k)   := ratcoef (p@poly, p@var, k)$
poly__coefs(p,ks)  := makelist(p@@coef(k), k, ks)$
poly__L    (p)     := p@@coefs(seqby(p@@hi(),0,-1))$

myp : new(poly(10*x^2 + 20*x + 30, x));
myp@@hi();                               " 2               "$
myp@@coefs([3,2,1,0]);                   " [0, 10, 20, 30] "$
myp@@L();                                "    [10, 20, 30] "$

*/