simple question about UFCS and templates...wasFound(i) works but not i.wasFound()
Paul Backus
snarwin at gmail.com
Thu Mar 20 03:26:04 UTC 2025
On Thursday, 20 March 2025 at 02:01:25 UTC, Jonathan M Davis
wrote:
> On Wednesday, March 19, 2025 5:48:37 PM MDT H. S. Teoh via
> Digitalmars-d-learn wrote:
>> I thought it was always a miss. :-D At least, it's never
>> worked for me every time I tried it. I always have to move
>> the UFCS function to module scope, then it works.
>
> AFAIK, it's always a miss. There's a bug report somewhere where
> Kenji explained exactly why it works the way that it does, but
> I don't recall what he said. I also don't know if it was closed
> as "won't fix" or remember much that would make it easy to
> find, unfortunately. :|
>
> But there is a technical reason for the limitation, even if I
> don't remember what it is.
It's to prevent UFCS functions from being shadowed by local
variables. From the spec:
> Rationale: Local function symbols are not considered by UFCS to
> avoid unexpected name conflicts.
https://dlang.org/spec/function.html#pseudo-member
More information about the Digitalmars-d-learn
mailing list