Virtual opBinary in interface

Ali Çehreli acehreli at yahoo.com
Fri Dec 20 18:40:17 UTC 2024


On 12/19/24 10:49 AM, sfp wrote:
 > Subject lines says it all

Although you clearly have a need for, virtual operators haven't been 
common in my experience. I always felt they could cause semantic issues.

For example, the two subclasses of an interface may not have the binary 
relation that the interface prescribes. I can think of the Animal 
hierarchy where Cat and Dog may have a certain relationship that may not 
make sense between Alligator and Mouse. Forcing such a binary function 
at the Interface level may not be right.

Having said that, and to contradict myself, this discussion reminded me 
of a fun DConf presentation by our friend Jean-Louis Leroy that included 
examples of such virtual functionality where it made sense:

"Open Methods for D (The Expression Problem - solved)"

   https://www.youtube.com/watch?v=MpwHeE2Vvfw&t=395s

But it uses his magical implementation (enabled by D) of open methods 
(and multi-methods).

Ali



More information about the Digitalmars-d-learn mailing list