> Bill Page wrote:
>> Normally I would just define local functions:
>>
>>        rep(x:%):Rep == x pretend Rep
>>        per(r:Rep):% == r pretend %
>>
>> but in this case I get the message:
>> ...
>>    compiling local rep : $ -> Union(acomp: A,bcomp: B)
>>       SUM;rep is replaced by x
>> Time: 0.14 SEC.
>>
>>    compiling local per : Union(acomp: A,bcomp: B) -> $
>>    Semantic Errors:
>>       [1] per: cannot pretend r of mode (Union (: acomp A) (: bcomp
>> B)) to mode $
>>
>> ****** comp fails at level 1 with expression: ******
>> error in function per
>>
>> ---
>>
>> I don't understand this error message from FriCAS. Perhaps this is
>> a bug that has been corrected in OpenAxiom?
>>

On Thu, May 14, 2009 at 9:58 PM, Waldek Hebisch wrote:
>
> Well, the compiler specifically checks if pretend is from a union
> to something which is no a union and rejects such pretends.  I can
> only guess that original Axiom developers considered such pretend
> to be too dangerous.  In fact, union has rather special representation,
> so most of the time such pretend would be wrong.  OTOH compiler
> contains no such check for records and records have the same
> problem with possibly different representation...
>

But you would agree I think, that the use of pretend in the context of
rep and per are in fact type-safe, right? Could we simply remove this
check from the compiler? Gaby: Is that what was done in OpenAxiom?

> Concerning Sum, the following (which is just a tiny part of Sum)
> compiles fine:
>
> )abbrev domain SUM Sum
> Sum (A:SetCategory,B:SetCategory) : C == T
>  where
>  C == SetCategory  with
>       selectsum     : % -> Union(acomp:A,bcomp:B)
>        ++ selectsum(x) \undocumented
>       in1  :   A -> %
>        ++ makefirst(a) \undocumented
>       in2 :   B -> %
>        ++ makesecond(b) \undocumented
>
>  T == add
>
>    --representations
>       Rep := Union(acomp:A,bcomp:B)
>       import Rep
>
>       rep(x:%):Rep == x :: Rep
>       per(r:Rep):% == r :: %
>
> Note that currently in FriCAS (like in original Axiom) Rep has
> magical properties, in particular it is enough to use '::' to
> convert between Rep and %.
>

I don't understand this use of :: It does not seem to me that coercion
should be involved in the definition of rep and per. By "magical" do
you really mean "inconsistent"? ;-)

Regards,
Bill Page.

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
_______________________________________________
open-axiom-devel mailing list
open-axiom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open-axiom-devel

Reply via email to