Am 27.01.2012, 20:01 Uhr, schrieb Era Scarecrow rtcv...@yahoo.com:
El 26/01/2012 14:59, Trass3r escribi?:
I thought it'd be good to outsource this
question from the other thread
about enums as flags.
Is there any merit in having implicit
conversion to the basetype?
Imo it only introduces
This is an important topic.
I have an enhancement requests on enums:
http://d.puremagic.com/issues/show_bug.cgi?id=3999
As usual language design is a matter of finding the right balance between
strictness, that helps catch real bugs, and type sloppiness that makes code
more handy, and avoids
///T of type ENUM, and S of an integral.
struct HandleFlags(T, S)
{
S state; ///Holds
state.
alias T T_Enum;
this(T[] setFlags...);
///Returns true/false if a specific
ENUM flag has been set.
bool check(T[] flag...);
///Returns true/false if
On 01/26/2012 08:17 PM, Simen Kjærås wrote:
On Thu, 26 Jan 2012 23:49:40 +0100, Alvaro alvarodotseg...@gmail.com
wrote:
El 26/01/2012 14:59, Trass3r escribió:
I thought it'd be good to outsource this question from the other thread
about enums as flags.
Is there any merit in having implicit
On 26/01/12 21:26, Trass3r wrote:
Is there any merit in having implicit conversion to the basetype?
Allowing it to be used as an argument when calling C functions?
extern(C):
enum Bla : int {...}
void foo(Bla b);
How does this require implicit conversion?
The codegen treats Bla like
extern(C):
enum Bla : int {...}
void foo(Bla b);
How does this require implicit conversion?
The codegen treats Bla like basetype anyway.
Some of the Windows functions are made of multiple enums of different
types, ORed together.
-.- Microsuckx.
Then I think it should either become a
El 26/01/2012 14:59, Trass3r escribi?:
I thought it'd be good to outsource this
question from the other thread
about enums as flags.
Is there any merit in having implicit
conversion to the basetype?
Imo it only introduces a severe bug source and
brings no advantages.
Sometimes,
On Fri, 27 Jan 2012 13:34:06 +0100, Chad J
chadjoan@__spam.is.bad__gmail.com wrote:
On 01/26/2012 08:17 PM, Simen Kjærås wrote:
On Thu, 26 Jan 2012 23:49:40 +0100, Alvaro alvarodotseg...@gmail.com
wrote:
El 26/01/2012 14:59, Trass3r escribió:
I thought it'd be good to outsource this
I thought it'd be good to outsource this question from the other
thread about enums as flags.
Is there any merit in having implicit conversion to the basetype?
Imo it only introduces a severe bug source and brings no
advantages.
For example it allows implicit conversion to bool.
enum Bla
{
Trass3r wrote:
but by using named enums I made clear that Bla and Blub are
totally different
No. Obviously you decjlared both to be implicitely convertable to a
common super type: int. To change this, both supertypes have be
changed.
The impßlementation is unfortenatey broken:
void
On Thursday, 26 January 2012 at 14:45:02 UTC, Manfred Nowak wrote:
Trass3r wrote:
but by using named enums I made clear that Bla and Blub are
totally different
No. Obviously you decjlared both to be implicitely convertable
to a common super type: int. To change this, both supertypes
have
Trass3r wrote:
Is there any merit in having implicit conversion to the basetype?
Yes. Otherwise it would be at least close to equivalence to a
`typedef'.
-manfred
Trass3r wrote:
That's why I question the implicit conversion.
Yes. I realized my fault and canceled my message, but wasn't fast
enough.
-manfred
Is there any merit in having implicit conversion to the
basetype?
Yes. Otherwise it would be at least close to equivalence to a
`typedef'.
Even typedef implicitly converts in one of the directions.
A named enum is a separate type with a finite set of allowed
values defined by the user.
Trass3r wrote:
Even typedef implicitly converts in one of the directions.
`typedef' is or will be disallowed in D because of reasons I do not
understand. In C and C++ their existence introduce problems because
they increase the amount of parsing passes.
A named enum is a separate type
On 01/26/2012 02:59 PM, Trass3r wrote:
I thought it'd be good to outsource this question from the other thread
about enums as flags.
Is there any merit in having implicit conversion to the basetype?
Imo it only introduces a severe bug source and brings no advantages.
For example it allows
Le 26/01/2012 14:59, Trass3r a écrit :
I thought it'd be good to outsource this question from the other thread
about enums as flags.
Is there any merit in having implicit conversion to the basetype?
Imo it only introduces a severe bug source and brings no advantages.
For example it allows
I have argued for banning those operations on strong enums before, but
some objected to it because they wanted to use strong enums as bit flags.
Yep, that's what the other thread 'using enums for flags' is about.
But implicit conversions seem wrong in any case.
`typedef' is or will be disallowed in D because of reasons I do not
understand.
It's ill-defined. There are 4 possible types of typedef:
http://d.puremagic.com/issues/show_bug.cgi?id=5467
In C and C++ their existence introduce problems because
they increase the amount of parsing passes.
On 26.01.2012 14:59, Trass3r wrote:
I thought it'd be good to outsource this question from the other thread
about enums as flags.
Is there any merit in having implicit conversion to the basetype?
Allowing it to be used as an argument when calling C functions?
Without it, how would you
Is there any merit in having implicit conversion to the basetype?
Allowing it to be used as an argument when calling C functions?
extern(C):
enum Bla : int {...}
void foo(Bla b);
How does this require implicit conversion?
The codegen treats Bla like basetype anyway.
Trass3r wrote:
It's ill-defined. There are 4 possible types of typedef:
http://d.puremagic.com/issues/show_bug.cgi?id=5467
[...]
Again, this thread is all about discussing the right way to do it
and not about what the buggy and holey spec reads.
[...]
I don't see any merit in that.
You
El 26/01/2012 14:59, Trass3r escribió:
I thought it'd be good to outsource this question from the other thread
about enums as flags.
Is there any merit in having implicit conversion to the basetype?
Imo it only introduces a severe bug source and brings no advantages.
A better example is
Alvaro wrote:
With a non-int-convertible bool your above weird
example would not work.
But that the example works is not the fault of the existence of enums.
It is due to the fact that omission, inclusion or change of one
character can produce a different value without any warning.
On Thu, 26 Jan 2012 23:49:40 +0100, Alvaro alvarodotseg...@gmail.com
wrote:
El 26/01/2012 14:59, Trass3r escribió:
I thought it'd be good to outsource this question from the other thread
about enums as flags.
Is there any merit in having implicit conversion to the basetype?
Imo it only
25 matches
Mail list logo