Ralf Hemmecke <[email protected]> writes:
| Hi,
|
| I'm used to parametrized macros. Are they available in SPAD?
There are available in OpenAxiom since version 1.4.0.
When I tried to compile your example, I got:
****** comp fails at level 2 with expression: ******
error in function baz
(+ (* 2 |x|) | << | (^ 3 |x|) | >> |)
****** level 2 ******
$x:= (^ 3 x)
$m := Integer
>> Apparent user error:
Cannot coerce x of mode Integer to mode NonNegativeInteger
| The following program seems to suggest NO, but it also seems to
| contain a bug, since it compiles with X which is nowhere defined.
|
| ---rhxBEGIN tst.spad
| EXX ==> Expression X
| EX Y ==> Expression Y
| fooz z ==> 2*z+3^z
|
| )abbrev category CATX CatX
| CatX(R: Ring): Category == with
| foo: EXX -> Integer
|
| )abbrev category CATY CatY
| CatY(R: Ring): Category == with
| foo2: EX R -> Integer
|
| )abbrev domain MINT MyInteger
| MyInteger: IntegerNumberSystem with
| baz: Integer -> Integer
| == Integer add
| -- fooz z ==> 2*z+3^z
| baz(x: Integer): Integer == fooz x
| ---rhxEND tst.spad
|
| Compilation aborts with the following message.
|
| MINT abbreviates domain MyInteger
| ------------------------------------------------------------------------
| initializing NRLIB MINT for MyInteger
| compiling into NRLIB MINT
| compiling exported baz : Integer -> Integer
| ****** comp fails at level 1 with expression: ******
| error in function baz
|
| ((|fooz| |x|))
| ****** level 1 ******
| $x:= (fooz x)
| $m:= (Integer)
| $f:=
| ((((|x| # #) (* #) (+ #) (- #) ...)))
|
| >> Apparent user error:
| cannot compile (fooz x)
|
| ==============================
| When "fooz z ==> 2*z+3^z" is mooved inside the "add" part of MINT, the
| error message is different. Why?
|
| ****** comp fails at level 3 with expression: ******
| error in function baz
|
| ((+ (* 2 | << z >> |) (^ 3 |z|)) |x|)
| ****** level 3 ******
| $x:= z
| $m:= $EmptyMode
| $f:=
| ((((|x| # #) (* #) (+ #) (- #) ...)))
|
| >> Apparent user error:
| Cannot coerce 2
| of mode (PositiveInteger)
| to mode $
|
| ==============================
| The compilation also shows
|
| --->/home/hemmecke/p/tst.spad-->CatX((foo ((Integer) (Expression
| X)))): Not documented!!!!
|
| --->/home/hemmecke/p/tst.spad-->CatY((foo2 ((Integer) (EX R)))): Not
| documented!!!!
|
| for CatX and CatY respectively, i.e. EXX seems to have been expanded
| to Expression X, but EX R is left untouched and not expanded to
| Expression R.
OpenAxiom does not expand EXX and EX.
| Can I somehow get paremetrized macros like in Aldor? According to the
| Axiom book (Chapter 6.2) parametrized macros should be available, but
| I guess that only applies to the interpreter.
yes, the AXIOM book was describing the interpreter; OpenAxiom included
them in the compiler too.
-- Gaby
------------------------------------------------------------------------------
RSA(R) Conference 2012
Mar 27 - Feb 2
Save $400 by Jan. 27
Register now!
http://p.sf.net/sfu/rsa-sfdev2dev2
_______________________________________________
open-axiom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/open-axiom-devel