[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [Axiom-developer] Convert and Coerce
From: |
Page, Bill |
Subject: |
RE: [Axiom-developer] Convert and Coerce |
Date: |
Mon, 27 Mar 2006 18:55:36 -0500 |
On Monday, March 27, 2006 6:36 PM Antoine Hersen wrote
> Just to be sure
>
> So coercion are done automatically both in a library code
> and in the interpreter.
No. coercion is not done automatically in the library code.
**Only** in the interpreter.
> But conversion need to be forced with "::" both in library
> code and interpreter ?
Yes. Coercion also needs to be forced in the library code,
i.e. in the library code (e.g. SPAD or Aldor) coercion is
treated the same way as conversion.
>
> So convert imply a lost of information and has to be called
> explicitely by :: ?
>
I do not think that in general conversion implies any loss of
information. (I am not sure how to define "loss of information".)
But conversion is often a partial function i.e. only defined for
some members of the domain. For example:
2.0::Integer
If we only know
x:Float
it is not "safe" to write:
x::Integer
since
2.1::Integer
will fail. Such conversions will not be done automatically.
On the other hand if we know
y:Integer
then
y::Float
is always safe and so it is coded as a coercion and done
automatically by the interpreter when needed.
Regards,
Bill Page.