Resctricted Genericity for classes that convert to ?

2 views
Skip to first unread message

Alejandro Garcia

unread,
Dec 3, 2025, 8:32:19 PM (6 hours ago) Dec 3
to Eiffel Users
How can I express that


I have a 
deferred class INTERMEDIARY[R,S]

R is for representation ans S is for storage.

How ever for the intermediary to be valid Représentations must be convertible to Storage.

So the way to express it is:

class INTERMEDIARY_STRICT[ R -> CONVERTIBLE_WITH[S], S]

So that R must inherit from a class where the conversion is specified.
And that works for the conversion.

BUT if R is not a independent class but actually a heir of S it doesn't satisfy the restriction.. so I need a third form of intermediary:


class INTEMEDIARY_HEIR[R->{S}, S]

To express that Représentations can be heirs of storages.

So but this hierarchy of INTERMEDIARIEs seem a lot to me.

How have you expressed the idea that Representations (json, xml) must be convertible to a class (addresses, car, people) or must be a heir to a class (string) ??





----

Alejandro García F. (elviejo)

EOM – End Of Message. The whole message is in the subject don't need to open it.
NNTR – No Need To Respond. Help cut down on all those “cool” and “thanks” emails.
SINGLE SUBJECT. Send one email for one topic, this makes replies easy..
CLEAR CALL TO ACTION: Ask for some specific result very clearly.
Reply all
Reply to author
Forward
0 new messages