> I am not sure why you think that interpreter should not automaticaly
> use "convert".  In 'i-coerce.boot' we have:
> 
> coerceOrCroak(triple, t, mapName) ==
>   -- this does the coercion and returns the value or dies
>   t = $NoValueMode => triple
>   t' := coerceOrConvertOrRetract(triple,t)
>   t' => objValUnwrap(t')
>   mapName = 'noMapName =>
>     throwKeyedMsgCannotCoerceWithValue(objVal triple,objMode triple, t)
>   sayKeyedMsg("S2IC0005",[mapName])
>   throwKeyedMsgCannotCoerceWithValue(objVal triple,objMode triple, t)
> 
> as you see the main function is called 'coerceOrConvertOrRetract'
> and it tries to use "convert".

> "convert" is not used by Spad compiler, but interpreter is different
> here.

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.

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

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.

Ralf

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/fricas-devel?hl=en.

Reply via email to