Re: Is there kind of "associative tuple" - like syntax in D?

2014-02-22 Thread Artur Skawina
On 02/21/14 18:57, Uranuz wrote: > In my template functions, classes it's necessary to write variadic template > parameter list, where elements are options to this class/function changing > it's behaviour. But they are optional and may be not set at all. These > options may be folowed by variad

Re: Is there kind of "associative tuple" - like syntax in D?

2014-02-21 Thread Philippe Sigaud
Justin: > alias MyFoo = Foo!(opt1(23), opt2("foo")); That's also my preferred solution. I find it easy to read and it's quite typesafe (also, it allows for more complex possibilities like n-params options). Another solution could be to use an associative array literal for each option (you have to

Re: Is there kind of "associative tuple" - like syntax in D?

2014-02-21 Thread Justin Whear
On Fri, 21 Feb 2014 19:09:56 +, Uranuz wrote: >> You could do something like this: >> >> alias Foo!( >> OptionType.optType1, 100, OptionType.optType2, "example, >> ...etc... >> ) MyFoo; > > Yes. I already use this. But it makes it not semanticaly obvious that > OptionType.optType1 is

Re: Is there kind of "associative tuple" - like syntax in D?

2014-02-21 Thread Uranuz
You could do something like this: alias Foo!( OptionType.optType1, 100, OptionType.optType2, "example, ...etc... ) MyFoo; Yes. I already use this. But it makes it not semanticaly obvious that OptionType.optType1 is a kind of `key` and 100 is `value`. Also it needs to parse it and

Re: Is there kind of "associative tuple" - like syntax in D?

2014-02-21 Thread Justin Whear
On Fri, 21 Feb 2014 17:57:57 +, Uranuz wrote: > My idea is that pass these options using syntax like this: > > alias Foo!( [ >OptionType.optType1 : 100, OptionType.optType2 : "example", >"someOtherOpt1": "someOtherOptValue", "someOtherOpt2": true > ] ) MyFoo; > > Using [] brackets

Is there kind of "associative tuple" - like syntax in D?

2014-02-21 Thread Uranuz
In my template functions, classes it's necessary to write variadic template parameter list, where elements are options to this class/function changing it's behaviour. But they are optional and may be not set at all. These options may be folowed by variadic template parameter list that will be