operator overloading outside the type
Steven Schveighoffer
schveiguy at gmail.com
Wed Mar 26 16:59:47 UTC 2025
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
More information about the Digitalmars-d
mailing list