Thread overview
Why enum of structs are not initialised?
Aug 11, 2011
mimocrocodil
Aug 11, 2011
bearophile
Aug 11, 2011
Jonathan M Davis
August 11, 2011
code:

private struct request_variant {
	package:
		immutable string sql_query;
}

enum test : request_variant {
	current_time = request_variant( "SELECT now()" ),
	//users = { sql_query: "SELECT 'users list'::text" }
}

causes syntax error if I am uncommit second string in enum
August 11, 2011
mimocrocodil:

> causes syntax error if I am uncommit second string in enum

I think D enums are mostly meant for enumerations, of things like ints, ushorts, chars, etc. (But enhancement requests are possible).

Also is that "package:" actually working?

Bye,
bearophile
August 11, 2011
On Thursday, August 11, 2011 13:18 bearophile wrote:
> mimocrocodil:
> > causes syntax error if I am uncommit second string in enum
> 
> I think D enums are mostly meant for enumerations, of things like ints, ushorts, chars, etc. (But enhancement requests are possible).

That's incorrect. TDPL specifically talks about using structs as the type of an enum. However, there are bugs with it which make it so that it doesn't really work at the moment. Among them are:

http://d.puremagic.com/issues/show_bug.cgi?id=4423 http://d.puremagic.com/issues/show_bug.cgi?id=5460

If you see any bugs with regards to structs not working as enum values, please report them if you can't find them in bugzilla.

- Jonathan M Davis