axiom-developer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Axiom-developer] Bootstrap documentation.


From: Gabriel Dos Reis
Subject: Re: [Axiom-developer] Bootstrap documentation.
Date: Tue, 8 May 2007 04:00:23 -0500 (CDT)

On Tue, 8 May 2007, Ralf Hemmecke wrote:

[...]

| > Spad needs to move to mutual recursion (with appropriate restrictions)
| > anyway.
| 
| Does someone know of an instance of mutual recursion in the Axiom library that
| cannot be cured with "extend"? (I am not saying that I don't want mutual
| recursion, but rather whether it is needed for the current Axiom library.)

This is not from the Axiom library, but I do run into it very often.

Assume I want to represent a typed abstract syntax tree for the
C language.  In C, I have the following (simplifying a bit)
  
   * literals
   * declarations
   * types
   * expressions
   * ...

A type can be:
    - an identifier
    - a structure, with components that are are fields (declarations
         involving names, types, and expressions)
    - an array, with components that are a type and an expression
    - ...

An expression among other things, contains:

    - sizeof (type)

I want distinct domains for literals, fields, types, expressions, etc. 


In Haskell (or Boot), I could write:

   type Symbol = String

   data Type = Identifier Symbol
             | Structure (Maybe Symbol) [Field]
             | Array Type Expression
             -- and more

   data Field = Bitfield (Maybe Symbol) Expression Type
              | NonBitfield Symbol Type

   data Expression = StringLiteral String
                   | SizeofExpr Expression
                   | SizeofType Type
                   -- and more

What would be a "natural" and concise expression of that in Spad?

-- Gaby




reply via email to

[Prev in Thread] Current Thread [Next in Thread]