digitalmars.D - Storage class consistency
- Robert Fraser (27/27) Apr 05 2008 Okay, I know everyone wants to put "enum" to rest, but I just want an
- Sean Kelly (5/9) Apr 05 2008 Near as I can tell, it was the desire to avoid the creation of an additi...
- Paul D. Anderson (3/37) Apr 05 2008 I agree this is a problem but to me it is a syntax problem rather than a...
- Steven Schveighoffer (4/24) Apr 06 2008 I haven't used D2 since this was added, but from what I understood about...
Okay, I know everyone wants to put "enum" to rest, but I just want an explanation for why "enum" was chosen in the facre of syntactic difficulties. In particular, what I mean is that for every other storage class the following is possible: public { int x = 5; float f = 7.0; } const { int x = 5; float y = 7.0; } ... but not with enum ... enum { int x = 5; float y = 7.0; } ... which instead must be used as ... enum int x = 5; enum float y = 7.0; I understand Walter probably thought it through and decided that this inconsistency was worth it to be able to use a confusing keyword, but these are the sort of reasons it's difficult for me to get excited about D2. Is there any particular reason this was thought unimportant?
Apr 05 2008
== Quote from Robert Fraser (fraserofthenight gmail.com)'s articleI understand Walter probably thought it through and decided that this inconsistency was worth it to be able to use a confusing keyword, but these are the sort of reasons it's difficult for me to get excited about D2. Is there any particular reason this was thought unimportant?Near as I can tell, it was the desire to avoid the creation of an additional keyword that was the driving force behind the decision, as well as an apparent desire to allow addressability for invariant data. Sean
Apr 05 2008
Robert Fraser Wrote:Okay, I know everyone wants to put "enum" to rest, but I just want an explanation for why "enum" was chosen in the facre of syntactic difficulties. In particular, what I mean is that for every other storage class the following is possible: public { int x = 5; float f = 7.0; } const { int x = 5; float y = 7.0; } ... but not with enum ... enum { int x = 5; float y = 7.0; } ... which instead must be used as ... enum int x = 5; enum float y = 7.0; I understand Walter probably thought it through and decided that this inconsistency was worth it to be able to use a confusing keyword, but these are the sort of reasons it's difficult for me to get excited about D2. Is there any particular reason this was thought unimportant?I agree this is a problem but to me it is a syntax problem rather than a keyword problem. I'd like to see the syntax you described become available. If the problem with the syntax is a conflict with existing "enum" syntax then I think you make a strong case for a new keyword. IIRC, the favorite of the forum was "manifest". Paul
Apr 05 2008
"Robert Fraser" wroteOkay, I know everyone wants to put "enum" to rest, but I just want an explanation for why "enum" was chosen in the facre of syntactic difficulties. In particular, what I mean is that for every other storage class the following is possible: public { int x = 5; float f = 7.0; } const { int x = 5; float y = 7.0; } ... but not with enum ... enum { int x = 5; float y = 7.0; }I haven't used D2 since this was added, but from what I understood about it, this should work. If not, it should be a bug. -Steve
Apr 06 2008