[Aldor-l] Aldor type system

Bill Page bill.page at newsynthesis.org
Thu Sep 10 14:47:25 EDT 2009


Pippijn,

I think answers to all your questions are here:

http://www.aldor.org/docs/HTML/index.html

In particular for "Type conversion" see

http://www.aldor.org/docs/HTML/chap7.html#6

Quote:

Courtesy conversions

While most type conversions must be made explicitly, a very
conservative set of courtesy conversions are performed as needed.
Courtesy conversions change between items represented as

    * multiple values,
    * a single Cross product value (see section 13.4) and
    * a single Tuple value (see section 13.3).

Certain Aldor programs would be extremely pedantic if courtesy
conversions were not applied.

The following courtesy conversions are applied automatically as required:

    * Cross(T, ..., T) -> Tuple T
    * Cross(T1, ..., TN) -> (T1, ..., TN)
    * Cross(T) -> T
    * (T, ..., T) -> Tuple T
    * (T1, ..., TN) -> Cross(T1, ..., TN)
    * T -> Tuple T
    * T -> Cross T

These conversions allow functions which take or return multiple values
to be used to pass arguments to other functions which can accept them,
without requiring notation for an explicit conversion.

These conversions are applied only when the type of an expression
exactly matches one of the conversions. For example, a value of type
List Cross(T, T, T) would not automatically be converted to a value of
type List Tuple T. Such a conversion could incur a significant hidden
cost, even in more ordinary circumstances.

end quote

For the second question see: "Subtypes"

http://www.aldor.org/docs/HTML/chap7.html#5

If you have already read this and still have questions, I would be
glad to give my interpretation.

Regards,
Bill Page.

2009/9/10 Pippijn van Steenhoven wrote:
> Hi,
>
> I have a few questions about the aldor type system but I can only
> remember two of them at the moment:
>
> 1. Are there any implicit conversions and if so, how do they affect type
>   inferencing? Implicit conversions make type inferencing undecidable
>   and overloading ambiguous, so I hope not.
> 2. How does subtyping or type classification work? In ML, you can have a
>   type called Bool and have two constructors TRUE and FALSE. You can
>   then later use pattern matching to find out which of those two
>   constructors was used to construct that Bool. In C++, one would do
>   that with inheritance and dynamic_cast (or visitor). Same goes for
>   Java. In C, it's all ugly with unions and markers and completely
>   throwing away type safety. The best in my opinion is the ML way, but I
>   understand that aldor doesn't have that, so what does it have?
>
> --
> Pippijn van Steenhoven
>




More information about the Aldor-l mailing list