www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Why enum of structs are not initialised?

reply mimocrocodil <4denizzz gmail.com> writes:
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
Aug 11 2011
next sibling parent reply bearophile <bearophileHUGS lycos.com> writes:
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
Aug 11 2011
parent "Jonathan M Davis" <jmdavisProg gmx.com> writes:
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
Aug 11 2011
prev sibling parent mimocrocodil <4denizzz gmail.com> writes:
bearophile:

 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).
I want to use this enum in 'final switch' statement.
 Also is that "package:" actually working?
Yes
Aug 11 2011