Re: Integer conversions too pedantic in 64-bit

2011-02-17 Thread Jonathan M Davis
On Thursday 17 February 2011 23:09:32 Russel Winder wrote: > On Thu, 2011-02-17 at 11:09 -0800, Walter Bright wrote: > > Russel Winder wrote: > > > Do not be afraid of the word. Fear leads to anger. Anger leads to > > > hate. Hate leads to suffering. (*) > > > > > > (*) With apologies to Master

Re: Integer conversions too pedantic in 64-bit

2011-02-17 Thread Russel Winder
On Thu, 2011-02-17 at 11:09 -0800, Walter Bright wrote: > Russel Winder wrote: > > Do not be afraid of the word. Fear leads to anger. Anger leads to > > hate. Hate leads to suffering. (*) > > > (*) With apologies to Master Yoda (**) for any misquote. > > "Luke, trust your feelings!" -- Oggie B

Re: Why does this work?

2011-02-17 Thread Andrei Alexandrescu
On 2/17/11 11:22 PM, Jonathan M Davis wrote: On Thursday 17 February 2011 21:06:26 Jason House wrote: Vladimir Panteleev Wrote: int foo; enum bar = foo+2; void main() { foo = 7; assert(bar == 9); } I would have expected bar to equal 2 since foo would be default initialized

Re: Why does this work?

2011-02-17 Thread Don
Vladimir Panteleev wrote: int foo; enum bar = foo+2; void main() { foo = 7; assert(bar == 9); } It's bug 2414 "enum is dynamically evaluated, yum"

Re: struct opEquals bug

2011-02-17 Thread Don
Sean Eskapp wrote: Has this been reported? struct A { int x; A foo() { return A(x); } const bool opEquals(ref const A other) { return (x == other.x); } } void main() { auto a = A(5); assert

Re: Why does this work?

2011-02-17 Thread Jonathan M Davis
On Thursday 17 February 2011 21:23:26 Vladimir Panteleev wrote: > On Fri, 18 Feb 2011 07:06:26 +0200, Jason House > > wrote: > > I would have expected bar to equal 2 since foo would be default > > initialized to 2. I'm going to guess that the there's some kind of > > optimization that only assign

Re: Why does this work?

2011-02-17 Thread Vladimir Panteleev
On Fri, 18 Feb 2011 07:06:26 +0200, Jason House wrote: I would have expected bar to equal 2 since foo would be default initialized to 2. I'm going to guess that the there's some kind of optimization that only assigns to foo once and isn't noticing that bar depends on it. Nope: int foo

Re: Why does this work?

2011-02-17 Thread Jonathan M Davis
On Thursday 17 February 2011 21:06:26 Jason House wrote: > Vladimir Panteleev Wrote: > > int foo; > > enum bar = foo+2; > > > > void main() > > { > > > > foo = 7; > > assert(bar == 9); > > > > } > > I would have expected bar to equal 2 since foo would be default initialized > to 2. I'm

Re: struct opEquals bug

2011-02-17 Thread Jason House
Sean Eskapp Wrote: > Has this been reported? Do what any of us would do... Search bugzilla and that as a bug if you don't find it.

Re: Why does this work?

2011-02-17 Thread Jason House
Vladimir Panteleev Wrote: > int foo; > enum bar = foo+2; > > void main() > { > foo = 7; > assert(bar == 9); > } > > -- > Best regards, > Vladimirmailto:vladi...@thecybershadow.net I would have expected bar to equal 2 since foo would be default initiali

Why does this work?

2011-02-17 Thread Vladimir Panteleev
int foo; enum bar = foo+2; void main() { foo = 7; assert(bar == 9); } -- Best regards, Vladimirmailto:vladi...@thecybershadow.net

struct opEquals bug

2011-02-17 Thread Sean Eskapp
Has this been reported? struct A { int x; A foo() { return A(x); } const bool opEquals(ref const A other) { return (x == other.x); } } void main() { auto a = A(5); assert(a == a.foo); // Erro

Re: Integer conversions too pedantic in 64-bit

2011-02-17 Thread Walter Bright
Nick Sabalausky wrote: "Walter Bright" wrote in message news:ijk6la$1d9a$1...@digitalmars.com... Andrej Mitrovic wrote: On 2/17/11, Walter Bright wrote: Andrej Mitrovic wrote: Is it true that you're not allowed to play with the segment registers in 32bit flat protected mode? Yes, that's th

Re: Integer conversions too pedantic in 64-bit

2011-02-17 Thread Nick Sabalausky
"Walter Bright" wrote in message news:ijk6la$1d9a$1...@digitalmars.com... > Andrej Mitrovic wrote: >> On 2/17/11, Walter Bright wrote: >>> Andrej Mitrovic wrote: Is it true that you're not allowed to play with the segment registers in 32bit flat protected mode? >>> Yes, that's the oper

Re: 0nnn octal notation considered harmful

2011-02-17 Thread Nick Sabalausky
"Stewart Gordon" wrote in message news:ijgpgb$1apc$1...@digitalmars.com... > > And is [octal] still the form of CompuServe user IDs? > Do those still exist?

Re: Integer conversions too pedantic in 64-bit

2011-02-17 Thread Nick Sabalausky
"Russel Winder" wrote in message news:mailman.1748.1297936806.4748.digitalmar...@puremagic.com... > A word is the natural length of an integer item in the processor. > It is necessarily machine specific. cf. DEC-10 had 9-bit bytes > and 36-bit word, IBM 370 has an 8-bit byte and a 32-bit word, >

Re: Integer conversions too pedantic in 64-bit

2011-02-17 Thread Walter Bright
Andrej Mitrovic wrote: On 2/17/11, Walter Bright wrote: Andrej Mitrovic wrote: Is it true that you're not allowed to play with the segment registers in 32bit flat protected mode? Yes, that's the operating system's job. They took our jerbs! You can always start your own company and hire y

Re: Integer conversions too pedantic in 64-bit

2011-02-17 Thread Andrej Mitrovic
On 2/17/11, Walter Bright wrote: > Andrej Mitrovic wrote: >> Is it true that you're not allowed to play with the segment registers >> in 32bit flat protected mode? > > Yes, that's the operating system's job. > They took our jerbs!

Re: Integer conversions too pedantic in 64-bit

2011-02-17 Thread Walter Bright
Andrej Mitrovic wrote: Is it true that you're not allowed to play with the segment registers in 32bit flat protected mode? Yes, that's the operating system's job.

Re: Integer conversions too pedantic in 64-bit

2011-02-17 Thread Andrej Mitrovic
Is it true that you're not allowed to play with the segment registers in 32bit flat protected mode?

Re: Integer conversions too pedantic in 64-bit

2011-02-17 Thread Walter Bright
Kagamin wrote: Walter Bright Wrote: Actually, you can have a segmented model on a 32 bit machine rather than a flat model, with separate segments for code, data, and stack. The Digital Mars DOS Extender actually does this. The advantage of it is you cannot execute data on the stack. AFAIK you

Re: Integer conversions too pedantic in 64-bit

2011-02-17 Thread Walter Bright
Russel Winder wrote: Do not be afraid of the word. Fear leads to anger. Anger leads to hate. Hate leads to suffering. (*) (*) With apologies to Master Yoda (**) for any misquote. "Luke, trust your feelings!" -- Oggie Ben Doggie Of course, expecting consistency from Star Wars is a waste o

Re: Integer conversions too pedantic in 64-bit

2011-02-17 Thread Steven Schveighoffer
On Thu, 17 Feb 2011 13:08:08 -0500, bearophile wrote: Steven Schveighoffer: Yes, David has proposed a corrected version on the Phobos mailing list: http://lists.puremagic.com/pipermail/phobos/2011-February/004493.html I suggest it to return a signed value, like an int. But a signed long

Re: Integer conversions too pedantic in 64-bit

2011-02-17 Thread bearophile
Steven Schveighoffer: > Yes, David has proposed a corrected version on the Phobos mailing list: > > http://lists.puremagic.com/pipermail/phobos/2011-February/004493.html I suggest it to return a signed value, like an int. But a signed long is OK too. I suggest a name as "len" (or "slen") because

Re: alias this question

2011-02-17 Thread Simen kjaeraas
Jacob Carlborg wrote: I'm pretty sure that you can use the getter/setter syntax with opDispatch, anything else is a bug. You can only use one of the two, and yes, the bug is already filed. -- Simen

Re: Integer conversions too pedantic in 64-bit

2011-02-17 Thread Kevin Bealer
== Quote from Daniel Gibson (metalcae...@gmail.com)'s article > It was not proposed to alter ulong (int64), but to only a size_t equivalent. > ;) > And I agree that not having unsigned types (like in Java) just sucks. > Wasn't Java even advertised as a programming language for network stuff? Quite

Re: alias this question

2011-02-17 Thread Jacob Carlborg
On 2011-02-17 11:54, spir wrote: On 02/17/2011 11:41 AM, Jacob Carlborg wrote: On 2011-02-16 20:42, Christopher Nicholson-Sauls wrote: On 02/13/11 10:30, Olli Aalto wrote: I encountered a problem with alias this, when the aliased member is private. I'm using the latest dmd2. It reports the fol

Re: Integer conversions too pedantic in 64-bit

2011-02-17 Thread Olivier Pisano
Le 17/02/2011 13:28, Don a écrit : Yes, I know. It's true but I think rather useless. We need a name for an 8 bit quantity, and a 16 bit quantity, and higher powers of two. 'byte' is an established name for the first one, even though historically there were 9-bit bytes. IMHO 'word' wasn't such a

Re: Integer conversions too pedantic in 64-bit

2011-02-17 Thread Kagamin
dsimcha Wrote: > Funny, as simple as it is, this is a great idea for std.array because it > shortens the verbose cast(int) a.length to one extra character. You > could even put an assert in it to check in debug mode only that the > conversion is safe. > > int ilength(void[] a) @property > > {

Re: Integer conversions too pedantic in 64-bit

2011-02-17 Thread Steven Schveighoffer
On Thu, 17 Feb 2011 09:45:14 -0500, Kagamin wrote: dsimcha Wrote: Funny, as simple as it is, this is a great idea for std.array because it shortens the verbose cast(int) a.length to one extra character. You could even put an assert in it to check in debug mode only that the conversion is saf

Re: Integer conversions too pedantic in 64-bit

2011-02-17 Thread dsimcha
Funny, as simple as it is, this is a great idea for std.array because it shortens the verbose cast(int) a.length to one extra character. You could even put an assert in it to check in debug mode only that the conversion is safe. On 2/17/2011 7:18 AM, Kagamin wrote: dsimcha Wrote: Now that

Re: Integer conversions too pedantic in 64-bit

2011-02-17 Thread Kagamin
Walter Bright Wrote: > Actually, you can have a segmented model on a 32 bit machine rather than a > flat > model, with separate segments for code, data, and stack. The Digital Mars DOS > Extender actually does this. The advantage of it is you cannot execute data > on > the stack. AFAIK you i

Re: Integer conversions too pedantic in 64-bit

2011-02-17 Thread Don
Russel Winder wrote: On Thu, 2011-02-17 at 10:13 +0100, Don wrote: [ . . . ] Me too. A word is two bytes. Any other definition seems to be pretty useless. Sounds like people have been living with 8- and 16-bit processors for too long. A word is the natural length of an integer item in the p

Re: Integer conversions too pedantic in 64-bit

2011-02-17 Thread Kagamin
dsimcha Wrote: > Now that DMD has a 64-bit beta available, I'm working on getting a whole bunch > of code to compile in 64 mode. Frankly, the compiler is way too freakin' > pedantic when it comes to implicit conversions (or lack thereof) of > array.length. 99.999% of the time it's safe to assume

Re: Integer conversions too pedantic in 64-bit

2011-02-17 Thread Kagamin
Adam Ruppe Wrote: > alias iota lazyRangeThatGoesFromStartToFinishByTheGivenStepAmount; Ever wondered, what iota is. At last it's self-documented.

Re: Integer conversions too pedantic in 64-bit

2011-02-17 Thread Don
spir wrote: On 02/17/2011 10:13 AM, Don wrote: David Nadlinger wrote: On 2/17/11 8:56 AM, Denis Koroskin wrote: I second that. word/uword are shorter than ssize_t/size_t and more in line with other type names. I like it. I agree that size_t/ptrdiff_t are misnomers and I'd love to kill them

Re: alias this question

2011-02-17 Thread spir
On 02/17/2011 11:41 AM, Jacob Carlborg wrote: On 2011-02-16 20:42, Christopher Nicholson-Sauls wrote: On 02/13/11 10:30, Olli Aalto wrote: I encountered a problem with alias this, when the aliased member is private. I'm using the latest dmd2. It reports the follwing: src\main.d(14): Error: stru

Re: alias this question

2011-02-17 Thread Jacob Carlborg
On 2011-02-16 20:42, Christopher Nicholson-Sauls wrote: On 02/13/11 10:30, Olli Aalto wrote: I encountered a problem with alias this, when the aliased member is private. I'm using the latest dmd2. It reports the follwing: src\main.d(14): Error: struct K.K member s is not accessible If I change

Re: Integer conversions too pedantic in 64-bit

2011-02-17 Thread spir
On 02/17/2011 10:13 AM, Don wrote: David Nadlinger wrote: On 2/17/11 8:56 AM, Denis Koroskin wrote: I second that. word/uword are shorter than ssize_t/size_t and more in line with other type names. I like it. I agree that size_t/ptrdiff_t are misnomers and I'd love to kill them with fire, bu

Re: Integer conversions too pedantic in 64-bit

2011-02-17 Thread spir
On 02/17/2011 05:19 AM, Kevin Bealer wrote: == Quote from spir (denis.s...@gmail.com)'s article On 02/16/2011 03:07 AM, Jonathan M Davis wrote: On Tuesday, February 15, 2011 15:13:33 spir wrote: On 02/15/2011 11:24 PM, Jonathan M Davis wrote: Is there some low level reason why size_t should b

Re: Integer conversions too pedantic in 64-bit

2011-02-17 Thread Russel Winder
On Thu, 2011-02-17 at 10:13 +0100, Don wrote: [ . . . ] > Me too. A word is two bytes. Any other definition seems to be pretty > useless. Sounds like people have been living with 8- and 16-bit processors for too long. A word is the natural length of an integer item in the processor. It is nec

Re: Integer conversions too pedantic in 64-bit

2011-02-17 Thread Don
David Nadlinger wrote: On 2/17/11 8:56 AM, Denis Koroskin wrote: I second that. word/uword are shorter than ssize_t/size_t and more in line with other type names. I like it. I agree that size_t/ptrdiff_t are misnomers and I'd love to kill them with fire, but when I read about »word«, I intui

Re: Integer conversions too pedantic in 64-bit

2011-02-17 Thread David Nadlinger
On 2/17/11 8:56 AM, Denis Koroskin wrote: I second that. word/uword are shorter than ssize_t/size_t and more in line with other type names. I like it. I agree that size_t/ptrdiff_t are misnomers and I'd love to kill them with fire, but when I read about »word«, I intuitively associated it wi

Re: Integer conversions too pedantic in 64-bit

2011-02-17 Thread Denis Koroskin
On Wed, 16 Feb 2011 06:49:26 +0300, Michel Fortin wrote: On 2011-02-15 22:41:32 -0500, "Nick Sabalausky" said: I like "nint". But is it unsigned or signed? Do we need 'unint' too? I think 'word' & 'uword' would be a better choice. I can't say I'm too displeased with 'size_t', but it's