Jump to page: 1 29  
Page
Thread overview
std.experimental.checkedint is ready for comments!
Jun 07, 2016
tsbockman
Jun 09, 2016
Jack Stouffer
Jun 14, 2016
Andrea Fontana
Jun 14, 2016
Andrea Fontana
Jun 14, 2016
tsbockman
Jun 14, 2016
Nordlöw
Jun 14, 2016
Nordlöw
Jun 14, 2016
tsbockman
Jun 14, 2016
Nordlöw
Jun 14, 2016
Walter Bright
Jun 14, 2016
Walter Bright
Jun 15, 2016
Walter Bright
Jun 15, 2016
tsbockman
Jun 15, 2016
Walter Bright
Jun 15, 2016
tsbockman
Jun 15, 2016
tsbockman
Jun 15, 2016
Walter Bright
Jun 15, 2016
Walter Bright
Jun 15, 2016
tsbockman
Jun 15, 2016
Jacob Carlborg
Jun 15, 2016
tsbockman
Jun 15, 2016
Walter Bright
Jun 15, 2016
tsbockman
Jun 15, 2016
Walter Bright
Jun 15, 2016
tsbockman
Jun 15, 2016
tsbockman
Jun 15, 2016
Walter Bright
Jun 15, 2016
tsbockman
Jun 15, 2016
tsbockman
Jun 15, 2016
Walter Bright
Jun 15, 2016
Walter Bright
Jun 15, 2016
tsbockman
Jun 15, 2016
tsbockman
Jun 16, 2016
tsbockman
Jun 15, 2016
tsbockman
Jun 15, 2016
tsbockman
Jun 16, 2016
tsbockman
Jun 16, 2016
tsbockman
Jun 16, 2016
lobo
Jun 16, 2016
tsbockman
Jun 16, 2016
John Colvin
Jun 16, 2016
tsbockman
Jun 16, 2016
tsbockman
Jun 16, 2016
tsbockman
Jun 16, 2016
Walter Bright
Jun 16, 2016
Jack Stouffer
Jun 16, 2016
Walter Bright
Jun 16, 2016
tsbockman
Jun 16, 2016
Walter Bright
Jun 16, 2016
tsbockman
Jun 17, 2016
deadalnix
Jun 17, 2016
Jacob Carlborg
Jun 17, 2016
Walter Bright
Jun 17, 2016
tsbockman
Jun 17, 2016
jmh530
Jun 17, 2016
Walter Bright
Jun 17, 2016
Walter Bright
Jun 18, 2016
Walter Bright
Jun 18, 2016
Jacob Carlborg
Jun 18, 2016
Walter Bright
Jun 18, 2016
Walter Bright
Jun 18, 2016
tsbockman
Jun 18, 2016
Walter Bright
Jun 18, 2016
tsbockman
Jun 17, 2016
tsbockman
Jun 18, 2016
Walter Bright
Jun 18, 2016
tsbockman
Jun 18, 2016
Walter Bright
Jun 15, 2016
Timon Gehr
Jun 15, 2016
tsbockman
Jun 16, 2016
tsbockman
Jun 16, 2016
tsbockman
June 07, 2016
As with many other languages (C, C++, Java, etc.), D's built-in integer data types are quite difficult to use correctly.

It is tempting to think of int, for example, as if it were an actual mathematical integer. Doing so, however leads to buggy code due to unintuitive behaviour like:

* Wrapped overflow
* Reinterpretation of signed values as unsigned in mixed expressions
* Floating Point Exceptions which aren't Exceptions and have nothing to do with
  floating point
* Formally "undefined behaviour" with some inputs for various operations

This checkedint module provides alternative operations and types (SafeInt,SmartInt) that protect the user from most difficulties of this sort, while maintaining good performance (provided that inlining and optimizations are enabled).

== SmartInt ==
SmartInt smartOp strive to actually give the mathematically correct answer whenever possible, rather than just signaling an error.

== SafeInt ==
SafeInt safeOp strive to match the behaviour of the basic integral types exactly, $(B except) that where the behaviour of the basic type is wrong, or very unintuitive, an error is signaled instead.


The main downsides to using checkedint are:

Some added friction when interfacing to non-checkedint-aware code.
Slower compilation and larger binaries.


PR: https://github.com/dlang/phobos/pull/4407
DUB: http://code.dlang.org/packages/checkedint

I will do the review management.
June 07, 2016
On Tuesday, 7 June 2016 at 08:50:07 UTC, Robert burner Schadek wrote:
> I will do the review management.

Thanks.
June 09, 2016
On Tuesday, 7 June 2016 at 08:50:07 UTC, Robert burner Schadek wrote:
> ...

I left my commentary in the PR. Overall it looks pretty good design wise, and I would totally vote for it's inclusion in Phobos.
June 14, 2016
In two weeks I will talk to tsbockmann how much time he needs to work in all comments.
After he is done I will start the formal review phase.

p.s.
@everybody please take an interest. This module can give D another strategic advantage over our competition.

June 14, 2016
On Tuesday, 14 June 2016 at 10:20:58 UTC, Robert burner Schadek wrote:
> In two weeks I will talk to tsbockmann how much time he needs to work in all comments.
> After he is done I will start the formal review phase.
>
> p.s.
> @everybody please take an interest. This module can give D another strategic advantage over our competition.

Any documentation/example?
June 14, 2016
On Tuesday, 14 June 2016 at 10:33:34 UTC, Andrea Fontana wrote:
> On Tuesday, 14 June 2016 at 10:20:58 UTC, Robert burner Schadek wrote:
>> In two weeks I will talk to tsbockmann how much time he needs to work in all comments.
>> After he is done I will start the formal review phase.
>>
>> p.s.
>> @everybody please take an interest. This module can give D another strategic advantage over our competition.
>
> Any documentation/example?

Whoops I see it's in PR. You should link here too :)
June 14, 2016
On Tuesday, 7 June 2016 at 08:50:07 UTC, Robert burner Schadek wrote:
> PR: https://github.com/dlang/phobos/pull/4407

I also have

https://github.com/nordlow/phobos-next/blob/master/src/bound.d
providing Ada-style range type at
https://github.com/nordlow/phobos-next/blob/master/src/bound.d#L286

and

https://github.com/nordlow/phobos-next/blob/master/src/modulo.d
providing Ada-style module type at
https://github.com/nordlow/phobos-next/blob/master/src/modulo.d#L46

I'm currently using `Mod` in an useful way here
https://github.com/nordlow/phobos-next/blob/master/src/typecons_ex.d#L227
unittested here
https://github.com/nordlow/phobos-next/blob/master/src/typecons_ex.d#L286

to automatically get bounded integers when searching for elements in static arrays. In turn, I'm using this in my radix tree implementation here

https://github.com/nordlow/phobos-next/blob/master/src/trie.d#L922

to provide more type-safe indexing of statically sized arryas.

I know, it's big, but it *is* motivated when accessing static arrays in specialized containers like radix trees.

Have you thought about extending checkedint to something similar to bounded integer wrapper type like my `bound.d`?

Not that my `Bound`-type probably should be used inplace of `Mod`, but I haven't had time to do the switch yet.
June 14, 2016
On Tuesday, 14 June 2016 at 10:39:01 UTC, Nordlöw wrote:
> providing Ada-style module type at

Should be:
providing Ada-style modulo type at
June 14, 2016
On Tuesday, 14 June 2016 at 10:34:49 UTC, Andrea Fontana wrote:
> On Tuesday, 14 June 2016 at 10:33:34 UTC, Andrea Fontana wrote:
>> Any documentation/example?
>
> Whoops I see it's in PR. You should link here too :)

I can't, because the link is not stable. The docs are rebuilt and given a new URL every time I update the PR.
June 14, 2016
On Tuesday, 14 June 2016 at 10:39:01 UTC, Nordlöw wrote:
> Have you thought about extending checkedint to something similar to bounded integer wrapper type like my `bound.d`?

I spent some time studying the possibility of a `BoundInt` type. Some conclusions I reached:

   1) Designing and implementing `BoundInt` to my standards for quality and
      performance would be a large project of similar magnitude to what has
      already been done on `checkedint`, which took me about a year. (And I
      was building on the earlier work of @burner and others.)

   2) `BoundInt` is not a replacement for `SafeInt` or `SmartInt`, although
      they would likely share some parts of the implementation.

   3) Adding `BoundInt` later should not require any breaking changes to the
      public API of `checkedint`.

   4) Pervasive, natural use of `BoundInt` in large systems (like Phobos)
      may cause *awful* template bloat issues, depending on the design used.
      (Improvements to the compiler front-end could mitigate this issue, in
      the long run.)

Given the above, I believe we should move forward with `checkedint` as-is. Someone can add a `BoundInt` type to it later, if there is demand.
« First   ‹ Prev
1 2 3 4 5 6 7 8 9