A switch bug

2011-05-31 Thread bearophile
In this case I have not appreciated implicit char <-> int conversions in D (this comes from a bug of mine): void main(string[] args) { foreach (c; args[1]) switch (c) { case 0: .. case 9: // do something with the digit default: } } Bye, bearophile

Tuples & const values

2011-05-31 Thread bearophile
Currently this doesn't work, but I'd like to do this: import std.typecons; void main() { const int x = 1; const int y = 2; auto t = tuple(x, y); } Is it possible to modify the tuples to allow this? Bye, bearophile

Clear big AAs

2011-05-31 Thread useo
Hi, I'm trying to clear big associative arrays, but I always get an object error - what I currently doing is: private string[uint] myAA; void main() { fill(myAA); myAA.clear(); fill(myAA); // object.Error: Access Violation } void fill(string[uint] aa) { for (uint i = 0; i < 10_000_

Re: nested comments

2011-05-31 Thread Jose Armando Garcia
On Mon, May 30, 2011 at 11:58 PM, Jonathan M Davis wrote: > On 2011-05-30 19:53, Nick Sabalausky wrote: >> "Ary Manzana" wrote in message >> news:is1hsa$p53$1...@digitalmars.com... >> >> > On 5/31/11 7:58 AM, Nick Sabalausky wrote: >> >> "bearophile"  wrote in message >> >> news:is1dj6$ihb$1...@d

Re: Template parameter defaults

2011-05-31 Thread Steven Schveighoffer
On Mon, 30 May 2011 09:42:53 -0400, Johann MacDonagh wrote: I'm wondering if there's a cleaner way to do this: class Test(T = uint) { this(string s) { } } void main(string[] argv) { auto a = new Test!()("test"); } I'd *like* to be able to do this: auto a = new Test("te

Re: nested comments

2011-05-31 Thread Steven Schveighoffer
On Mon, 30 May 2011 20:43:18 -0400, bearophile wrote: Jesse Phillips: The purpose is commenting out code, but note that there is also version(none) { } which is never compiled in. version(none) {} is probably the official way to comment out code. And if you use a versioning system to kee

Re: Template parameter defaults

2011-05-31 Thread Jonathan M Davis
On 2011-05-31 10:49, Steven Schveighoffer wrote: > On Mon, 30 May 2011 09:42:53 -0400, Johann MacDonagh > > wrote: > > I'm wondering if there's a cleaner way to do this: > > > > class Test(T = uint) > > { > > > > this(string s) > > { > > } > > > > } > > > > void main(string[] argv) > > { > >

Re: Template parameter defaults

2011-05-31 Thread Simen Kjaeraas
On Tue, 31 May 2011 19:49:24 +0200, Steven Schveighoffer wrote: Currently, you can omit the template args only in the case of IFTI (Implicit Function Template Instantiation) which actually deduces your template arguments based on the function call. I'd argue actually, that IFTI should be

nested class inheritance

2011-05-31 Thread Michael Shulman
Hi, I have a class which defines a nested class: class Outer1 { class Inner1 { } } Now I want to inherit from Outer1, to modify its behavior in a way which also involves modifying the behavior of the corresponding inner objects. My first instinct was to write class Outer2 : Outer1 { class

Re: newbie windows setup help (path settings seem correct) fixed

2011-05-31 Thread Robert Smith
> > Changed directories back to: > dmd2\windows\bin > dmd2\windows\lib > dmd2\src > fixed. Thank you for your help. Robert Smith

Re: nested class inheritance

2011-05-31 Thread Simen Kjaeraas
On Tue, 31 May 2011 20:17:23 +0200, Michael Shulman wrote: I have thought of a workaround with 'alias this': class Outer2 : Outer1 { class Inner2 { Inner1 _self; alias _self this; this() { _self = this.outer.new Inner1(); } } } This seems to work, but requires manu

Re: nested class inheritance

2011-05-31 Thread Michael Shulman
On Tue, May 31, 2011 at 2:24 PM, Simen Kjaeraas wrote: >> I have thought of a workaround with 'alias this': >> >> class Outer2 : Outer1 { >>  class Inner2 { >>    Inner1 _self; >>    alias _self this; >>    this() { >>      _self = this.outer.new Inner1(); >>    } >>  } >> } >> >> This seems to wo

Re: Clear big AAs

2011-05-31 Thread bearophile
useo: > So... is there any solution to clear associative arrays > without memory leaking? What about remove an item at a time inside a loop (iterations on the keys array), and then doing a rehash? Bye, bearophile

Re: Clear big AAs

2011-05-31 Thread David Nadlinger
I realize that this might sound strange, but try setting myAA to null after clear(), this should fix the crash. David On 5/31/11 4:00 PM, useo wrote: Hi, I'm trying to clear big associative arrays, but I always get an object error - what I currently doing is: private string[uint] myAA; voi

Re: nested comments

2011-05-31 Thread Nick Sabalausky
"Steven Schveighoffer" wrote in message news:op.vwcxmwfgeav7ka@localhost.localdomain... > On Mon, 30 May 2011 20:43:18 -0400, bearophile > wrote: > >> Jesse Phillips: >> >>> The purpose is commenting out code, but note that there is also >>> version(none) { } which is never compiled in. >> >>

Re: nested comments

2011-05-31 Thread Jonathan M Davis
On 2011-05-31 18:03, Nick Sabalausky wrote: > "Steven Schveighoffer" wrote in message > news:op.vwcxmwfgeav7ka@localhost.localdomain... > > > On Mon, 30 May 2011 20:43:18 -0400, bearophile > > > > wrote: > >> Jesse Phillips: > >>> The purpose is commenting out code, but note that there is also

Re: The compiler can not find the property function.

2011-05-31 Thread choi heejo
Thanks for your detailed answer :)