[m-rev.] for review: Parse and check subtype definitions.

Julien Fischer jfischer at opturion.com
Tue Feb 16 16:41:00 AEDT 2021


On Tue, 16 Feb 2021, Peter Wang wrote:

> On Tue, 16 Feb 2021 14:38:39 +1100 Julien Fischer <jfischer at opturion.com> wrote:
>>
>> Hi Peter,
>>
>> On Mon, 15 Feb 2021, Peter Wang wrote:
>>
>>> (Note that I changed the documentation a fair bit since I originally
>>> posted it.)
>>
>> A couple of questions:
>>
>> How are equality and comparison defined for subtypes?  In particular,
>> what happens if the supertype has user-defined equality or comparison?
>>
>> I guess the simplest thing would be to say that user-defined equality
>> and comparison do not carry over to the subtypes.  OTOH, since the
>> representations are the same you could implement unification and
>> comparison for subtypes by:
>>
>>      unify_subtype(X, Y) :-
>>          unify_supertype(coerce(X), coerce(Y)).
>>
>> and similarly for comparison.  (Also, it seems semantically weird for
>> subtype not to have the same equality and comparison operation as the
>> supertype.)
>>
>
> There is nothing special about subtypes in this respect.
> We could do something later if it's deemed necessary.

That's fine for now; du types with user-defined equality and comparison
are very rare anyway.

...

>>> doc/reference_manual.texi:
>>>    Add documentation for subtypes.
>>>
>>>    Add documentation for a proposed `coerce' operation, commented out
>>>    for now.
>>>
>>>    Add "=<" to the list of reserved type names.
>>
>> If you are intending to commit this to the trunk then all of the new
>> doucumentation should be commited out for now with the exception of of
>> "=<" being a reserved type name.
>
> Subtype definitions do work as described. What if I just write at the
> top of the section:
>
>    (This is a new and experimental feature, subject to change.)

That's fine.

I had a look through the code and couldn't see anything obviously amiss.
(You may want to wait a bit before committing in case anyone else has
any feedback.)

Julien.


More information about the reviews mailing list