With
ints, the best we can do is 0. With floats, NaN makes it better.
With the logic that NaN is the default for floats, 0 is a very
bad choice for ints. It the worst we could do. Altough I
understand that setting it to something else like -infinity is
still not a good choice.
I think that
On 09/06/12 14:42, Minas wrote:
With
ints, the best we can do is 0. With floats, NaN makes it better.
With the logic that NaN is the default for floats, 0 is a very bad
choice for ints. It the worst we could do. Altough I understand that
setting it to something else like -infinity is still
On 09/06/12 20:48, Kevin wrote:
On 09/06/12 14:42, Minas wrote:
With
ints, the best we can do is 0. With floats, NaN makes it better.
With the logic that NaN is the default for floats, 0 is a very bad
choice for ints. It the worst we could do. Altough I understand that
setting it to
On Sat 09 Jun 2012 14:59:21 EDT, Jerome BENOIT wrote:
On 09/06/12 20:48, Kevin wrote:
On 09/06/12 14:42, Minas wrote:
With
ints, the best we can do is 0. With floats, NaN makes it better.
With the logic that NaN is the default for floats, 0 is a very bad
choice for ints. It the worst we
On 09/06/12 20:42, Minas wrote:
With
ints, the best we can do is 0. With floats, NaN makes it better.
With the logic that NaN is the default for floats, 0 is a very bad choice for
ints. It the worst we could do. Altough I understand that setting it to
something else like -infinity is still
On Sat, Jun 9, 2012 at 4:53 PM, Andrew Wiley wiley.andre...@gmail.com wrote:
On Sat, Jun 9, 2012 at 11:57 AM, Kevin kevincox...@gmail.com wrote:
On Sat 09 Jun 2012 14:59:21 EDT, Jerome BENOIT wrote:
On 09/06/12 20:48, Kevin wrote:
On 09/06/12 14:42, Minas wrote:
With
ints, the best
Hello:
On 10/06/12 01:57, Andrew Wiley wrote:
On Sat, Jun 9, 2012 at 4:53 PM, Andrew Wileywiley.andre...@gmail.com wrote:
On Sat, Jun 9, 2012 at 11:57 AM, Kevinkevincox...@gmail.com wrote:
On Sat 09 Jun 2012 14:59:21 EDT, Jerome BENOIT wrote:
On 09/06/12 20:48, Kevin wrote:
On
On Sunday, June 10, 2012 02:32:18 Jerome BENOIT wrote:
I see. So the alternative, to get a kind of NaN effect, would be to set
integers to their hardware extremum (INT_MAX,SIZE_MAX,...). But this option
is hardware dependent, so zero as default for integers sounds the best
option.
??? All
On 10/06/12 02:49, Jonathan M Davis wrote:
On Sunday, June 10, 2012 02:32:18 Jerome BENOIT wrote:
I see. So the alternative, to get a kind of NaN effect, would be to set
integers to their hardware extremum (INT_MAX,SIZE_MAX,...). But this option
is hardware dependent, so zero as default for
On 10/06/12 02:49, Jonathan M Davis wrote:
On Sunday, June 10, 2012 02:32:18 Jerome BENOIT wrote:
I see. So the alternative, to get a kind of NaN effect, would be to set
integers to their hardware extremum (INT_MAX,SIZE_MAX,...). But this option
is hardware dependent, so zero as default for
The idea isn't being practical exactly. The idea was to use
invalid
values as defaults. Unfortunately things like ints don't have
invalid
values, so they chose zero. The idea is to make people
initialize their
variables.
I understand the logic, but I still disagree. No offense :)
I don't
On Thu, Jun 7, 2012 at 6:50 PM, Minas minas_mina1...@hotmail.co.uk wrote:
I agree that the default value for floats/doubles should be zero. It feels
much more natural.
The point is to make sure code is correct. Initializing your variables
should be what feels natural. Leaving then
I agree that the default value for floats/doubles should be zero.
It feels much more natural.
I think the problem here is that people are thinking about some
stuff too much. D is a rather new language that wants to be
practical. Floats defaulting to NaN is NOT practical FOR MOST
PEOPLE when
On Jun 7, 2012 9:53 PM, Minas minas_mina1...@hotmail.co.uk wrote:
I agree that the default value for floats/doubles should be zero. It
feels much more natural.
I think the problem here is that people are thinking about some stuff too
much. D is a rather new language that wants to be practical.
hello List:
On 08/06/12 04:04, Kevin Cox wrote:
On Jun 7, 2012 9:53 PM, Minas minas_mina1...@hotmail.co.uk
mailto:minas_mina1...@hotmail.co.uk wrote:
I agree that the default value for floats/doubles should be zero. It feels
much more natural.
This highly depends on your perspective:
People may not have voiced their dislike but I'm sure quite a few
don't like it, it felt jarringly wrong to me. Zero is a better
default for the consistency and usefulness, expecting a default
to cause things to keel over as a justification isn't a good one,
or not as strong as the consistency
On 14/04/12 16:52, F i L wrote:
On Saturday, 14 April 2012 at 10:38:45 UTC, Silveri wrote:
On Saturday, 14 April 2012 at 07:52:51 UTC, F i L wrote:
On Saturday, 14 April 2012 at 06:43:11 UTC, Manfred Nowak wrote:
F i L wrote:
4) use hardware signalling to overcome some of the limitations
On 16/04/12 04:38, F i L wrote:
Of course FP numbers are meant for coders... they're in a programming language.
They are used by coders, and not every coder that uses FP math *has* to be well
trained in the finer points of mathematics simply to use a number that can
represent fractions in a
Forums are messing up, so I'll try and respond in sections.
/test
Actually, all of this discussion has made me think that having a
compiler flag to change FP values to zero as default would be a
good idea.
Basically my opinion is largely influenced by a couple things.
That is:
- I believe a lot of good programmers are used to using zero for
default.
F i L:
I should be able to tackle something like adding a compiler
flag to default FP variables to zero. If I write the code,
would anyone object to having a flag for this?
I strongly doubt Walter Andrei will accept this in the main DMD
trunk.
Bye,
bearophile
On Monday, 16 April 2012 at 03:25:15 UTC, bearophile wrote:
F i L:
I should be able to tackle something like adding a compiler
flag to default FP variables to zero. If I write the code,
would anyone object to having a flag for this?
I strongly doubt Walter Andrei will accept this in the
On 4/16/12 12:00 PM, F i L wrote:
On Monday, 16 April 2012 at 03:25:15 UTC, bearophile wrote:
F i L:
I should be able to tackle something like adding a compiler flag to
default FP variables to zero. If I write the code, would anyone
object to having a flag for this?
I strongly doubt Walter
On Monday, 16 April 2012 at 04:05:35 UTC, Ary Manzana wrote:
On 4/16/12 12:00 PM, F i L wrote:
On Monday, 16 April 2012 at 03:25:15 UTC, bearophile wrote:
F i L:
I should be able to tackle something like adding a compiler
flag to
default FP variables to zero. If I write the code, would
On 04/13/2012 09:00 PM, F i L wrote:
default is NaN
Just to complete the picture, character types have invalid initial
values as well: 0xFF, 0x, and 0x for char, wchar, and dchar,
respectively.
Ali
On Friday, April 13, 2012 23:29:40 Ali Çehreli wrote:
On 04/13/2012 09:00 PM, F i L wrote:
default is NaN
Just to complete the picture, character types have invalid initial
values as well: 0xFF, 0x, and 0x for char, wchar, and dchar,
respectively.
Yeah. Thanks for mentioning
F i L wrote:
It sounds like circular reasoning.
Several considerations pressed the design into the current form:
1) always changing output on unchanged input is hard to debug
2) GC needs to be saved from garbage, that looks like pointers
3) missed explicit initializations should not create
Jonathan M Davis wrote:
No. You always have a bug if you don't initialize a variable to
the value that
it's supposed to be. It doesn't matter whether it's 0, NaN,
527.1209823, or
whatever. All having a default value that you're more likely to
use means is
that you're less likely to have to
On Saturday, 14 April 2012 at 06:43:11 UTC, Manfred Nowak wrote:
F i L wrote:
It sounds like circular reasoning.
Several considerations pressed the design into the current form:
1) always changing output on unchanged input is hard to debug
2) GC needs to be saved from garbage, that looks
On Saturday, 14 April 2012 at 06:29:40 UTC, Ali Çehreli wrote:
On 04/13/2012 09:00 PM, F i L wrote:
default is NaN
Just to complete the picture, character types have invalid
initial values as well: 0xFF, 0x, and 0x for char,
wchar, and dchar, respectively.
Ali
That's
On Saturday, April 14, 2012 09:58:42 F i L wrote:
On Saturday, 14 April 2012 at 06:29:40 UTC, Ali Çehreli wrote:
On 04/13/2012 09:00 PM, F i L wrote:
default is NaN
Just to complete the picture, character types have invalid
initial values as well: 0xFF, 0x, and 0x for
On Saturday, 14 April 2012 at 07:59:25 UTC, Jonathan M Davis
wrote:
On Saturday, April 14, 2012 09:45:57 F i L wrote:
If D doesn't accommodate entering Laymen, how does it expect to
gain popularity in any major way? Efficiency puts D on the map,
convenience is what brings the tourists.
I
On Saturday, 14 April 2012 at 07:52:51 UTC, F i L wrote:
On Saturday, 14 April 2012 at 06:43:11 UTC, Manfred Nowak wrote:
F i L wrote:
4) use hardware signalling to overcome some of the limitations
impressed by 3).
4) I have no idea what you just said... :)
On Saturday, 14 April 2012 at
Am 14.04.2012 07:48, schrieb F i L:
On Saturday, 14 April 2012 at 05:19:38 UTC, dennis luehring wrote:
Am 14.04.2012 06:00, schrieb F i L:
struct Foo {
int x, y;// ready for use.
float z, w; // messes things up.
float r = 0; // almost always...
}
On 14/04/12 09:45, F i L wrote:
Jonathan M Davis wrote:
No. You always have a bug if you don't initialize a variable to the value that
it's supposed to be. It doesn't matter whether it's 0, NaN, 527.1209823, or
whatever. All having a default value that you're more likely to use means is
that
F i L:
So basically, it's for debugging?
To avoid bugs it's useful for all variables to be initialized
before use (maybe with an explicit annotation for the uncommon
cases where you want to use uninitialized memory, like:
http://research.swtch.com/sparse ). Having a variable not
On 4/14/12, bearophile bearophileh...@lycos.com wrote:
Having a variable not initialized is a common source of bugs.
I'm going to argue that this was true for C/C++ but is much less true
for D. One benefit of having integrals initialized to 0 is that you
now have a defined default that you can
Jerome BENOIT wrote:
Why would a compiler set `real' to 0.0 rather then 1.0, Pi,
?
Because 0.0 is the lowest (smallest, starting point, etc..)
numerical value. Pi is the corner case and obviously has to be
explicitly set.
If you want to take this further, chars could even be
On Saturday, 14 April 2012 at 10:38:45 UTC, Silveri wrote:
On Saturday, 14 April 2012 at 07:52:51 UTC, F i L wrote:
On Saturday, 14 April 2012 at 06:43:11 UTC, Manfred Nowak
wrote:
F i L wrote:
4) use hardware signalling to overcome some of the limitations
impressed by 3).
4) I have no idea
dennis luehring wrote:
what does make float default to 0.0 better - does it just feel
better?
Not just. It's consistent with Int types, therefor easier for
newbs to pick up since all numeric value types behave the same.
I even think char should default to a usable value as well. Most
On Saturday, 14 April 2012 at 12:48:01 UTC, Andrej Mitrovic wrote:
On 4/14/12, bearophile bearophileh...@lycos.com wrote:
Having a variable not initialized is a common source of bugs.
I'm going to argue that this was true for C/C++ but is much
less true
for D. One benefit of having integrals
On 4/14/12, F i L witte2...@gmail.com wrote:
This is exactly what I'm trying to get at.
Anyway it's not all bad news since we can use a workaround:
struct Float {
float payload = 0.0;
alias payload this;
}
void main() {
Float x; // acts as a float, is initialized to 0.0
}
Not
On 14/04/12 16:47, F i L wrote:
Jerome BENOIT wrote:
Why would a compiler set `real' to 0.0 rather then 1.0, Pi, ?
Because 0.0 is the lowest (smallest, starting point, etc..)
quid -infinity ?
numerical value. Pi is the corner case and obviously has to be explicitly set.
If you
On Saturday, 14 April 2012 at 15:44:46 UTC, Jerome BENOIT wrote:
On 14/04/12 16:47, F i L wrote:
Jerome BENOIT wrote:
Why would a compiler set `real' to 0.0 rather then 1.0, Pi,
?
Because 0.0 is the lowest (smallest, starting point, etc..)
quid -infinity ?
The concept of zero is
On Saturday, 14 April 2012 at 15:35:13 UTC, Andrej Mitrovic wrote:
On 4/14/12, F i L witte2...@gmail.com wrote:
This is exactly what I'm trying to get at.
Anyway it's not all bad news since we can use a workaround:
struct Float {
float payload = 0.0;
alias payload this;
}
void
On 4/14/12, F i L witte2...@gmail.com wrote:
a Hack though, since it doesn't work with 'auto'.
What do you mean?
On Saturday, 14 April 2012 at 17:30:19 UTC, Andrej Mitrovic wrote:
On 4/14/12, F i L witte2...@gmail.com wrote:
a Hack though, since it doesn't work with 'auto'.
What do you mean?
Only that:
auto f = 1.0f; // is float not Float
On 4/14/12, F i L witte2...@gmail.com wrote:
auto f = 1.0f; // is float not Float
UFCS in 2.059 to the rescue:
struct Float
{
float payload = 0.0;
alias payload this;
}
@property Float f(float val) { return Float(val); }
void main()
{
auto f = 1.0.f;
}
On 14/04/12 18:38, F i L wrote:
On Saturday, 14 April 2012 at 15:44:46 UTC, Jerome BENOIT wrote:
On 14/04/12 16:47, F i L wrote:
Jerome BENOIT wrote:
Why would a compiler set `real' to 0.0 rather then 1.0, Pi, ?
Because 0.0 is the lowest (smallest, starting point, etc..)
quid
On Saturday, 14 April 2012 at 18:02:57 UTC, Andrej Mitrovic wrote:
On 4/14/12, F i L witte2...@gmail.com wrote:
auto f = 1.0f; // is float not Float
UFCS in 2.059 to the rescue:
struct Float
{
float payload = 0.0;
alias payload this;
}
@property Float f(float val) { return
On Saturday, 14 April 2012 at 18:07:41 UTC, Jerome BENOIT wrote:
On 14/04/12 18:38, F i L wrote:
On Saturday, 14 April 2012 at 15:44:46 UTC, Jerome BENOIT
wrote:
On 14/04/12 16:47, F i L wrote:
Jerome BENOIT wrote:
Why would a compiler set `real' to 0.0 rather then 1.0, Pi,
?
Because
On 4/14/12, Jerome BENOIT g62993...@rezozer.net wrote:
I would even say that D may go further by setting a kind of NaN for integers.
That's never going to happen.
F i L wrote:
You can't force new D programmers to follow a 'guidline'
By exposing a syntax error for every missed explicit initialization the
current guideline would be changed into an insurmountable barrier,
forcing every new D programmers to follow the 'guidline'.
-manfred
On 14/04/12 16:52, F i L wrote:
The initialization values chosen are also determined by the underlying
hardware implementation of the type. Signalling NANs
(http://en.wikipedia.org/wiki/NaN#Signaling_NaN) can be used with floats
because they are implemented by the CPU, but in the case of
On 14/04/12 20:51, F i L wrote:
On Saturday, 14 April 2012 at 18:07:41 UTC, Jerome BENOIT wrote:
On 14/04/12 18:38, F i L wrote:
On Saturday, 14 April 2012 at 15:44:46 UTC, Jerome BENOIT wrote:
On 14/04/12 16:47, F i L wrote:
Jerome BENOIT wrote:
Why would a compiler set `real' to 0.0
From the FaQ:
NaNs have the interesting property in that whenever a NaN is
used as an operand in a computation, the result is a NaN.
Therefore, NaNs will propagate and appear in the output
whenever a computation made use of one. This implies that a NaN
appearing in the output is an
On Saturday, April 14, 2012 06:00:35 F i L wrote:
From the FaQ:
NaNs have the interesting property in that whenever a NaN is
used as an operand in a computation, the result is a NaN.
Therefore, NaNs will propagate and appear in the output
whenever a computation made use of one. This
Am 14.04.2012 06:00, schrieb F i L:
struct Foo {
int x, y;// ready for use.
float z, w; // messes things up.
float r = 0; // almost always...
}
how often in your code is 0 or 0.0 the real starting point?
i can't think of any situation except counters or
So it's what I thought, the only reason is based on a faulty
premise, IMO.
Jonathan M Davis wrote:
Types default to the closest thing that they have to an invalid
value so that
code blows up as soon as possible if you fail to initialize a
variable to a
proper value and so that it fails
On Saturday, 14 April 2012 at 05:19:38 UTC, dennis luehring wrote:
Am 14.04.2012 06:00, schrieb F i L:
struct Foo {
int x, y;// ready for use.
float z, w; // messes things up.
float r = 0; // almost always...
}
how often in your code is 0 or 0.0 the real
On Saturday, April 14, 2012 07:41:33 F i L wrote:
You're supposed to initialize them or assign them
to appropriate values before using them.
sure, but if they always default to _usable_ constants no
expectations are lost and no bugs are created.
No. You always have a bug if you don't
61 matches
Mail list logo