ADL

Manu via Digitalmars-d digitalmars-d at puremagic.com
Sat Sep 3 08:51:29 PDT 2016


On 3 September 2016 at 21:16, Walter Bright via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> On 9/3/2016 3:51 AM, Timon Gehr wrote:
>>
>> By default, name lookup does not work in a way that would allow you to
>> actually
>> extend types using UFCS, and therefore none of Phobos works that way.
>
>
> Lambdas!

This is exactly the difference between std.algorithm, and what I was
trying to express as an algorithm that 'does work'. It's not the
business of the API for the user to supply the work to do (ie, via
lambda); the function is meant to do the work, which means it needs to
call other functions. There are no lambdas to be seen in this
situation.

> (Besides, I showed how other scopes can be imported based on a type, and
> then things can be looked up in those scopes, and UFCS applied.)

I still think that's unnecessarily complicated, and multiple arguments
leads to static if-ing and __traits(compiles,...). The fact the user
needs to intervene at all is already too much.
Apparently I need to stress again, this is a *core value proposition
of D*... It's presented as "this is modern D code", and yet it's
awkward and requires careful handling or you get hard to understand
name-resolution issues.
UFCS *is* modern D. Algorithms and ranges *is* modern D.
Seriously, this is the style that modern D aspires to, and it doesn't
'just work'. There should be ear-piercing alarms and flashing red
everywhere.
This comes up for me frequently, yet ADL has never caused me a single
moments trouble, in 15+ years. I didn't even know ADL existed until I
started running into this problem in D and then wondered to myself why
I never encountered the same issue in C++. It worked so seamlessly and
intuitively, I didn't even know it was there.

I don't care if the solution is ADL like C++, or something else that
works, just that this problem is real; it's a massive fly in the
ointment of modern D style, and I don't think it's acceptable. It
needs a seamless solution, not manual intervention at every case. D
depends on this so much more than C++ does.


More information about the Digitalmars-d mailing list