Re: Virtual opBinary in interface

2024-12-24 Thread Renato Athaydes via Digitalmars-d-learn
On Saturday, 21 December 2024 at 23:16:52 UTC, sfp wrote: On Saturday, 21 December 2024 at 07:02:07 UTC, Steven Schveighoffer wrote: I wrote a blog post on how to use a single mixin to forward all operators to the D1 style overloads. You might find it useful or inspiring. https://www.schveigu

Re: Virtual opBinary in interface

2024-12-21 Thread sfp via Digitalmars-d-learn
On Saturday, 21 December 2024 at 07:02:07 UTC, Steven Schveighoffer wrote: I wrote a blog post on how to use a single mixin to forward all operators to the D1 style overloads. You might find it useful or inspiring. https://www.schveiguy.com/blog/2022/06/how-to-keep-using-d1-operator-overloads/

Re: Virtual opBinary in interface

2024-12-21 Thread sfp via Digitalmars-d-learn
On Friday, 20 December 2024 at 18:40:17 UTC, Ali Çehreli wrote: 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. ... But it uses his magi

Re: Virtual opBinary in interface

2024-12-21 Thread Andy Valencia via Digitalmars-d-learn
On Saturday, 21 December 2024 at 07:02:07 UTC, Steven Schveighoffer wrote: I wrote a blog post on how to use a single mixin to forward all operators to the D1 style overloads. You might find it useful or inspiring. https://www.schveiguy.com/blog/2022/06/how-to-keep-using-d1-operator-overloads/

Re: Virtual opBinary in interface

2024-12-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On Thursday, 19 December 2024 at 18:49:28 UTC, sfp wrote: Subject lines says it all, I think... The choice to make binary operators implementable only via this `opBinary` template means it's unclear how to get virtual operators on an interface. I am very new to D, and my goal is to learn how

Re: Virtual opBinary in interface

2024-12-20 Thread Ali Çehreli via Digitalmars-d-learn
On 12/20/24 10:40 AM, Ali Çehreli wrote: > I always felt they could cause semantic issues. I remembered one such case. What should happen if both Cat and Dog defined the "+" operator? Should we expect 'cat + dog' behave the same as 'dog + cat'? Unfortunately, virtual functions are picked by t

Re: Virtual opBinary in interface

2024-12-20 Thread Ali Çehreli via Digitalmars-d-learn
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

Re: Virtual opBinary in interface

2024-12-19 Thread sfp via Digitalmars-d-learn
On Friday, 20 December 2024 at 01:29:32 UTC, user1234 wrote: On Thursday, 19 December 2024 at 18:49:28 UTC, sfp wrote: Subject lines says it all, I think... The choice to make binary operators implementable only via this `opBinary` template means it's unclear how to get virtual operators on an

Re: Virtual opBinary in interface

2024-12-19 Thread mzfhhhh via Digitalmars-d-learn
On Thursday, 19 December 2024 at 18:49:28 UTC, sfp wrote: Subject lines says it all, I think... The choice to make binary operators implementable only via this `opBinary` template means it's unclear how to get virtual operators on an interface. E.g., this toy example *does* compile: ``` interf

Re: Virtual opBinary in interface

2024-12-19 Thread user1234 via Digitalmars-d-learn
On Thursday, 19 December 2024 at 18:49:28 UTC, sfp wrote: Subject lines says it all, I think... The choice to make binary operators implementable only via this `opBinary` template means it's unclear how to get virtual operators on an interface. E.g., this toy example *does* compile: ``` interf

Re: Virtual opBinary in interface

2024-12-19 Thread monkyyy via Digitalmars-d-learn
On Thursday, 19 December 2024 at 18:49:28 UTC, sfp wrote: perhaps `.d` files need to be added on the command line, or use `-i` to compile imports always try -i in response to any linker error