std.d.lexer : voting thread
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Mon Oct 7 21:37:28 PDT 2013
On 10/7/13 9:34 PM, Andrei Alexandrescu wrote:
> On 10/7/13 9:26 PM, Andrei Alexandrescu wrote:
>> On 10/7/13 9:21 PM, Jakob Ovrum wrote:
>>> On Tuesday, 8 October 2013 at 00:16:45 UTC, Andrei Alexandrescu wrote:
>>>> http://dpaste.dzfl.pl/d07dd46d
>>>
>>> I have to say, that `generateCases` function is rather disgusting. I'm
>>> really worried about the trend of using string mixins when not
>>> necessary, for no apparent gain. Surely you could have used static
>>> foreach to generate those cases instead, allowing code that is actually
>>> readable. It would probably have much better compile-time performance as
>>> well, but that's just speculation.
>>
>> This is the first shot, and I'm more interested in the API with the
>> implementation to be improved. Your idea sounds great - care to put it
>> in code so we see how it does?
>>
>> Andrei
>
> FWIW I just tried this, and it seems to work swell.
>
> int main(string[] args) {
> alias TypeTuple!(1, 2, 3, 4) tt;
> int a;
> switch (args.length) {
> foreach (i, _; tt) {
> case i + 1: return i * 42;
> }
> default: break;
> }
> return 0;
> }
>
> Interesting!
>
>
> Andrei
On the other hand, I find it difficult to figure how the needed
processing can be done with reasonable ease with just the above. So I
guess it's your turn.
Andrei
More information about the Digitalmars-d
mailing list