std library hooks

Sean Kelly sean at invisibleduck.org
Sun Apr 15 17:27:08 PDT 2012


On Apr 15, 2012, at 4:32 PM, Walter Bright <newshound2 at digitalmars.com> wrote:

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

If you're overriding the one in the library then it has to be documented to have that name. It also has to live in its own section or you can have link errors. By comparison, hooks for commonly overridden things seems a bit easier. 


More information about the Digitalmars-d mailing list