The design of the hooks in std.experimental.checkedint

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Sun Jun 4 12:52:40 PDT 2017


On 06/04/2017 03:25 PM, Jacob Carlborg wrote:
> On 2017-06-03 23:45, Andrei Alexandrescu wrote:
> 
>> One question - current logic decides whether to call e.g. hookOpBinary
>> vs. perform the default operation followed by onOverflow. How would that
>> work if both hookOpBinary and onOverflow are defined?
> 
> I'm not sure I fully understand without a code example but I would say 
> that the default hook would implement hookOpBinary to perform the 
> default operation and then call onOverflow.

What would be the advantage of moving the default into a hook?

>> I'm unclear whether this is a step in the right direction. Why have user
>> code work more to provide less information to the framework?
> 
> I don't see how it would provide less information to the framework.

Hook function is defined: "I want to hook this entire operation."

Hook function is not defined: "I am not interested in hooking this 
operation."

If hook is always defined, the shell cannot identify what a particular 
hook has an interest in.


Andrei



More information about the Digitalmars-d mailing list