operator overloading outside the type

sfp sfp at hush.ai
Fri Mar 28 00:31:59 UTC 2025


On Wednesday, 26 March 2025 at 16:59:47 UTC, Steven Schveighoffer 
wrote:
> I think we should enable this. It was identified pretty 
> recently in a stream of an influencer (see other messages in 
> this group), as something that is desirable.
>
> Especially with importC, where C does not support operator 
> overloading, it should just work. Indeed, in my [raylib 
> binding](https://github.com/schveiguy/raylib-d/blob/1cc76b8be3da3c1a34c54528678a62ce237c969e/source/raylib/raylib_types.d#L7), we purposely implement our own copies of all the basic POD types because we want to add operator overloads. This becomes MUCH simpler if we could just use UFCS operators.
>
> A long time ago, member functions were member functions only, 
> and UFCS did not exist (except for arrays). Now that UFCS does 
> exist, and operator overloads are a straightforward template 
> rewrite, the position of only allowing operator overloads to be 
> members is less defendable.
>
> I also agree with the streamer that .h files should just work.
>
> -Steve

I would REALLY, REALLY like this feature to be implemented.

I said my bit about it over in the other thread about the stream 
since I didn't notice this thread:

https://forum.dlang.org/post/azieoqhwwgployarvazx@forum.dlang.org

I also read through this old thread:

https://forum.dlang.org/thread/mntbbmllhxgdmwynffpz@forum.dlang.org?page=1

and as far as I can tell there is no *real* technical impediment 
to adding this feature.


More information about the Digitalmars-d mailing list