On Fri, May 16, 2008 at 10:50 PM, Bill Page <[EMAIL PROTECTED]> wrote:
> Gaby,
>
> I wanted to you send a "thank you!" for the implementation of 'rep'
> and 'per' in OpenAxiom. I frequently found the liberal and irregular
> use of 'pretend' in other Axiom dialects to be confusing - so much so
> that sometimes I had to resort to first writing code in Aldor to
> benefit from the improved error messages and consistent use of 'rep'
> and 'per' in order to get something to compile. Once it was working in
> Aldor then I could manually translate it back to SPAD and be
> reasonably confident that it would compile in SPAD also.
>
> The page:
>
>  http://axiom-wiki.newsynthesis.org/SandBoxSum
>
> is the first time I have been able to do this directly in SPAD using
> OpenAxiom. Consistent use of 'rep' and 'per' is a pleasure. And there
> seem to have been other less obvious improvements to the compiler.
> Thank you very much for this!

You're welcome.  Kudos to Luke Wagner who kindly reported the problem
and explained how painful to work around when he was working on a class
project.  It is good to see that you can now express things that were
difficult or impossible to express before.

I agree with your assessment about the use of `pretend'.  I wish my
students never
heard of `pretend' :-)

>
> ---------
>
> Then I'll ask just one question about Union:
>
> (1) -> )sh Union(a:Integer,b:Float)
>
>  Union(a: Integer,b: Float) is a domain constructor.
> ------------------------------- Operations --------------------------------
>
>  ?=? : (%,%) -> Boolean                ?case? : (%,a) -> Boolean
>  ?case? : (%,b) -> Boolean             coerce : % -> OutputForm
>  construct : Float -> %                construct : Integer -> %
>  ?.? : (%,b) -> Float                  ?.? : (%,a) -> Integer
>  ?~=? : (%,%) -> Boolean
>
> shows only 'construct' as an overloaded method for creating members of
> the Union.
>
> (1) -> x:Union(a:Integer,b:Float):=2
>
>   (1)  2
>                                                  Type: Union(a: Integer,...)
>
> (2) -> y:Union(a:Integer,b:Float):=3.14
>
>   (2)  3.14
>                                                    Type: Union(b: Float,...)
>
> But suppose I wanted to create a Union with two copies of 'Integer'?

This is impossible in all versions of AXIOM right now -- as documented
in the Jenks&Sutor book, under the euphemism `can be difficult to work with'.
Types in branches must not overlap.

> This is a tagged union so this should be possible, right? But what
> about the exports?

Currently, it is not.  And it can be frustrating -- almost a year ago, I spent
an incredible amount of time chasing that problem.  I did not have time to solve
it, but I believe you should open an bug report for it.  I know the
implementation
reasons why it is that way, but I don't think there is any `high
level' justification
for that limitation.

>
> (3) -> )sh Union(a:Integer,b:Integer)
>  Union(a: Integer,b: Integer) is a domain constructor.
> ------------------------------- Operations --------------------------------
>
>  ?=? : (%,%) -> Boolean                ?case? : (%,a) -> Boolean
>  ?case? : (%,b) -> Boolean             coerce : % -> OutputForm
>  construct : Integer -> %              construct : Integer -> %
>  ?.? : (%,a) -> Integer                ?.? : (%,b) -> Integer
>  ?~=? : (%,%) -> Boolean
>
> There seem to be two operations named 'construct' with the *same*
> signature! Surely one of these was intended to create an member of the
> Union tagged 'a' and the other a member tagged 'b'. But how can I call
> the correct one?
>
> (3) -> z:Union(a:Integer,b:Integer):=2
>
>   (3)  2
>                                       Type: Union(a: Integer,b: Integer,...)
> (4) -> z.a
>
>   (4)  2
>                                                        Type: PositiveInteger
> (5) -> z.b
>
>   >> Error detected within library code:
>   (0 . 2) cannot be coerced to mode (Integer)
>
> (5) -> z.b := 2
>
>   The form on the left hand side of an assignment must be a single
>      variable, a Tuple of variables or a reference to an entry in an
>      object supporting the setelt operation.
>
> (5) -> z:Union(a:Integer,b:Integer) := [b==3]
>
>   There are no library operations named OPTARG
>      Use HyperDoc Browse or issue
>                               )what op OPTARG
>      to learn if there is any operation containing " OPTARG " in its
>      name.
>
>   Cannot find a definition or applicable library operation named
>      OPTARG with argument type(s)
>                                 Variable b
>                               PositiveInteger
>
>      Perhaps you should use "@" to indicate the required return type,
>      or "$" to specify which version of the function you need.
>
> -------
>
> How can I create a member tagged with 'b'?
>
> In panAxiom I can write:
>
>   x:Product(Integer,Integer) := [1,2]
>
> With the dual construction of 'Sum' shown at the link above, I would
> also like to be able to write:
>
>  x:Sum(a:Integer,b:Integer) := ?
>
> and have it populate the correct copy of Integer. In Aldor I can use
> the "keyword arguments" like:
>
>  x:Sum(a:Integer,b:Integer) :=  [b==3]
>
> or equivalently 'union(b==3)'
>
>  http://www.aldor.org/docs/HTML/chap13.html#8
>
> but so far I have not found anything equivalent in any flavor of Axiom.
>
> Maybe 'setelt' should be exported by Union?
>
> I wonder if the reference to "OPTARG" in the error message shown above
> indicates that there is some incomplete support for this somewhere in
> the Interpreter?

When you wrote [b == 2], the interpreter understood that you were passing
in value for an optional argument -- much like value for `keyword parameter'
in some other programming languages.  I don't like much that double
interpretation
of `==' which depends on whether '==' appears at toplevel or inside expression.
I would rather use a different symbol for `keyword argument', than a fuzzy
interpretation of '=='.

(To be honest, as much as I dislike that notation for default values, I found
myself extending Boot with that notation in order not to fallback to
Lisp.  I tried some
other symbols but it would have required me to do an extensive modification to
the parser for the local problem I wanted to solve.)


>
> Any ideas about this?
>

It is a limitation documented in the Axiom Book.  Please fill a
`feature request'.

-- Gaby

-------------------------------------------------------------------------
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