The design of the hooks in std.experimental.checkedint

via Digitalmars-d digitalmars-d at puremagic.com
Mon Jun 5 09:09:30 PDT 2017


On Monday, 5 June 2017 at 16:04:18 UTC, Petar Kirov [ZombineDev] 
wrote:
> On Monday, 5 June 2017 at 10:29:26 UTC, Jacob Carlborg wrote:
>>> 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.
>>
>> Right.
>
> (As I'm sure you know) this can be solved by using UDAs. I.e. 
> the members of the mixin template can be tagged with e.g. 
> @default indicating to the shell that the there was interest in 
> overriding them. Of course static ifs will be needed again, but 
> if we assume that in the common case the shell doesn't need to 
> differentiate between user defined and default hooks, then this 
> can be a net win in terms of LoC needed for the shell.

...indicating to the shell that the there was *no* interest in 
overriding them.


More information about the Digitalmars-d mailing list