static opSlice is not possible

Jonathan M Davis newsgroup.d at jmdavisprog.com
Thu Feb 15 23:20:42 UTC 2018


On Thursday, February 15, 2018 22:49:56 Alex via Digitalmars-d-learn wrote:
> Hi all,
> a short question about an old bug:
> https://issues.dlang.org/show_bug.cgi?id=11877
>
> Are there reasons, which speaks against this feature?
>
> And maybe another one, more general:
> Is there any place, where it is documented, which operators can
> work in static mode and which cannot?

The only overloaded operator that I'd expect to work as static would be
opCall, which I expect works primarily because of functors but is useful for
factory functions as well.

But the point of having overloaded operators is to make it so that
user-defined types can act like built-in types. As such, it generally
doesn't make any sense for them to be static. As for opSlice, it _really_
doesn't make sense, because that would conflict with arrays and AliasSeqs.

I'm not aware of anywhere in the spec that talks about static and overloaded
operators, but I also haven't read through it recently. The spec does tend
to be a bit sparse on some details though.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list