Re: Multiple assignment

2011-02-25 Thread Jonathan M Davis
On Friday 25 February 2011 22:32:47 Ali Çehreli wrote: > On 02/25/2011 06:10 PM, Jonathan M Davis wrote: > > On Friday, February 25, 2011 17:31:36 Ali Çehreli wrote: > >> On 02/25/2011 05:09 PM, bearophile wrote: > >> > int j; > >> > int[2] y; > >> > y[j] = j = 1; > >> > >>

Re: Multiple assignment

2011-02-25 Thread Ali Çehreli
On 02/25/2011 06:10 PM, Jonathan M Davis wrote: On Friday, February 25, 2011 17:31:36 Ali Çehreli wrote: On 02/25/2011 05:09 PM, bearophile wrote: > int j; > int[2] y; > y[j] = j = 1; I think that's undefined behavior in C and C++. It is not defined whether j's previous

Re: std.xml empty element

2011-02-25 Thread Tom
El 25/02/2011 20:07, Jacob Carlborg escribió: On 2011-02-25 21:11, Tom wrote: El 24/02/2011 19:40, Tom escribió: El 24/02/2011 09:51, Jacob Carlborg escribió: On 2011-02-24 06:48, Tom wrote: Hi, how can I create an empty element with current D2 std.xml Element implementation? stdout.writeln(

Re: Interfacing with c and platform dependent sizes

2011-02-25 Thread Jonathan M Davis
On Friday, February 25, 2011 17:35:02 Jonathan M Davis wrote: > On Friday, February 25, 2011 17:16:31 simendsjo wrote: > > On 26.02.2011 02:06, bearophile wrote: > > > simendsjo: > > >> So.. A long in C is the same as the platform size? And long long > > >> doesn't exist in 64 bit? > > > > > > In

Re: Multiple assignment

2011-02-25 Thread Jonathan M Davis
On Friday, February 25, 2011 19:26:14 Steven Schveighoffer wrote: > On Fri, 25 Feb 2011 21:10:59 -0500, Jonathan M Davis > > wrote: > > On Friday, February 25, 2011 17:31:36 Ali Çehreli wrote: > >> On 02/25/2011 05:09 PM, bearophile wrote: > >> > int j; > >> > int[2] y; > >> > y

Re: Multiple assignment

2011-02-25 Thread Steven Schveighoffer
On Fri, 25 Feb 2011 21:10:59 -0500, Jonathan M Davis wrote: On Friday, February 25, 2011 17:31:36 Ali Çehreli wrote: On 02/25/2011 05:09 PM, bearophile wrote: > int j; > int[2] y; > y[j] = j = 1; I think that's undefined behavior in C and C++. It is not defined whether j's

Re: Interfacing with c and platform dependent sizes

2011-02-25 Thread Steven Schveighoffer
On Fri, 25 Feb 2011 20:06:04 -0500, bearophile wrote: simendsjo: So.. A long in C is the same as the platform size? And long long doesn't exist in 64 bit? In D the size of int/uint is 32 bits and long/ulong is 64 bits. In C the size of int, unsigned int, long, long long int, unsigned lon

Re: implicite deref on array element access? (indexing)

2011-02-25 Thread Jonathan M Davis
On Friday, February 25, 2011 07:15:52 spir wrote: > Hello, > > I thought it worked, just like implicite deref on (struct, class) member > access. But I cannot have it work: > > auto a = [1,2,3]; > auto pa = &a; > writeln((*pa)[2]); // ok > writeln(pa[2]); // segfa

Re: Multiple assignment

2011-02-25 Thread Jonathan M Davis
On Friday, February 25, 2011 17:31:36 Ali Çehreli wrote: > On 02/25/2011 05:09 PM, bearophile wrote: > > int j; > > int[2] y; > > y[j] = j = 1; > > I think that's undefined behavior in C and C++. It is not defined > whether j's previous or past value is used in y[j]. > > I would

Re: Multiple assignment

2011-02-25 Thread Ali Çehreli
On 02/25/2011 05:09 PM, bearophile wrote: > int j; > int[2] y; > y[j] = j = 1; I think that's undefined behavior in C and C++. It is not defined whether j's previous or past value is used in y[j]. I would expect the situation be the same in D. Ali

Re: Interfacing with c and platform dependent sizes

2011-02-25 Thread Jonathan M Davis
On Friday, February 25, 2011 17:16:31 simendsjo wrote: > On 26.02.2011 02:06, bearophile wrote: > > simendsjo: > >> So.. A long in C is the same as the platform size? And long long doesn't > >> exist in 64 bit? > > > > In D the size of int/uint is 32 bits and long/ulong is 64 bits. > > > > In C t

Re: Interfacing with c and platform dependent sizes

2011-02-25 Thread simendsjo
On 26.02.2011 02:06, bearophile wrote: simendsjo: So.. A long in C is the same as the platform size? And long long doesn't exist in 64 bit? In D the size of int/uint is 32 bits and long/ulong is 64 bits. In C the size of int, unsigned int, long, long long int, unsigned long long int, etc ar

Re: Multiple assignment

2011-02-25 Thread bearophile
simendsjo: > I couldn't find any info on the comma expression in the language > reference, but this was my first google hit: > """ > A comma expression contains two operands of any type separated by a > comma and has *left-to-right* associativity. The left operand is fully > evaluated, possibly

Re: Multiple assignment

2011-02-25 Thread Ali Çehreli
On 02/25/2011 04:56 PM, bearophile wrote: > Is this program showing a bug in multiple assignments (DMD 2.052)? > > > void main() { > int i; > int[2] x; > i, x[i] = 1; I haven't heard about multiple assignments but that's the comma operator up there, separating (and sequencing) two

Re: Interfacing with c and platform dependent sizes

2011-02-25 Thread bearophile
simendsjo: > So.. A long in C is the same as the platform size? And long long doesn't > exist in 64 bit? In D the size of int/uint is 32 bits and long/ulong is 64 bits. In C the size of int, unsigned int, long, long long int, unsigned long long int, etc are not fixed, the change according to t

Re: Multiple assignment

2011-02-25 Thread simendsjo
On 26.02.2011 01:56, bearophile wrote: Is this program showing a bug in multiple assignments (DMD 2.052)? void main() { int i; int[2] x; i, x[i] = 1; assert(x == [1, 0]); // OK int j; int[2] y; y[j], j = 1; assert(y == [0, 0]); // Not OK } At the end o

Multiple assignment

2011-02-25 Thread bearophile
Is this program showing a bug in multiple assignments (DMD 2.052)? void main() { int i; int[2] x; i, x[i] = 1; assert(x == [1, 0]); // OK int j; int[2] y; y[j], j = 1; assert(y == [0, 0]); // Not OK } At the end of the program I expect y to be [1,0] instead of [

Interfacing with c and platform dependent sizes

2011-02-25 Thread simendsjo
C is not my strong side, so I'm having some problems wrapping some code. I found a couple of sources on this: 1) http://www.digitalmars.com/d/2.0/htomodule.html 2) http://www.digitalmars.com/d/2.0/interfaceToC.html 1) C's long is the same as D's int. long long is long 2) C 32bit's long long is

Re: How do you test pre-/post-conditions and invariants?

2011-02-25 Thread Jonathan M Davis
On Friday, February 25, 2011 14:33:20 Magnus Lie Hetland wrote: > On 2011-02-25 20:04:10 +0100, Jonathan M Davis said: > > On Friday, February 25, 2011 07:30:50 Magnus Lie Hetland wrote: > >> Or, more generally, how do you test asserts (which is what I'm using in > >> my preconditions etc.)? > >>

Re: How do you test pre-/post-conditions and invariants?

2011-02-25 Thread spir
On 02/25/2011 11:33 PM, Magnus Lie Hetland wrote: On 2011-02-25 20:04:10 +0100, Jonathan M Davis said: On Friday, February 25, 2011 07:30:50 Magnus Lie Hetland wrote: Or, more generally, how do you test asserts (which is what I'm using in my preconditions etc.)? As far as I can see, collectEx

Re: How do you test pre-/post-conditions and invariants?

2011-02-25 Thread spir
On 02/25/2011 11:20 PM, Magnus Lie Hetland wrote: On 2011-02-25 17:48:54 +0100, spir said: On 02/25/2011 04:30 PM, Magnus Lie Hetland wrote: Or, more generally, how do you test asserts (which is what I'm using in my preconditions etc.)? As far as I can see, collectException() won't collect er

Re: std.xml empty element

2011-02-25 Thread Jacob Carlborg
On 2011-02-25 21:11, Tom wrote: El 24/02/2011 19:40, Tom escribió: El 24/02/2011 09:51, Jacob Carlborg escribió: On 2011-02-24 06:48, Tom wrote: Hi, how can I create an empty element with current D2 std.xml Element implementation? stdout.writeln(new Element("foo")); // Shields instead of T

Re: array idioms

2011-02-25 Thread spir
On 02/25/2011 11:31 PM, Andrej Mitrovic wrote: On 2/25/11, spir wrote: But where is this func implemented? DMD\dmd2\src\druntime\src\rt\aaA.d _aaDel&& _aaDelX And then in object.d: extern (C) { // from druntime/src/compiler/dmd/aaA.d ... void _aaDel(void* p, TypeInfo keyti,

Re: array idioms

2011-02-25 Thread spir
On 02/25/2011 09:09 PM, Jonathan M Davis wrote: On Friday, February 25, 2011 11:30:28 spir wrote: Hello, What's the idiomatic way to: * delete an element in an associative array If you have the key, then just use remove. The online documentation for asseciative array discusses it. e.g. b.re

Re: How do you test pre-/post-conditions and invariants?

2011-02-25 Thread Magnus Lie Hetland
On 2011-02-25 20:04:10 +0100, Jonathan M Davis said: On Friday, February 25, 2011 07:30:50 Magnus Lie Hetland wrote: Or, more generally, how do you test asserts (which is what I'm using in my preconditions etc.)? As far as I can see, collectException() won't collect errors, which is what asser

Re: array idioms

2011-02-25 Thread Andrej Mitrovic
On 2/25/11, spir wrote: > But where is this func > implemented? DMD\dmd2\src\druntime\src\rt\aaA.d _aaDel && _aaDelX And then in object.d: extern (C) { // from druntime/src/compiler/dmd/aaA.d ... void _aaDel(void* p, TypeInfo keyti, ...); ... } I don't really know how it gets c

Re: How do you test pre-/post-conditions and invariants?

2011-02-25 Thread Magnus Lie Hetland
On 2011-02-25 17:48:54 +0100, spir said: On 02/25/2011 04:30 PM, Magnus Lie Hetland wrote: Or, more generally, how do you test asserts (which is what I'm using in my preconditions etc.)? As far as I can see, collectException() won't collect errors, which is what assert() throws -- so what's th

Re: How do you test pre-/post-conditions and invariants?

2011-02-25 Thread Magnus Lie Hetland
On 2011-02-25 19:18:40 +0100, Jesse Phillips said: There has been talk of a std.unittest that would help with this, but for now: unittest { try { callMeWrong(wrong); assert(0); catch(AssertError e) { } } } Ah. I used something like... auto thrown = 0; try foo

Re: Foreach with byte problems

2011-02-25 Thread Ali Çehreli
On 02/25/2011 10:52 AM, Andrej Mitrovic wrote: So I'd like to print all values storable in a byte in hex representation: import std.stdio; void main() { int counter; foreach (byte index; byte.min..byte.max) { if (!(counter % 4)) writeln(); writef("%

Re: array idioms

2011-02-25 Thread spir
On 02/25/2011 08:55 PM, Andrej Mitrovic wrote: On 2/25/11, spir wrote: * delete an element in an associative array Just use .remove? void main() { auto var = ["a" : 1]; var.remove("b");// nothing happens var.remove("a");// "a" key is gone assert(!var.length); //

Re: Foreach with byte problems

2011-02-25 Thread Andrej Mitrovic
On 2/25/11, Jonathan M Davis wrote: > However, it is true that in this particular case, it's annoying. Still, in > the > general case, I do believe that it's definitely the right behavior. > > - Jonathan M Davis > I do agree it's the right thing to do, and I wouldn't want to change it. But I'd l

Re: Foreach with byte problems

2011-02-25 Thread Jonathan M Davis
On Friday, February 25, 2011 11:37:23 spir wrote: > On 02/25/2011 07:52 PM, Andrej Mitrovic wrote: > > So I'd like to print all values storable in a byte in hex representation: > > > > import std.stdio; > > void main() > > { > > > > int counter; > > foreach (byte index; byte.min..byte.m

Re: array idioms

2011-02-25 Thread Jonathan M Davis
On Friday, February 25, 2011 12:51:53 Andrej Mitrovic wrote: > I have asked for remove before, I got some responses here (in fact, > Jonathan made an enhancement request for it): > > http://www.digitalmars.com/d/archives/digitalmars/D/learn/Removing_an_objec > t_from_a_range_23212.html > > The to

Re: array idioms

2011-02-25 Thread Andrej Mitrovic
I have asked for remove before, I got some responses here (in fact, Jonathan made an enhancement request for it): http://www.digitalmars.com/d/archives/digitalmars/D/learn/Removing_an_object_from_a_range_23212.html The topic was derailed, but essentially you can provide a predicate as a function

Re: array idioms

2011-02-25 Thread Jonathan M Davis
On Friday 25 February 2011 12:30:00 Andrej Mitrovic wrote: > On 2/25/11, Jonathan M Davis wrote: > >> * insert an element in a dyn array > > > > Same as remove. There's no function for doing it at the moment. > > std.array.insert: > > int[] a = [ 1, 2, 3, 4 ]; > a.insert(2, [ 1, 2 ]); > assert(

Re: array idioms

2011-02-25 Thread Jonathan M Davis
On Friday 25 February 2011 12:09:44 Jonathan M Davis wrote: > On Friday, February 25, 2011 11:30:28 spir wrote: > > * delete an element in a dyn array > > I don't think that there is one right now. There should probably be a > function in std.array which does what remove in std.container would do,

Re: array idioms

2011-02-25 Thread Jonathan M Davis
On Friday 25 February 2011 12:16:19 Steven Schveighoffer wrote: > On Fri, 25 Feb 2011 15:09:44 -0500, Jonathan M Davis > > wrote: > > On Friday, February 25, 2011 11:30:28 spir wrote: > >> Hello, > >> > >> What's the idiomatic way to: > >> > >> * delete an element in an associative array > > >

Re: array idioms

2011-02-25 Thread Andrej Mitrovic
On 2/25/11, Jonathan M Davis wrote: > >> * insert an element in a dyn array > > Same as remove. There's no function for doing it at the moment. std.array.insert: int[] a = [ 1, 2, 3, 4 ]; a.insert(2, [ 1, 2 ]); assert(a == [ 1, 2, 1, 2, 3, 4 ]); afaik insert was missing from the documentation i

Re: array idioms

2011-02-25 Thread Steven Schveighoffer
On Fri, 25 Feb 2011 15:09:44 -0500, Jonathan M Davis wrote: On Friday, February 25, 2011 11:30:28 spir wrote: Hello, What's the idiomatic way to: * delete an element in an associative array If you have the key, then just use remove. The online documentation for asseciative array discusse

Re: std.xml empty element

2011-02-25 Thread Tom
El 24/02/2011 19:40, Tom escribió: El 24/02/2011 09:51, Jacob Carlborg escribió: On 2011-02-24 06:48, Tom wrote: Hi, how can I create an empty element with current D2 std.xml Element implementation? stdout.writeln(new Element("foo")); // Shields instead of Thanks in advance, Tom; http://d

Re: Foreach with byte problems

2011-02-25 Thread Steven Schveighoffer
On Fri, 25 Feb 2011 14:51:18 -0500, Andrej Mitrovic wrote: On 2/25/11, Steven Schveighoffer wrote: a dirty trick you could do is add 0, which should promote the arg to int. Cool. I've almost used +1-1, LOL! Well, I thought DMD would simply ignore +0 (dead code elimination?), but apparen

Re: array idioms

2011-02-25 Thread Jonathan M Davis
On Friday, February 25, 2011 11:30:28 spir wrote: > Hello, > > What's the idiomatic way to: > > * delete an element in an associative array If you have the key, then just use remove. The online documentation for asseciative array discusses it. e.g. b.remove("hello"); If you're looking to remo

Re: array idioms

2011-02-25 Thread Andrej Mitrovic
On 2/25/11, spir wrote: > * delete an element in an associative array Just use .remove? void main() { auto var = ["a" : 1]; var.remove("b");// nothing happens var.remove("a");// "a" key is gone assert(!var.length); // empty }

Re: Foreach with byte problems

2011-02-25 Thread Andrej Mitrovic
On 2/25/11, Steven Schveighoffer wrote: > a dirty trick you could do is add 0, which should promote the arg to int. Cool. I've almost used +1-1, LOL! Well, I thought DMD would simply ignore +0 (dead code elimination?), but apparently this is a cool shorthand for casting literals? Nice.

Re: Foreach with byte problems

2011-02-25 Thread Steven Schveighoffer
On Fri, 25 Feb 2011 14:34:35 -0500, Andrej Mitrovic wrote: Can this be simplified?: byte[] arr = to!(byte[])(array(iota(byte.min, byte.max+1))); The +1 turns byte.max into an int that can store 128. So when I call array on an iota, I'll get back an int[] of [-128, ..., 127]. And I have to c

Re: Foreach with byte problems

2011-02-25 Thread Steven Schveighoffer
On Fri, 25 Feb 2011 14:15:52 -0500, Andrej Mitrovic wrote: Maybe it's best to let D do type infering for me. This works ok: foreach (index; byte.min..byte.max+1) { if((index - byte.min) % 4 == 0) writeln(); writef("%#.2x, ", index); } I'm fine with t

Re: Foreach with byte problems

2011-02-25 Thread spir
On 02/25/2011 07:52 PM, Andrej Mitrovic wrote: So I'd like to print all values storable in a byte in hex representation: import std.stdio; void main() { int counter; foreach (byte index; byte.min..byte.max) { if (!(counter % 4)) writeln(); writef("%

Re: Foreach with byte problems

2011-02-25 Thread Andrej Mitrovic
Can this be simplified?: byte[] arr = to!(byte[])(array(iota(byte.min, byte.max+1))); The +1 turns byte.max into an int that can store 128. So when I call array on an iota, I'll get back an int[] of [-128, ..., 127]. And I have to convert that to a byte[].

array idioms

2011-02-25 Thread spir
Hello, What's the idiomatic way to: * delete an element in an associative array * delete an element in a dyn array * insert an element in a dyn array Thank you, Denis -- _ vita es estrany spir.wikidot.com

Re: Foreach with byte problems

2011-02-25 Thread Andrej Mitrovic
Maybe it's best to let D do type infering for me. This works ok: foreach (index; byte.min..byte.max+1) { if((index - byte.min) % 4 == 0) writeln(); writef("%#.2x, ", index); } I'm fine with that. Now, what's wrong with this code: auto foo = iota(byte

Re: How do you test pre-/post-conditions and invariants?

2011-02-25 Thread Jonathan M Davis
On Friday, February 25, 2011 07:30:50 Magnus Lie Hetland wrote: > Or, more generally, how do you test asserts (which is what I'm using in > my preconditions etc.)? > > As far as I can see, collectException() won't collect errors, which is > what assert() throws -- so what's the standard way of wri

Re: Foreach with byte problems

2011-02-25 Thread Steven Schveighoffer
On Fri, 25 Feb 2011 13:52:53 -0500, Andrej Mitrovic wrote: So I'd like to print all values storable in a byte in hex representation: import std.stdio; void main() { int counter; foreach (byte index; byte.min..byte.max) { if (!(counter % 4)) writeln(); wri

Foreach with byte problems

2011-02-25 Thread Andrej Mitrovic
So I'd like to print all values storable in a byte in hex representation: import std.stdio; void main() { int counter; foreach (byte index; byte.min..byte.max) { if (!(counter % 4)) writeln(); writef("%#.2x, ", index); counter++; } } If

Re: How do you test pre-/post-conditions and invariants?

2011-02-25 Thread Jesse Phillips
Magnus Lie Hetland Wrote: > Or, more generally, how do you test asserts (which is what I'm using in > my preconditions etc.)? > > As far as I can see, collectException() won't collect errors, which is > what assert() throws -- so what's the standard way of writing unit > tests for precondition

Re: How do you test pre-/post-conditions and invariants?

2011-02-25 Thread Ary Manzana
On 2/25/11 1:48 PM, spir wrote: On 02/25/2011 04:30 PM, Magnus Lie Hetland wrote: Or, more generally, how do you test asserts (which is what I'm using in my preconditions etc.)? As far as I can see, collectException() won't collect errors, which is what assert() throws -- so what's the standard

Re: implicite deref on array element access? (indexing)

2011-02-25 Thread spir
On 02/25/2011 04:43 PM, Steven Schveighoffer wrote: On Fri, 25 Feb 2011 10:15:52 -0500, spir wrote: Hello, I thought it worked, just like implicite deref on (struct, class) member access. But I cannot have it work: auto a = [1,2,3]; auto pa = &a; writeln((*pa)[2]); // ok writeln(pa[2]); // s

Re: How do you test pre-/post-conditions and invariants?

2011-02-25 Thread spir
On 02/25/2011 04:30 PM, Magnus Lie Hetland wrote: Or, more generally, how do you test asserts (which is what I'm using in my preconditions etc.)? As far as I can see, collectException() won't collect errors, which is what assert() throws -- so what's the standard way of writing unit tests for pr

Re: override to!string

2011-02-25 Thread Dmitry Olshansky
On 25.02.2011 17:28, spir wrote: Hello, Imagine I have the following custom type: alias float[] Numbers; Is it possible to override to!string for Numbers so that it outputs eg like; (1.1 2.2 3.3) ? I can indeed override/specialise toImpl or formatValue for the custom type, but those

Re: implicite deref on array element access? (indexing)

2011-02-25 Thread Steven Schveighoffer
On Fri, 25 Feb 2011 10:58:49 -0500, Andrej Mitrovic wrote: On 2/25/11, Steven Schveighoffer wrote: Fun fact, you can avoid array bounds checks (if you know the index is valid) by doing arr.ptr[n] Can't you do the same with -noboundscheck ? No, -noboundscheck stops bounds checking everyw

Re: implicite deref on array element access? (indexing)

2011-02-25 Thread Andrej Mitrovic
On 2/25/11, Steven Schveighoffer wrote: > Fun fact, you can avoid array bounds checks (if you know the index is > valid) by doing arr.ptr[n] Can't you do the same with -noboundscheck ?

Re: implicite deref on array element access? (indexing)

2011-02-25 Thread Steven Schveighoffer
On Fri, 25 Feb 2011 10:15:52 -0500, spir wrote: Hello, I thought it worked, just like implicite deref on (struct, class) member access. But I cannot have it work: auto a = [1,2,3]; auto pa = &a; writeln((*pa)[2]); // ok writeln(pa[2]); // segfault Because

How do you test pre-/post-conditions and invariants?

2011-02-25 Thread Magnus Lie Hetland
Or, more generally, how do you test asserts (which is what I'm using in my preconditions etc.)? As far as I can see, collectException() won't collect errors, which is what assert() throws -- so what's the standard way of writing unit tests for preconditions that use assert? (I.e., test that th

Re: implicite deref on array element access? (indexing)

2011-02-25 Thread Jesse Phillips
spir Wrote: > Hello, > > I thought it worked, just like implicite deref on (struct, class) member > access. But I cannot have it work: > > auto a = [1,2,3]; > auto pa = &a; > writeln((*pa)[2]); // ok > writeln(pa[2]); // segfault You aren't making a pointer to

Re: implicite deref on array element access? (indexing)

2011-02-25 Thread Andrej Mitrovic
P.S. I got bitten by this when I was interfacing with C. Only in my case I used multidimensional arrays. I just assumed they were the same thing as in C, but I was wrong.

Re: rdmd problems (OS X Leopard, DMD 2.052)

2011-02-25 Thread Magnus Lie Hetland
On 2011-02-21 15:17:44 +0100, Jacob Carlborg said: On 2011-02-21 14:16, Lars T. Kyllingstad wrote: Say you have a file "myscript", that starts with the line #!/path/to/interpreter --foo --bar If you run this as ./myscript --hello --world then the args[] received by the interpreter program

Re: override to!string

2011-02-25 Thread Jesse Phillips
spir Wrote: > Hello, > > Imagine I have the following custom type: > alias float[] Numbers; > > Is it possible to override to!string for Numbers so that it outputs eg like; > (1.1 2.2 3.3) > ? No, this is one reason for writeTo replacing toString, or whatever the name. It would all

Re: implicite deref on array element access? (indexing)

2011-02-25 Thread Andrej Mitrovic
Actually that doesn't explain anything! What I mean is, arrays in D are not the same as arrays in C. auto a = [1, 2, 3]; auto pa = &a; writeln(&a[0]); writeln(&a[1]); writeln(&a[2]); writeln(&pa[0]); writeln(&pa[1]); writeln(&pa[2]); 9A2E40 9A2E44 9A2E48 12FE34

Re: implicite deref on array element access? (indexing)

2011-02-25 Thread Andrej Mitrovic
This should explain everything: auto a = [1,2,3]; auto pa = &a; writeln(&pa); writeln(&pa+1); Do the math!

Re: rdmd problems (OS X Leopard, DMD 2.052)

2011-02-25 Thread Magnus Lie Hetland
On 2011-02-22 22:46:41 +0100, Paolo Invernizzi said: Hi Magnus, This is sligthly OT, but... How I loved AnyGui! Haha, cool :D Yeah, too bad the project died. Oh, well -- at least we tried :) It's nice to see you here, in the D bandwagon... Yeah, I've been looking for a more "close to the

implicite deref on array element access? (indexing)

2011-02-25 Thread spir
Hello, I thought it worked, just like implicite deref on (struct, class) member access. But I cannot have it work: auto a = [1,2,3]; auto pa = &a; writeln((*pa)[2]); // ok writeln(pa[2]); // segfault Denis -- _ vita es estrany spir.wikidot.com

override to!string

2011-02-25 Thread spir
Hello, Imagine I have the following custom type: alias float[] Numbers; Is it possible to override to!string for Numbers so that it outputs eg like; (1.1 2.2 3.3) ? I can indeed override/specialise toImpl or formatValue for the custom type, but those overrides are simply ignore

Re: %x and floats

2011-02-25 Thread Lars T. Kyllingstad
On Thu, 24 Feb 2011 13:27:39 -0500, Trass3r wrote: > Why doesn't this work: > > import std.stdio; > void main() > { > float a,b=0; > writefln("%x %x", a, b); > } > > std.format.FormatError: std.format floating That is because %x is for formatting integers. If you want a hex repres