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

Re: nested comments

2011-05-31 Thread Jose Armando Garcia
On Mon, May 30, 2011 at 11:58 PM, Jonathan M Davis jmdavisp...@gmx.com wrote: On 2011-05-30 19:53, Nick Sabalausky wrote: Ary Manzana a...@esperanto.org.ar wrote in message news:is1hsa$p53$1...@digitalmars.com... On 5/31/11 7:58 AM, Nick Sabalausky wrote: bearophilebearophileh...@lycos.com

Re: Template parameter defaults

2011-05-31 Thread Steven Schveighoffer
On Mon, 30 May 2011 09:42:53 -0400, Johann MacDonagh johann.macdonagh@spam..gmail.com 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

Re: nested comments

2011-05-31 Thread Steven Schveighoffer
On Mon, 30 May 2011 20:43:18 -0400, bearophile bearophileh...@lycos.com 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

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 johann.macdonagh@spam..gmail.com 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 schvei...@yahoo.com 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,

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 viritril...@gmail.com 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

Re: nested class inheritance

2011-05-31 Thread Michael Shulman
On Tue, May 31, 2011 at 2:24 PM, Simen Kjaeraas simen.kja...@gmail.com 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,

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;

Re: nested comments

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

Re: nested comments

2011-05-31 Thread Jonathan M Davis
On 2011-05-31 18:03, Nick Sabalausky wrote: Steven Schveighoffer schvei...@yahoo.com wrote in message news:op.vwcxmwfgeav7ka@localhost.localdomain... On Mon, 30 May 2011 20:43:18 -0400, bearophile bearophileh...@lycos.com wrote: Jesse Phillips: The purpose is commenting out code,