| Thread overview | ||||||||
|---|---|---|---|---|---|---|---|---|
|
July 06, 2008 Integer overflows | ||||
|---|---|---|---|---|
| ||||
A short article from July 01, 2008, shows that some people are re-inventing the integer overflows compiler check that Pascal/Delphi programmers have enjoyed for lot of years: http://www.ddj.com/hpc-high-performance-computing/208801981 This time I am happy that history is repeating itself. Bye, bearophile | ||||
July 06, 2008 Re: Integer overflows | ||||
|---|---|---|---|---|
| ||||
Posted in reply to bearophile | bearophile Wrote:
> A short article from July 01, 2008, shows that some people are re-inventing the integer overflows compiler check that Pascal/Delphi programmers have enjoyed for lot of years:
>
> http://www.ddj.com/hpc-high-performance-computing/208801981
>
> This time I am happy that history is repeating itself.
me 2 but the article is just a rant. we should demand this from languages and computers. well yeah i demand a cow with diet coke too.
i was always unclear on somethin'. should the check be in the operation or the type of the operand? i mean maybe i have some data and only sometimes i want to make sure there's no overflow. so i'm sayin'
int a, b, c;
a = b _+_ c;
or something. that _+_ is checked and shit. or should i be like
Safe!(int) a, b, c;
a = b + c;
arguments could go both ways i guess. the advantage of the albeit uglier first solution is that it is more likely to be used. somehow safe types keep on comin' in languages but people don't use'em if thery're not the default. positive bias i suppose. (ppl underestimate the likelihood of bad shit happening to'em and overestimate their capacity to avoid bad shit when it is imminent.)
| |||
July 06, 2008 Re: Integer overflows | ||||
|---|---|---|---|---|
| ||||
Posted in reply to superdan | "superdan" <super@dan.org> wrote in message news:g4r88k$qjj$1@digitalmars.com... > bearophile Wrote: > >> A short article from July 01, 2008, shows that some people are re-inventing the integer overflows compiler check that Pascal/Delphi programmers have enjoyed for lot of years: >> >> http://www.ddj.com/hpc-high-performance-computing/208801981 >> >> This time I am happy that history is repeating itself. > > me 2 but the article is just a rant. we should demand this from languages and computers. well yeah i demand a cow with diet coke too. > > i was always unclear on somethin'. should the check be in the operation or the type of the operand? i mean maybe i have some data and only sometimes i want to make sure there's no overflow. so i'm sayin' > > int a, b, c; > a = b _+_ c; > > or something. that _+_ is checked and shit. or should i be like > > Safe!(int) a, b, c; > a = b + c; > > arguments could go both ways i guess. the advantage of the albeit uglier first solution is that it is more likely to be used. somehow safe types keep on comin' in languages but people don't use'em if thery're not the default. positive bias i suppose. (ppl underestimate the likelihood of bad shit happening to'em and overestimate their capacity to avoid bad shit when it is imminent.) C# has a nice solution that involves (I think this is what they're named:) "checked" and "unchecked" keywords. (Heh heh, yes, here I go praising something in C# again. I really do like D better overall, honest! (Of course, D is helped by the fact that C#'s templates are effectively gimped - just look up the whole "no IArithmetic" bizzareness. Anyway...)) The way it works is this: In the compiler settings, you can choose a default, either artithmetic is checked for overflows by default or not checked by default. Then, in the code, you can override the compiler setting by doing something like this: checked { // Code here } unchecked { // Code here } a = checked(b + c); a = unchecked(b + c); | |||
July 06, 2008 Re: Integer overflows | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Nick Sabalausky | Nick Sabalausky Wrote:
> "superdan" <super@dan.org> wrote in message news:g4r88k$qjj$1@digitalmars.com...
> > bearophile Wrote:
> >
> >> A short article from July 01, 2008, shows that some people are re-inventing the integer overflows compiler check that Pascal/Delphi programmers have enjoyed for lot of years:
> >>
> >> http://www.ddj.com/hpc-high-performance-computing/208801981
> >>
> >> This time I am happy that history is repeating itself.
> >
> > me 2 but the article is just a rant. we should demand this from languages and computers. well yeah i demand a cow with diet coke too.
> >
> > i was always unclear on somethin'. should the check be in the operation or the type of the operand? i mean maybe i have some data and only sometimes i want to make sure there's no overflow. so i'm sayin'
> >
> > int a, b, c;
> > a = b _+_ c;
> >
> > or something. that _+_ is checked and shit. or should i be like
> >
> > Safe!(int) a, b, c;
> > a = b + c;
> >
> > arguments could go both ways i guess. the advantage of the albeit uglier first solution is that it is more likely to be used. somehow safe types keep on comin' in languages but people don't use'em if thery're not the default. positive bias i suppose. (ppl underestimate the likelihood of bad shit happening to'em and overestimate their capacity to avoid bad shit when it is imminent.)
>
> C# has a nice solution that involves (I think this is what they're named:) "checked" and "unchecked" keywords. (Heh heh, yes, here I go praising something in C# again. I really do like D better overall, honest! (Of course, D is helped by the fact that C#'s templates are effectively gimped - just look up the whole "no IArithmetic" bizzareness. Anyway...))
>
> The way it works is this:
> In the compiler settings, you can choose a default, either artithmetic is
> checked for overflows by default or not checked by default. Then, in the
> code, you can override the compiler setting by doing something like this:
>
> checked
> {
> // Code here
> }
>
> unchecked
> {
> // Code here
> }
>
> a = checked(b + c);
> a = unchecked(b + c);
>
>
does that checked stuff see through function calls?
| |||
July 07, 2008 Re: Integer overflows | ||||
|---|---|---|---|---|
| ||||
Posted in reply to superdan | "superdan" <super@dan.org> wrote in message news:g4rg1u$1en7$1@digitalmars.com... > Nick Sabalausky Wrote: > >> "superdan" <super@dan.org> wrote in message news:g4r88k$qjj$1@digitalmars.com... >> > bearophile Wrote: >> > >> >> A short article from July 01, 2008, shows that some people are re-inventing the integer overflows compiler check that Pascal/Delphi programmers have enjoyed for lot of years: >> >> >> >> http://www.ddj.com/hpc-high-performance-computing/208801981 >> >> >> >> This time I am happy that history is repeating itself. >> > >> > me 2 but the article is just a rant. we should demand this from >> > languages >> > and computers. well yeah i demand a cow with diet coke too. >> > >> > i was always unclear on somethin'. should the check be in the operation >> > or >> > the type of the operand? i mean maybe i have some data and only >> > sometimes >> > i want to make sure there's no overflow. so i'm sayin' >> > >> > int a, b, c; >> > a = b _+_ c; >> > >> > or something. that _+_ is checked and shit. or should i be like >> > >> > Safe!(int) a, b, c; >> > a = b + c; >> > >> > arguments could go both ways i guess. the advantage of the albeit >> > uglier >> > first solution is that it is more likely to be used. somehow safe types >> > keep on comin' in languages but people don't use'em if thery're not the >> > default. positive bias i suppose. (ppl underestimate the likelihood of >> > bad >> > shit happening to'em and overestimate their capacity to avoid bad shit >> > when it is imminent.) >> >> C# has a nice solution that involves (I think this is what they're >> named:) >> "checked" and "unchecked" keywords. (Heh heh, yes, here I go praising >> something in C# again. I really do like D better overall, honest! (Of >> course, D is helped by the fact that C#'s templates are effectively >> gimped - >> just look up the whole "no IArithmetic" bizzareness. Anyway...)) >> >> The way it works is this: >> In the compiler settings, you can choose a default, either artithmetic is >> checked for overflows by default or not checked by default. Then, in the >> code, you can override the compiler setting by doing something like this: >> >> checked >> { >> // Code here >> } >> >> unchecked >> { >> // Code here >> } >> >> a = checked(b + c); >> a = unchecked(b + c); >> >> > > does that checked stuff see through function calls? I would assume so, but I'd really have to look it up or do a test to be sure. | |||
July 08, 2008 Re: Integer overflows | ||||
|---|---|---|---|---|
| ||||
Posted in reply to superdan | superdan wrote: > bearophile Wrote: > >> A short article from July 01, 2008, shows that some people are re-inventing the integer overflows compiler check that Pascal/Delphi programmers have enjoyed for lot of years: >> >> http://www.ddj.com/hpc-high-performance-computing/208801981 >> >> This time I am happy that history is repeating itself. > > me 2 but the article is just a rant. we should demand this from languages and computers. well yeah i demand a cow with diet coke too. > > i was always unclear on somethin'. should the check be in the operation or the type of the operand? i mean maybe i have some data and only sometimes i want to make sure there's no overflow. so i'm sayin' > > int a, b, c; > a = b _+_ c; > > or something. that _+_ is checked and shit. or should i be like > > Safe!(int) a, b, c; > a = b + c; This reminds me of ADA. It had this range and subrange types which you could specify any range for a number and the runtime would validate it for you. They could also be passed in as ranges for arrays which was kinda neat. > > arguments could go both ways i guess. the advantage of the albeit uglier first solution is that it is more likely to be used. somehow safe types keep on comin' in languages but people don't use'em if thery're not the default. positive bias i suppose. (ppl underestimate the likelihood of bad shit happening to'em and overestimate their capacity to avoid bad shit when it is imminent.) | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply