Thread overview | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
July 08, 2011 Re: This seems like what could be a common cause of bugs | ||||
---|---|---|---|---|
| ||||
On 7/9/11, Andrej Mitrovic <andrej.mitrovich@gmail.com> wrote:
> double step = 1 / width; // or .1
Woops that should have been `1.`. See, another bug right there!
|
July 08, 2011 Re: This seems like what could be a common cause of bugs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | On Fri, 08 Jul 2011 18:47:55 -0400, Andrej Mitrovic <andrej.mitrovich@gmail.com> wrote:
> On 7/9/11, Andrej Mitrovic <andrej.mitrovich@gmail.com> wrote:
>> double step = 1 / width; // or .1
>
> Woops that should have been `1.`. See, another bug right there!
1.0
1. is a horrible legacy thing, and should be removed.
-Steve
|
July 08, 2011 Re: This seems like what could be a common cause of bugs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | Andrej Mitrovic: > enum width = 100; > double step = 1 / width; > ... > This seems like a very easy mistake to make. Right, it was present even in Python 2.x: http://ideone.com/BEZqq The bug you have found is common enough to deserve a so fundamental change in Python, they have improved it in Python3.x: http://ideone.com/QeZEk In Pascal/ObjectPascal you have both FP division (/) and integer division (div). In OCaML too, there is "/" and "/." to tell them apart. I believe such distinction reduces similar bugs a lot. Even if Python2 was (and is) a very widespread language, and they have fixed the division, I don't think we'll see this change in D. Introducing an integer division operator in D is a possibility, but I think this is not enough to avoid your bug. ------------------------------ Steven Schveighoffer: > 1. is a horrible legacy thing, and should be removed. I agree, just as .1 :-) Saving one char of souece code is not worth the troubles this causes now and then. Bye, bearophile |
July 08, 2011 Re: This seems like what could be a common cause of bugs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On 7/9/11, Steven Schveighoffer <schveiguy@yahoo.com> wrote:
> On Fri, 08 Jul 2011 18:47:55 -0400, Andrej Mitrovic <andrej.mitrovich@gmail.com> wrote:
>
>> On 7/9/11, Andrej Mitrovic <andrej.mitrovich@gmail.com> wrote:
>>> double step = 1 / width; // or .1
>>
>> Woops that should have been `1.`. See, another bug right there!
>
> 1.0
>
> 1. is a horrible legacy thing, and should be removed.
>
> -Steve
>
I get tempted to use it because it's there and then get shot in the foot. :)
|
July 09, 2011 Re: This seems like what could be a common cause of bugs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On 2011-07-09 01:03, Steven Schveighoffer wrote: > On Fri, 08 Jul 2011 18:47:55 -0400, Andrej Mitrovic > <andrej.mitrovich@gmail.com> wrote: > >> On 7/9/11, Andrej Mitrovic <andrej.mitrovich@gmail.com> wrote: >>> double step = 1 / width; // or .1 >> >> Woops that should have been `1.`. See, another bug right there! > > 1.0 > > 1. is a horrible legacy thing, and should be removed. > > -Steve Yes, please remove it. -- /Jacob Carlborg |
July 09, 2011 Re: This seems like what could be a common cause of bugs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | "Steven Schveighoffer" <schveiguy@yahoo.com> wrote in message news:op.vybo0hv1eav7ka@localhost.localdomain... > 1. is a horrible legacy thing, and should be removed. > > -Steve This I hate, but I'd hate to lose 1.f and 1.L |
July 09, 2011 Re: This seems like what could be a common cause of bugs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | Steven Schveighoffer: > 1. is a horrible legacy thing, and should be removed. I have asked for this in two bug reports, both closed because of octal literals: http://d.puremagic.com/issues/show_bug.cgi?id=3837 http://d.puremagic.com/issues/show_bug.cgi?id=2656 So I have opened one more just for FP literals: http://d.puremagic.com/issues/show_bug.cgi?id=6277 Bye, bearophile |
July 11, 2011 Re: This seems like what could be a common cause of bugs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Murphy | On Sat, 09 Jul 2011 07:38:39 -0400, Daniel Murphy
<yebblies@nospamgmail.com> wrote:
> "Steven Schveighoffer" <schveiguy@yahoo.com> wrote in message
> news:op.vybo0hv1eav7ka@localhost.localdomain...
>> 1. is a horrible legacy thing, and should be removed.
>>
>> -Steve
>
> This I hate, but I'd hate to lose 1.f and 1.L
>
>
What's wrong with 1.0f and 1.0L ?
-Steve
|
July 11, 2011 Re: This seems like what could be a common cause of bugs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | "Steven Schveighoffer" <schveiguy@yahoo.com> wrote in message news:op.vygk71eweav7ka@localhost.localdomain... > > What's wrong with 1.0f and 1.0L ? > > -Steve It's one character longer! Mostly it's just a habit I've gotten into. I'd likely be able to get used to writing the zero fairly easily. |
July 11, 2011 Re: This seems like what could be a common cause of bugs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Murphy | On Mon, 11 Jul 2011 10:45:16 -0400, Daniel Murphy <yebblies@nospamgmail.com> wrote:
> "Steven Schveighoffer" <schveiguy@yahoo.com> wrote in message
> news:op.vygk71eweav7ka@localhost.localdomain...
>>
>> What's wrong with 1.0f and 1.0L ?
>>
>> -Steve
>
> It's one character longer!
1f is one character shorter :P (BTW, not sure the grammar currently supports this one, even though it compiles. I think:
Integer FloatSuffix
should be added.
I admit, there is no equivalent for real, since L is dual-purposed.
-Steve
|
Copyright © 1999-2021 by the D Language Foundation