On Monday, 28 May 2012 at 13:47:47 UTC, Andrei Alexandrescu wrote:
On 5/28/12 8:19 AM, foobar wrote:
See functional languages such as ML for a correct
implementation and also Java 5 Enums (similar but with an OO
flavor).
I've always found it amusing to watch what a kitchen sink Java
On Monday, 28 May 2012 at 21:01:43 UTC, bearophile wrote:
Andrei Alexandrescu:
I do agree that it's wrong to _conflate_ the enumerated value
with it ordinal,
I agree it is possible to fix enum.
Thank you for your answers Andrei. I have filed an enhancement
request:
On Sunday, May 27, 2012 21:45:22 bearophile wrote:
In some code I have created a small bug that can be reduced to
something like this, that the D compiler has not caught at
compile-time:
enum E1 { A, B }
enum E2 { C, D }
void main() {
E1[2] a;
with (E2)
assert(a[0]
27.05.2012 23:45, bearophile написал:
In some code I have created a small bug that can be reduced to something
like this, that the D compiler has not caught at compile-time:
enum E1 { A, B }
enum E2 { C, D }
void main() {
E1[2] a;
with (E2)
assert(a[0] == D);
}
Why isn't D able to statically
On 28.05.2012 12:58, Denis Shelomovskij wrote:
27.05.2012 23:45, bearophile написал:
In some code I have created a small bug that can be reduced to something
like this, that the D compiler has not caught at compile-time:
enum E1 { A, B }
enum E2 { C, D }
void main() {
E1[2] a;
with (E2)
Denis Shelomovskij:
Enumerations are in very poor state in D now.
...
By the way, current enums can be modified to correspond list
enumeration and flags can be added as library component.
I think D enums need to become a bit more strict (so you can't
equal elements of different enums).
Pascal got type safe enums and sets of enums (aka flags) right
in the 60ies. Too bad not even Ada copied this nice feature.
Fortunately, Nimrod does.
On Monday, 28 May 2012 at 08:58:29 UTC, Denis Shelomovskij wrote:
27.05.2012 23:45, bearophile написал:
In some code I have created a small bug that can be reduced to
something
like this, that the D compiler has not caught at compile-time:
enum E1 { A, B }
enum E2 { C, D }
void main() {
On 5/28/12 8:19 AM, foobar wrote:
I have to loudly object to this definition. Given a typical enumeration
such as:
enum color {Blue, Green, Red};
Who's to say that Blue must equal 0? This is conceptually plain *wrong*.
A conceptually correct enumeration must NOT expose such implementation
Andrei Alexandrescu:
I do agree that it's wrong to _conflate_ the enumerated value
with it ordinal, so in this program neither comparison should
compile without an explicit cast:
enum E1 { A, B }
enum E2 { C, D }
void main() {
E1 a;
assert(a == 0);
assert(a == E2.C);
}
The
On Monday, 28 May 2012 at 13:47:47 UTC, Andrei Alexandrescu wrote:
On 5/28/12 8:19 AM, foobar wrote:
I have to loudly object to this definition. Given a typical
enumeration
such as:
enum color {Blue, Green, Red};
Who's to say that Blue must equal 0? This is conceptually
plain *wrong*.
A
Am Mon, 28 May 2012 13:48:23 +0200
schrieb Araq rump...@web.de:
Pascal got type safe enums and sets of enums (aka flags) right
in the 60ies. Too bad not even Ada copied this nice feature.
Fortunately, Nimrod does.
Yes, I really like Pascal for that feature. Actually it is a mix of features
On 5/28/12 1:07 PM, foobar wrote:
It depends on what exactly the general concept is, is this a predefined
set of values or is it an ordered list. I'd argue that the set is more
general and we shouldn't force an ordering when one isn't strictly
required. Of course, the programmer should be able
On Monday, May 28, 2012 14:21:14 Andrei Alexandrescu wrote:
On 5/28/12 1:07 PM, foobar wrote:
It depends on what exactly the general concept is, is this a predefined
set of values or is it an ordered list. I'd argue that the set is more
general and we shouldn't force an ordering when one
On 5/28/12 2:37 PM, Jonathan M Davis wrote:
enum does need some work, but I think that the fact that it can be both built-
in types such as int as well as user-defined structs is great. It essentially
gives us the best of both worlds (basic enums such as in C/C++ and more
complex types as in
Andrei Alexandrescu:
I do agree that it's wrong to _conflate_ the enumerated value
with it ordinal,
I agree it is possible to fix enum.
Thank you for your answers Andrei. I have filed an enhancement
request:
http://d.puremagic.com/issues/show_bug.cgi?id=8157
Issue 8157 is a subset of
In some code I have created a small bug that can be reduced to
something like this, that the D compiler has not caught at
compile-time:
enum E1 { A, B }
enum E2 { C, D }
void main() {
E1[2] a;
with (E2)
assert(a[0] == D);
}
Why isn't D able to statically tell when you
On Monday, 28 May 2012 at 05:33:28 UTC, Mehrdad wrote:
The *real* question is, why don't you need the E2 qualifier
when you say D?
well never mind, I need sleep... I didn't see you were using
'with'.
The *real* question is, why don't you need the E2 qualifier
when you say D?
19 matches
Mail list logo