Re: using enums as key in associative array

2011-03-08 Thread Jonathan M Davis
On Tuesday, March 08, 2011 07:40:08 spir wrote: > On 03/08/2011 03:48 PM, Jonathan M Davis wrote: > > I really don't understand your problem with module constructors. They're > > fantastic. > > I may be wrong, but I think this point of view is a "where I can from" > statement. C's char* are fantas

Re: using enums as key in associative array

2011-03-08 Thread Wilfried Kirschenmann
>> >> I really don't understand your problem with module constructors. They're >> fantastic. > > I may be wrong, but I think this point of view is a "where I can from" > statement. C's char* are fantastic when you have never used a PL with > builtin strings. There are languages in which you don't n

Re: using enums as key in associative array

2011-03-08 Thread spir
On 03/08/2011 03:48 PM, Jonathan M Davis wrote: I really don't understand your problem with module constructors. They're fantastic. I may be wrong, but I think this point of view is a "where I can from" statement. C's char* are fantastic when you have never used a PL with builtin strings. The

Re: using enums as key in associative array

2011-03-08 Thread Jonathan M Davis
On Tuesday 08 March 2011 04:54:45 spir wrote: > On 03/08/2011 09:26 AM, Wilfried Kirschenmann wrote: > >>> enum deviceType {cpu, gpu} > >>> auto execDeviceSuffix = [deviceType.cpu:".cpu", deviceType.gpu:".gpu"]; > >> > >> The way to get what you want to work in this case is to use a module > >> co

Re: using enums as key in associative array

2011-03-08 Thread spir
On 03/08/2011 09:26 AM, Wilfried Kirschenmann wrote: enum deviceType {cpu, gpu} auto execDeviceSuffix = [deviceType.cpu:".cpu", deviceType.gpu:".gpu"]; The way to get what you want to work in this case is to use a module constructor. So, you'd do something like this: string[deviceType] execDe

Re: using enums as key in associative array

2011-03-08 Thread Wilfried Kirschenmann
>> enum deviceType {cpu, gpu} >> auto execDeviceSuffix = [deviceType.cpu:".cpu", deviceType.gpu:".gpu"]; > The way to get what you want to work in this case is to use a module > constructor. So, you'd do something like this: > > string[deviceType] execDeviceSuffix; > > static this() > { >        e

Re: using enums as key in associative array

2011-03-07 Thread Ali Çehreli
On 03/07/2011 11:16 AM, Jonathan M Davis wrote: > On Monday, March 07, 2011 07:22:47 Wilfried Kirschenmann wrote: >> enum deviceType {cpu, gpu} >> auto execDeviceSuffix = [deviceType.cpu:".cpu", deviceType.gpu:".gpu"]; [...] >> This won't compile and give the error: >> Error: non-constant expre

Re: using enums as key in associative array

2011-03-07 Thread Jonathan M Davis
On Monday, March 07, 2011 07:22:47 Wilfried Kirschenmann wrote: > Hi, > > I'm a beginner in D; I have just begun the book from Andrei. > > I would like to know how to statically declare an associative array whose > key are enums. > > example : > #!../dmd2/linux/bin/rdmd > > import std.stdio, st