On Tue, Apr 23, 2013 at 1:43 PM, Graydon Hoare <[email protected]> wrote:
> On 22/04/2013 9:57 PM, Robert O'Callahan wrote:
>>
>> On Tue, Apr 23, 2013 at 4:18 AM, Graydon Hoare <[email protected]
>> <mailto:[email protected]>> wrote:
>>
>>     We've also had some requests for a mechanism to enable overflow
>>     checking on _all_ integer types within a given static or dynamic
>>     program extent, using attributes.
>>
>>
>> I, at least, made a request for overflow checking on all integer types,
>> full stop :-). And I still want it; failure of obvious properties like
>> "a >= 0 ===> a + b >= b" is just crazy, and I'm tired of living in
>> crazy-land.
>
>
> How much of a performance penalty is it worth? I believe you can trap this
> in C presently with a gcc flag too (-ftrapv); but it's a flag rarely turned
> on.
>
> (I generally concur and wanted rust integers to overflow to bignums
> originally! But I have had to retreat from such stances due to complaints
> about performance / not-C-ness. I suspect the attribute mechanism is the
> right approach for such pragmas; would it be acceptable to put one attribute
> in each of your crates?)
>
> -Graydon

I don't really think you need an attribute, just good support for an
integer type in the library that traps the overflow and expands to a
big integer.

At the very least, the overhead would involve making integers 2 words
instead of 1 for a tag, adding a branch to every operation and also
adding a branch after almost every fixnum representation.
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to