Re: auto init & what the code means

2010-12-27 Thread Andrei Alexandrescu
On 12/26/10 6:04 PM, Tomek Sowiński wrote: spir wrote: On Sun, 26 Dec 2010 14:54:12 +0100 Andrej Mitrovic wrote: int i;// auto-initialized to int.init int i = void; // not initialized Thanks. Actually this solves my "semantic" issue, did not even think at 'void'. (I will use it often).

Re: auto init & what the code means

2010-12-27 Thread Jonathan M Davis
On Monday 27 December 2010 04:28:29 spir wrote: > On Sun, 26 Dec 2010 14:04:28 -0800 > > Jonathan M Davis wrote: > > On Sunday 26 December 2010 07:08:22 Andrei Alexandrescu wrote: > > > On 12/26/10 8:54 AM, spir wrote: > > > > On Sun, 26 Dec 2010 14:54:12 +0100 > > > > > > > > Andrej Mitrovic w

Re: auto init & what the code means

2010-12-27 Thread spir
On Sun, 26 Dec 2010 14:04:28 -0800 Jonathan M Davis wrote: > On Sunday 26 December 2010 07:08:22 Andrei Alexandrescu wrote: > > On 12/26/10 8:54 AM, spir wrote: > > > On Sun, 26 Dec 2010 14:54:12 +0100 > > > > > > Andrej Mitrovic wrote: > > >> int i;// auto-initialized to int.init > > >> in

Re: auto init & what the code means

2010-12-26 Thread Jonathan M Davis
On Sunday 26 December 2010 15:02:42 Daniel Gibson wrote: > Am 26.12.2010 23:04, schrieb Jonathan M Davis: > > On Sunday 26 December 2010 07:08:22 Andrei Alexandrescu wrote: > >> On 12/26/10 8:54 AM, spir wrote: > >>> On Sun, 26 Dec 2010 14:54:12 +0100 > >>> > >>> Andrej Mitrovic wrote: > in

Re: auto init & what the code means

2010-12-26 Thread Tomek Sowiński
spir wrote: > On Sun, 26 Dec 2010 14:54:12 +0100 > Andrej Mitrovic wrote: > > > int i;// auto-initialized to int.init > > int i = void; // not initialized > > Thanks. Actually this solves my "semantic" issue, did not even think > at 'void'. (I will use it often). By the way, I don't want to

Re: auto init & what the code means

2010-12-26 Thread Andrej Mitrovic
On 12/27/10, Daniel Gibson wrote: > I really like how D does this: Make the safe thing default and the > unsafe thing possible via more typing. Compare this to Go, where the safe thing is the only way of doing things and the unsafe thing is impossible*. Unsafe can be useful, and D allows it. But

Re: auto init & what the code means

2010-12-26 Thread Daniel Gibson
Am 26.12.2010 23:04, schrieb Jonathan M Davis: On Sunday 26 December 2010 07:08:22 Andrei Alexandrescu wrote: On 12/26/10 8:54 AM, spir wrote: On Sun, 26 Dec 2010 14:54:12 +0100 Andrej Mitrovic wrote: int i;// auto-initialized to int.init int i = void; // not initialized Thanks. Actua

Re: auto init & what the code means

2010-12-26 Thread Jonathan M Davis
On Sunday 26 December 2010 07:08:22 Andrei Alexandrescu wrote: > On 12/26/10 8:54 AM, spir wrote: > > On Sun, 26 Dec 2010 14:54:12 +0100 > > > > Andrej Mitrovic wrote: > >> int i;// auto-initialized to int.init > >> int i = void; // not initialized > > > > Thanks. Actually this solves my "se

Re: auto init & what the code means

2010-12-26 Thread Andrei Alexandrescu
On 12/26/10 8:54 AM, spir wrote: On Sun, 26 Dec 2010 14:54:12 +0100 Andrej Mitrovic wrote: int i;// auto-initialized to int.init int i = void; // not initialized Thanks. Actually this solves my "semantic" issue, did not even think at 'void'. (I will use it often). By the way, I don't wa

Re: auto init & what the code means

2010-12-26 Thread bearophile
spir: > Actually this solves my "semantic" issue, did not even think at 'void'. (I > will use it often). Do not use =void often, it's for performance critical situations only (and other uncommon situations). It goes against the D way. Bye, bearophile

Re: auto init & what the code means

2010-12-26 Thread spir
On Sun, 26 Dec 2010 14:54:12 +0100 Andrej Mitrovic wrote: > int i;// auto-initialized to int.init > int i = void; // not initialized Thanks. Actually this solves my "semantic" issue, did not even think at 'void'. (I will use it often). By the way, I don't want to play the superhero with un

Re: auto init & what the code means

2010-12-26 Thread Andrej Mitrovic
Well that's why I declare my variables right where I need them, compared to e.g. Pascal where you have to define all variables at the top. But If I understand correctly, then you can use the following: 3) int i = int.init; // meant to be auto-initialized to int.init 4) int i; // auto-initialized

Re: auto init & what the code means

2010-12-26 Thread bearophile
Andrej Mitrovic: > int i;// auto-initialized to int.init > int i = void; // not initialized I think the OP meant: 1) int i = void; // not initialized 2) int i = 0; // initialized to 0 3) int i; // meant to be auto-initialized to int.init, similar to case 2 4) int i; // auto-initialized to in

Re: auto init & what the code means

2010-12-26 Thread Andrej Mitrovic
int i;// auto-initialized to int.init int i = void; // not initialized There is no ambiguity. If you want to play with non-initialized values (and play a superhero) you have to work extra and "initialize" those variables with void, which means they're uninitialized. On 12/26/10, spir wrote:

auto init & what the code means

2010-12-26 Thread spir
Hello, I have a problem with D's auto-init feature. When reading in someone else's code int i; there is no way, I guess, to know whether this means "i is initialised to 0" or "i is left undefined". For this reason, in the former case I do explicitely initialise. Thus, int i = 0;