ADL
Andrei Alexandrescu via Digitalmars-d
digitalmars-d at puremagic.com
Sat Sep 3 14:38:36 PDT 2016
On 9/3/16 11:31 AM, Manu via Digitalmars-d wrote:
>> > In any case, these difficulties are the consequence of trying to write C++
>> > code in D.
> You've told me this before, and I find it kind of offensive every time
> you do, since I've been programming D for like 7 years now, and I
> definitely don't code D like C++.
> If anything, I have a strong tendency to code C++ like D, and that has
> lead to a lot of interesting changes in my C++ style.
>
> I'm tired of these sorts of dismissals. You insist that I'm not a
> 'real' D programmer, or something to that effect.
There's really no need to take offense here. We have a bit of a mimosa
culture of easily bruised egos it seems. As the joke goes: "You take
offense too easily." "I can't believe you just said that!"
It's hard to not see your view as coming straight from the "I want to
speak Italian by replacing English words with Italian words" box.
* It hypothesizes that one entire style of design is completely
impossible because it lacks one obscure feature from C++.
* Vast evidence to the contrary is ignored.
* The fact that the feature is problematic and controversial even within
C++ circles is also neglected.
* The lack of said feature is regarded as an utter disaster and no
workaround is even close to cutting the mustard.
* A language change is a must; no library solution would ever be acceptable.
For the most part this is a Pop a level up and figure what the needed
accomplishment is, so other routes than the ADL bottleneck are possible.
Let's approach this together like a problem that has a solution within
D, and let's make that solution accessible comfortably.
Two apocryphal anecdotes: Koenig invented the eponymous lookup as a
consequence to the fact that namespaces broke the "Hello, world" program
(something to do with cout and endl being migrated to namespace std),
which surprised the inner circles of C++ the way putting mentos in coke
surprises the unwary. Namespaces are an unusually poorly designed
feature of C++, not second even to exceptions. By that time significant
work had been invested in defining and implementing namespaces, so going
back wasn't quite an option. ADL was hailed as a horrible hack but a
lifesaving one. Compilers have been slow to implement ADL, partly
because essentially it meant breaking a lookup algorithm that was
relatively orderly and DWIM, and replace it with a patchwork of special
cases. The community has since learned to live with the odd idioms that
make code work with the new rules.
Second anecdote: Scott Meyers had an infamous talk on C++ in which the
leitmotif was "What does f(x) mean?" Scott asks the question in the
beginning to which the obvious response is "Call function f passing it
argument x". By the time his talk is done, the horrified audience
realizes they have no idea what f(x) means and where it goes.
Andrei
More information about the Digitalmars-d
mailing list