ADL

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Sat Sep 3 13:58:21 PDT 2016


On 9/3/2016 8:51 AM, Manu via Digitalmars-d wrote:
> 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.

This is purely a stylistic issue. I, on the other hand, think lambdas are a 
superior design, as ADL lookups never sat well with me because it can be quite 
difficult for the user to figure out where 'func' is coming from.


>> (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.

I already showed how your previous objection to this could be folded away inside 
a nice template.


> 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.

As mentioned, I don't see anything hard to understand about it - it makes it 
clear to the reader where names are coming from. ADL pulls names in from who 
knows where.


> 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.

You've used ADL for 15 years. You're obviously very comfortable with it. I 
suggest trying out using lambdas enough to feel comfortable with it before 
deciding that ADL is better. New coding styles are rarely comfortable right off 
the bat.



More information about the Digitalmars-d mailing list