Tagged enums why reserved words are not permitted ?

H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Oct 27 18:03:10 PDT 2014


On Tue, Oct 28, 2014 at 12:31:43AM +0000, Domingo via Digitalmars-d-learn wrote:
> Hello !
> 
> I'm not sure if I'm missing something here but for a tagged enum it
> doesn't seem to make sense to forbid reserved keywords like:
> 
> enum CrudOps {read, write, delete}
> 
> The dmd compiler are complaining:
> ------
> cte.d(4): Error: basic type expected, not delete
> cte.d(4): Error: no identifier for declarator int
> cte.d(4): Error: type only allowed if anonymous enum and no enum type
> cte.d(4): Error: if type, there must be an initializer
> cte.d(4): Error: found 'delete' when expecting ','
> ------
> 
> It doesn't make sense to me because this kind of enum will not polute
> the global space and always need to beused with the tag:
> CrudOps.delete
[...]

Not true:

	CrudOps x;
	with (CrudOps) {
		x = read;
		... // etc.
	}


T

-- 
In a world without fences, who needs Windows and Gates? -- Christian Surchi


More information about the Digitalmars-d-learn mailing list