| Thread overview | ||||||
|---|---|---|---|---|---|---|
|
April 05, 2008 Storage class consistency | ||||
|---|---|---|---|---|
| ||||
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?
| ||||
April 05, 2008 Re: Storage class consistency | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Robert Fraser | == Quote from Robert Fraser (fraserofthenight@gmail.com)'s article
> 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?
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
| |||
April 05, 2008 Re: Storage class consistency | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Robert Fraser | 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
| |||
April 06, 2008 Re: Storage class consistency | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Robert Fraser | "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;
> }
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
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply