Re: Could that bug be catch using D's way?

2018-02-19 Thread Ali Çehreli via Digitalmars-d-learn
On 02/19/2018 05:33 AM, rikki cattermole wrote: https://dlang.org/phobos/std_experimental_checkedint.html#.Checked.min Accompanying presentations: DConf 2017: https://www.youtube.com/watch?v=29h6jGtZD-U Google Tel Aviv: https://www.youtube.com/watch?v=es6U7WAlKpQ Andrei likes the second

Re: Could that bug be catch using D's way?

2018-02-19 Thread Basile B. via Digitalmars-d-learn
On Monday, 19 February 2018 at 21:34:04 UTC, Simen Kjærås wrote: On Monday, 19 February 2018 at 14:20:16 UTC, Basile B. wrote: I had never used Checked and i discover that strangely there's no hook for opAssign. onLowerBound and onUpperBound works for +=, -=, *=, /=, %=, ^^=, &=, |=, ^=, <<=, >

Re: Could that bug be catch using D's way?

2018-02-19 Thread Simen Kjærås via Digitalmars-d-learn
On Monday, 19 February 2018 at 14:20:16 UTC, Basile B. wrote: I had never used Checked and i discover that strangely there's no hook for opAssign. onLowerBound and onUpperBound works for +=, -=, *=, /=, %=, ^^=, &=, |=, ^=, <<=, >>=, and >>>=. But since init is 0, += works: Ah, thanks. Filed

Re: Could that bug be catch using D's way?

2018-02-19 Thread Basile B. via Digitalmars-d-learn
On Monday, 19 February 2018 at 13:51:50 UTC, Simen Kjærås wrote: On Monday, 19 February 2018 at 13:33:34 UTC, rikki cattermole wrote: https://dlang.org/phobos/std_experimental_checkedint.html#.Checked.min Can't seem to get that to work, so I assumed it's not meant to be used that way: impor

Re: Could that bug be catch using D's way?

2018-02-19 Thread Simen Kjærås via Digitalmars-d-learn
On Monday, 19 February 2018 at 13:33:34 UTC, rikki cattermole wrote: https://dlang.org/phobos/std_experimental_checkedint.html#.Checked.min Can't seem to get that to work, so I assumed it's not meant to be used that way: import std.experimental.checkedint; struct MyHook { enum min(T) =

Re: Could that bug be catch using D's way?

2018-02-19 Thread rikki cattermole via Digitalmars-d-learn
On 19/02/2018 1:24 PM, Simen Kjærås wrote: On Monday, 19 February 2018 at 12:58:45 UTC, Marc wrote: I'm pretty sure something could be done with Ada's type range but what we could do using D? We can easily define a range type in D. The simple example below probably has awful performance and m

Re: Could that bug be catch using D's way?

2018-02-19 Thread Simen Kjærås via Digitalmars-d-learn
On Monday, 19 February 2018 at 12:58:45 UTC, Marc wrote: I'm pretty sure something could be done with Ada's type range but what we could do using D? We can easily define a range type in D. The simple example below probably has awful performance and many holes, but outlines the basic idea. It

Could that bug be catch using D's way?

2018-02-19 Thread Marc via Digitalmars-d-learn
I'm pretty sure something could be done with Ada's type range but what we could do using D?