login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Edit detail for LanguageDifferences revision 4 of 15

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Editor: test1
Time: 2013/05/17 14:20:35 GMT+0


-   l : List Integer := [ 1,  2,  3,  4,  5,
-                         6,  7,  8,  9, 10,
-                        11, 12, 13, 14, 15]

              my_list : List Integer := [ 1,  2,  3,  4,  5,
                                          6,  7,  8,  9, 10,
                                         11, 12, 13, 14, 15]

As mentioned on FriCASProgramming?, there are a number of languages connected to PanAxiom?. Since for actual users only 3 of them are relevant, namely, Spad, the Axiom interpreter language, and Aldor, we are going to list here a number of differences.

The main difference between Aldor/Spad and the interpreter language is that the interpreter language is more relaxed with respect to types. As a first iteration one could say that the interpreter language is identical with Spad plus a mechanism that throws in coercion functions in places where they make sense. This mechanism is, however, a heuristics. It sometimes does a coercion at the wrong moment so that eventually the computation will not succeed for seemingly non-obvious reasons.

In fact, these coercions are helpful for people that come from typeless computer algebra systems. Neither Spad nor Aldor do such automated coercions. For serious library it is a good thing to be explicit about type coercions. The flow of computation should be predictable.

There are other small differences. For example, you can use the keyword rule in the interpreter like:

  rule log(x) + log(y) == log(x * y)

but that form is not available in Spad or Aldor. You would have to call the corresponding library functions more explicitly.

Currenly in FriCAS? interpreter and Spad compiler share first stage. Conseqently Spad and intepreter keyword are almost the same, the difference is that Spad compiler treats words rule and default as ordinary identifiers. Also, Spad compiler does not form piles in some cases where intepreter would make them. For exmaple:

<p>              my_list : List Integer := [ 1,  2,  3,  4,  5,
                                          6,  7,  8,  9, 10,
                                         11, 12, 13, 14, 15]

works producing a list in Spad, but leads to parse error due to unwanted piles in the interpreter.

Differences between Aldor and Spad

  • Aldor has Generator, Spad has not.
  • delay is a (unused and reserved) keyword in Aldor but not in Spad. Rather it is a function name in the Axiom library.
  • Aldor programs can be written in ordinary mode with braces and semicolons or in pile mode (which must be introduced via the compiler directive #pile) Spad is written exclusively in pile mode.
  • Compiler directives start with '# in Aldor and with )' in Spad.
  • Each domain/package/category has to be abbreviated via the ')abbrevÍ„' directive in Spad. In Aldor that is not necessary.
  • Spad uses import Integer. In Aldor one writes import from Integer.
  • In Aldor the representation Rep is defined as a constant, i.e., one writes something like:
          Rep == Record(re: Integer, im: Integer)
        whereas in Spad one has to write::
          Rep := Record(re: Integer, im: Integer)
        i.e., like a variable assignment.
  • The meaning of == in Aldor is: "assignment of a constant". In Spad == means "delayed assignment".
  • In Aldor, one must properly use rep and per to convert between the types % and Rep. In Spad, this is not always necessary. This is one of the places where Spad throws in some mild form of automated coercion.
  • Spad uses an apostroph to introduce a symbol:
          op := operator 'X
        In Aldor, the apostroph is reserved, but not used.
  • Aldor allows to extend a domain D by a category C like this:
          extend D: C == add {...}
  • (syntactic sugar) Where Aldor uses the special function name apply, Spad use elt.
  • (syntactic sugar) Aldor uses bracket whereas Spad uses construct, i.e., '[a,b,c]?' is translated to bracket(a,b,c) and construct(a,b,c), respectively.
  • The category defaults are given in Aldor like this:
          C: Category == with {
             default { ... }
        whereas in Spad they are written with the 'add' keyword::
          C: Category == with
  • Aldor has exception handling, Spad has not.
  • Aldor knows the builtin types Cross, TrailingArray, Literal, which are not in Spad.