std library hooks
Nick Sabalausky
SeeWebsiteToContactMe at semitwist.com
Sun Apr 15 22:17:45 PDT 2012
"Walter Bright" <newshound2 at digitalmars.com> wrote in message
news:jmflrl$5ub$1 at digitalmars.com...
> On 4/15/2012 4:19 PM, Manu wrote:
>> On 16 April 2012 02:09, Walter Bright <newshound2 at digitalmars.com
>> <mailto:newshound2 at digitalmars.com>> wrote:
>>
>> On 4/15/2012 3:04 AM, Manu wrote:
>>
>> Wow. This all sounds... really unpredictable.
>>
>>
>> It isn't. People are way overthinking this.
>>
>>
>> Maybe, but I still think that anyone who doesn't have the equivalent of a
>> Ph.D
>> in compiler authoring probably won't understand this, and will become
>> frustrated
>> when things don't work as expected.
>
> Please, please stop thinking this is Ph.D complicated. It is not. Linkers
> are old old OLD technology going back to the 50's. They haven't improved
> much since then. They are ridiculously simple (compared with the
> complexity of modern languages) and simple-minded tools.
>
>> A nice API to register hooks just seems so much simpler, and more
>> conventional.
>> Most libraries I've worked with have such an API, I think it'd be pretty
>> intuitive to many users to follow the same pattern in druntime too.
>
> Hooks add bloat and complexity to the library, and I don't see how they
> are any easier to use than simply providing your own explicit function
> with the same name that automatically overrides one in the library by the
> mere fact that it exists.
>
It would be easy *IF* it worked that way. But it clearly *doesn't*. There's
a whole host of caveats that all stem from the specifics of the underlying
algorithm used by whatever particular linker you happen to be using.
"Here, I'll provide my own X."
Multiply defined symbol X.
"WTF? Walter said it should work!"
[Posts on the NG and waits for help]
"So 'Multiply defined symbol X' REALLY means 'If you provide X you also need
to provide Y and Z'?"
Yup.
"WTF! Ok fine, here's Y and Z..."
[Works fine. Few weeks later, you make an unrelated change in some other
section of code]
Multiply defined symbols X, Y and Z.
"God damnnit."
[Waste time hunting down the issue]
"Jesus, so that unreleated change added a call to phobos's 'foo', which in
turn calls druntime symbol W, which wasn't previously used by my app, but it
is now, and it's not provided by my X Y and Z stuff when all I wanted to do
was just replace X, so now I had to figure out that this totally nonlocal
change means I *also* have to provide a Q now, oh and nothing ever told me
so because apperently this is so super-simple that none of it needs to be
documented. So fine then, linker, here's your damn Q..."
[Works again until druntime/phobos is updated]
Multiply defined symbols Q, X, Y and Z.
"Fuck, what now? I didn't even change *one line* in my app!"
[Waste more time...Loose more hair...Enlarge the head-shaped dent in the
wall...]
"So...druntime changed: that particular object in druntime now *also* has a
new symbol F which some *other* function in druntime or phobos has been
changed to now use. Gah...fine, take the damn F..."
[Some poor sap tries to use a different linker and the whole damn thing
blows up]
"FFFUUUUUUUUUUUUUU!!!!!!" (Insert accompanying meme picture here)
You *seriously* expect to convince people that qualifies as "ridiculously
simple"? C includes make more sense than that. The linker implementation
might be simple, but the implications sure as hell aren't.
More information about the Digitalmars-d
mailing list