Re: The design of the hooks in std.experimental.checkedint

2017-06-05 Thread via Digitalmars-d
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

Re: The design of the hooks in std.experimental.checkedint

2017-06-05 Thread via Digitalmars-d
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

Re: The design of the hooks in std.experimental.checkedint

2017-06-05 Thread Jacob Carlborg via Digitalmars-d
On 2017-06-04 21:52, Andrei Alexandrescu wrote: What would be the advantage of moving the default into a hook? The whole idea was to reduce the number of "static if" in the implementation. Hook function is defined: "I want to hook this entire operation." Hook function is not defined: "I

Re: The design of the hooks in std.experimental.checkedint

2017-06-04 Thread Andrei Alexandrescu via Digitalmars-d
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?

Re: The design of the hooks in std.experimental.checkedint

2017-06-04 Thread Jacob Carlborg via Digitalmars-d
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

Re: The design of the hooks in std.experimental.checkedint

2017-06-03 Thread Andrei Alexandrescu via Digitalmars-d
On 06/03/2017 11:59 AM, Jacob Carlborg wrote: I've been looking a bit at the design of the hooks in std.experimental.checkedint. Due to all hooks being optional there's quite a few "static if" in the implementation of checkedint to check if a hook is implemented. Wouldn't it

The design of the hooks in std.experimental.checkedint

2017-06-03 Thread Jacob Carlborg via Digitalmars-d
I've been looking a bit at the design of the hooks in std.experimental.checkedint. Due to all hooks being optional there's quite a few "static if" in the implementation of checkedint to check if a hook is implemented. Wouldn't it be simpler if all hooks were required and