Page 1 of 1

Interface synonyms

Posted: 18 Dec 2017 0:23
by Martin Meyer
Hello Thomas,

just a small suggestion regarding interface synonyms, maybe this could be made working in some future version:

Code: Select all

interface obj{@Type}   domains     myType =         myType_a(@Type);         myType_b.   end interface obj   implement main   domains     obj_unsigned = obj{unsigned}.   clauses     run() :-         Val = obj_unsigned::myType_a(1), %throws error c218 : Unknown class/interface 'obj_unsigned'         stdIO::write(Val).   end implement main

Re: Interface synonyms

Posted: 18 Dec 2017 9:20
by Thomas Linder Puls
You can just write:

Code: Select all

implement main   clauses     run() :-         Val = obj::myType_a(1),         stdIO::write(Val).   end implement main

Re: Interface synonyms

Posted: 18 Dec 2017 14:38
by Martin Meyer
True, that makes the example's code even shorter. In large use cases however things can be the other way around. I.e. when declarations made in an interface obj{@TypeA, @TypeB, ...} are refered to many times in the code and in each place type parameters are substituted by same lengthy type expressions.

Merry Christmas to you and all

Re: Interface synonyms

Posted: 19 Dec 2017 10:21
by Thomas Linder Puls
An interface defines an object type, and as such it defines the predicates and properties that such objects have.

For convenience an interface is however also a scope that can declare constants and domains, but these constants and domains belongs to the scope not to the interface type (and they are not accessible through the objects).

So an interface definition is a single textural construction that defines two things, an object type and a static/global scope.

We have no intensions about extending object types to carry more than the predicates and properties of the corresponding objects.

Likewise we have no intensions about extending an synonym type to do more than defining a synonym of a type.

So the definition

Code: Select all

domains     obj_unsigned = obj{unsigned}.
Defines a synonym of the type, but it is not the type that contains the myType domain, so you cannot write:

Code: Select all

obj_unsigned::myType
But you can define this synonym type (i.e. because is it a type):

Code: Select all

domains     myType_unsigned = obj{unsigned}::myType.
You may also be able to handle things by opening obj{unsigned}.

Re: Interface synonyms

Posted: 19 Dec 2017 15:09
by Martin Meyer
Thank you for the detailed explanation. Now I see the concept behind scenes.

I suppose the issue is connected to Supports Qualification for Domains. Similarly a supports qualification extends the type of an interface but not its scope.

Re: Interface synonyms

Posted: 19 Dec 2017 17:17
by Thomas Linder Puls
Martin Meyer wrote: 19 Dec 2017 15:09Similarly a supports qualification extends the type of an interface but not its scope.
Exactly.