Ralf Hemmecke <r...@hemmecke.de> writes:

[...]

| Whatever the code says, it is not what I think how it should work. I
| rather trust the intentions of the original developers and they say in
| the Axiom Book
>
| http://axiom-wiki.newsynthesis.org/uploads/chapter-2.xhtml#sec-2.7
>
|   A coercion is a special kind of conversion that Axiom is allowed
|   to do automatically when you enter an expression.  Coercions are
|   usually somewhat safer than more general conversions.  The Axiom
|   library contains operations called  coerce and  convert.
|   Only the  coerce operations can be used by the interpreter to
|   change an object into an object of another type unless you explicitly
|   use a ::.
>
| For me that means, that only "coerce" functions are allowed to be
| inserted automagically. Never "convert". I am not so sure about
| "retract" or rather "retractIfCan". The latter are probably necessary to
| go back to the most specific domain that an object lives in.
>
| When I started with Axiom, I got confused by the mere existance of
| convert and coerce. They actually seem to be there for the same purpose.
| But no, the difference is that the interpreter can use coerce but not
| convert. If this distinction is blurred then it makes no sense to have
| two different names.

A reasonably good mental model of 'coerce' is that it injects a value of
one domain into another domain, e.g. you can inject the integer value
1 into the ring of polynomial with integer coefficients without much of
computational information loss.

On the other hand, there are situations where we want a different
representation of a value, but we are willing to accept for a little bit
of occasional information loss: that is where 'convert' is most
appropriate.  The string representation (in base 10) of a DoubleFloat
is not an injection as is well known.

>
| So I am rather in favour of keeping that difference and working towards
| a clear distinction.
>
| As you see above there is a ::. While I worked with Axiom, I never
| really thought about its explicit meaning. In Aldor the meaning is
| clearly defined. a::X is syntactic sugar for coerce(a)@X. No retract, no
| convert. But that is Aldor. In Axiom, it seems that :: can mean what
| coerceOrConvertOrRetract says. Can you confirm that your above cited
| function is the explicit translation of ::?

The Axiom interpreter actually does make the distinction.
Apparently, some people don't want that distinction so they have a flag
that you can set to tell the interpreter to use 'convert' when it should
be using only 'coerce'.


| If it is part of the process of inserting coercions to make the types
| match, then I'd argue that this should be fixed in favour of a clear
| distinction between coerce and convert.
>
| I know that we somewhat disagree on the "automatic insertion of
| coercions in the compiler", but what I just said, all applied to the
| interpreter. The compiler should in my opinion never silently insert a
| coercion.

The compiler is a different story from the interpreter.

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
open-axiom-devel mailing list
open-axiom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open-axiom-devel

Reply via email to