Gaby,

I am enthusiastic about this kind of change, but as usual I have some
comments and questions ... :-)

On Sat, May 17, 2008 at 2:03 PM, Gabriel Dos Reis wrote:
>
> As of revision 573, the interpreter now accepts calling a constructor
> with a homogeneous variable length argument list, when the constructor
> is defined to take a tuple.  This new capability makes it possible
> to define domains like Enumeration as ordinary OpenAxiom domains.

Good!

> For example, given
>
> )abbrev domain MYENUM MyEnum
> MyEnum(enums: Tuple Symbol): Public == Private where
>  Public ==> SetCategory with
>    coerce: Symbol -> %
>
>  Private ==> add
>    Rep == NonNegativeInteger
>
>    coerce(s: Symbol): % ==
>      for i in 0..(length enums - 1) repeat
>        s = select(enums,i) => return per i
>      userError [s, "is not a valid enumerator"]
>
>    e1 = e2 ==
>      rep e1 = rep e2
>
>    coerce(e: %): OutputForm ==
>      select(enums, rep e)::OutputForm
>
>
> I have
>
> (1) -> WeekDay := MyEnum(Mon,Tue,Wed,Thu,Fri)
>
>   (1)  MyEnum(Mon,Tue,Wed,Thu,Fri)
>                                                                 Type: Domain
> (2) -> Mon :: WeekDay
>
>   (2)  Mon
>                                            Type: MyEnum(Mon,Tue,Wed,Thu,Fri)
>
> (3) -> Sat::WeekDay
>
>   >> Apparent user error:
>   Sat
>   is not a valid enumerator
>

Question:

1) What happens if there is more that one Tuple or another type of
argument in the argument list? E.g.

     TupleDom(sym: Tuple Symbol, str:String, int: Tuple Integer):
Public == Private where

2) Can I write something like?

    MyDom := TupleDom( (x,y,z,w,u), "test", (1,2,3,4,5))

    or do I still need to use [x,y,z ... ] ?

3) Can I use Tuple in a similar manner when calling a function? E.g.

    t(x:Tuple PI):INT == length(x)

    t(1,2,3)

instead of?

   t([1,2,3])

Comments:

1) Besides 'Tuple', would it also be possible to treat 'Record' and
'Union' this way? E.g.

     RecDom(arg:Record(sym: Symbol, str:String, int: Integer)): Public
== Private where

         if arg.sym=x and arg.str="x" or arg.int=0 then ...

    MyDom := RecDom(x,"x",1)

----------

     UnionDom(arg:Union(sym: Symbol, str:String, int: Integer)):
Public == Private where

         if arg case sym  then ...

    MyDom := UnionDom("x")

----------

(1) -> f(x:Union(Integer,Float)):Union(Integer,Float) == (x case
Integer => x+1; x+1)

   Function declaration f : Union(Integer,Float) -> Union(Integer,Float)
   has been added to workspace.
                                                      Type: Void
(2) -> f(2.0)

   Compiling function f with type Union(Integer,Float) -> Union(Integer,Float)

   (2)  3.0
                                                       Type: Union(Float,...)

(3) -> f(2)

   (3)  3.0
                                                       Type: Union(Float,...)

(4) -> f(-1::Union(Integer,Float))

   (4)  0.0
                                                       Type: Union(Float,...)

---------

Regards,
Bill Page.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
open-axiom-devel mailing list
open-axiom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open-axiom-devel

Reply via email to