primitive value overflow
luka8088
luka8088 at owave.net
Wed May 29 16:23:58 PDT 2013
On 24.5.2013. 1:58, bearophile wrote:
> Peter Alexander:
>
>> What about code that relies on overflow? It's well-defined behaviour,
>> so it should be expected that people rely on it (I certainly do
>> sometimes)
>
> Do you rely on signed or unsigned overflow?
>
> My opinions on this topic have changed few times.
>
> A modern system language should offer the programmer both integral types
> for the rare situations where the overflow or wrap around are expected
> or acceptable, and other "default" integral types to be used in all the
> other situations, where overflow or wrap-around are unexpected and not
> desired. The implementation then should offer ways to optionally perform
> run-time tests on the second group of integrals.
>
> A very good system language should also offer various means to
> statically verify the bounds of a certain percentage of values and
> expression results, to reduce the amount of run-time tests needed (here
> things like "Liquid Types" help).
>
> D currently doesn't have such safe built-in types, and it doesn't offer
> means to create such efficient types in library code. I think such means
> should be provided:
> http://d.puremagic.com/issues/show_bug.cgi?id=9850
>
> Bye,
> bearophile
I agree completely!
Would it maybe be a good consensus to allow operator overloading and
invariants for primitive types?
Or is there a reason why that is a bad idea?
More information about the Digitalmars-d
mailing list