Permitted locations of a version condition

Phil Deets pjdeets2 at gmail.com
Thu Oct 29 21:28:05 PDT 2009


On Thu, 29 Oct 2009 22:16:13 -0500, Stewart Gordon <smjg_1998 at yahoo.com>  
wrote:

> Phil Deets wrote:
>> I would definitely like the following code to work.
>>  enum Tag
>> {
>>    A, B, C,
>>    version (5) {
>>       D, E,
>>    }
>>    version (7) {
>>       F, G,
>>    }
>>    // ...
>> }
>
> So would I, except that it makes more sense to me to have the trailing  
> comma after the '}'.  Commas separate, unlike semicolons, which  
> terminate.
>

I put the comma inside the version block because then there wouldn't be  
duplicate commas if the version was removed. If the version number was 6  
in the above example, it would evaluate to "A, B, C, D, E," with my way,  
but

enum Tag
{
    A, B, C,
    version (5) {
       D, E
    },
    version (7) {
       F, G
    },
    // ...
}

would evaluate to "A, B, C, D, E, ," which has two commas in a row.  
However, you could keep version blocks separated with commas if you  
specialized the enum grammar specifically for version blocks, which might  
be the right way to go.



More information about the Digitalmars-d mailing list