Re: Enum "Inheritance"?

2011-02-27 Thread spir
On 02/27/2011 07:21 AM, %u wrote: Actually, on a second thought, I just noticed that the union method *is* extensible, since you're putting things in different unions... I think I'll give it a shot, thanks! :) And you can always "super-compose" unions. This view, in fact, is similar to the (fa

Re: Enum "Inheritance"?

2011-02-27 Thread spir
On 02/27/2011 04:20 AM, Nick Sabalausky wrote: "Nick Sabalausky" wrote in message news:ikcepj$248p$1...@digitalmars.com... I think your main original problem was that there isn't really a way to compose enums additively, only subtractive. That just gave me an idea: I think you should be abl

Re: Enum "Inheritance"?

2011-02-26 Thread %u
Actually, on a second thought, I just noticed that the union method *is* extensible, since you're putting things in different unions... I think I'll give it a shot, thanks! :)

Re: Enum "Inheritance"?

2011-02-26 Thread %u
> I know some people don't like using mixins, but I think that's really the best way to achieve that effect without loosing DIY and without resorting to something more heavy-weight > ... > That just gave me an idea: I think you should be able to get away with an ordinary union I thought about thos

Re: Enum "Inheritance"?

2011-02-26 Thread Nick Sabalausky
"Nick Sabalausky" wrote in message news:ikcepj$248p$1...@digitalmars.com... > > I think your main original problem was that there isn't really a way to > compose enums additively, only subtractive. > That just gave me an idea: I think you should be able to get away with an ordinary union: enu

Re: Enum "Inheritance"?

2011-02-26 Thread Nick Sabalausky
"%u" wrote in message news:ik7slf$2q2u$1...@digitalmars.com... >> What exactly is it that you're trying to do? > > >>> (1) I'm not going to create a new instance of an entire class > every single time I need to check an access mask, that's wasteful. >> I meant, you write File.open or File.isReada

Re: Enum "Inheritance"?

2011-02-25 Thread %u
> As long as you expose OS cruft, your wrappers are useless, I'm afraid. > I suggest you to provide safe and meaningful wrappers, e.g. streams, ranges, for concrete business cases which deal with OS directly so that the wrapper won't need flags from user (they are usually encoded in the function na

Re: Enum "Inheritance"?

2011-02-25 Thread Kagamin
%u Wrote: > So the question is, what's the best way to do it? As long as you expose OS cruft, your wrappers are useless, I'm afraid. I suggest you to provide safe and meaningful wrappers, e.g. streams, ranges, for concrete business cases which deal with OS directly so that the wrapper won't nee

Re: Enum "Inheritance"?

2011-02-25 Thread %u
> What exactly is it that you're trying to do? >> (1) I'm not going to create a new instance of an entire class every single time I need to check an access mask, that's wasteful. > I meant, you write File.open or File.isReadable which do the job for you and don't expose OS cruft. That's what I'

Re: Enum "Inheritance"?

2011-02-25 Thread Kagamin
%u Wrote: > >> Lol, okay. Do you have any other suggestions for a better > solution on how to avoid duplicating generic access masks like > MAXIMUM_ALLOWED inside each access mask type? > > > You're doing it wrong. Create OO wrapper instead. > > Hm... but: > > (1) I'm not going to create a new

Re: Enum "Inheritance"?

2011-02-24 Thread Nick Sabalausky
"%u" wrote in message news:ik70pq$1a37$1...@digitalmars.com... >>> Lol, okay. Do you have any other suggestions for a better > solution on how to avoid duplicating generic access masks like > MAXIMUM_ALLOWED inside each access mask type? > >> You're doing it wrong. Create OO wrapper instead. > >

Re: Enum "Inheritance"?

2011-02-24 Thread %u
>> Lol, okay. Do you have any other suggestions for a better solution on how to avoid duplicating generic access masks like MAXIMUM_ALLOWED inside each access mask type? > You're doing it wrong. Create OO wrapper instead. Hm... but: (1) I'm not going to create a new instance of an entire class e

Re: Enum "Inheritance"?

2011-02-24 Thread Kagamin
%u Wrote: > Lol, okay. Do you have any other suggestions for a better solution on how to > avoid duplicating > generic access masks like MAXIMUM_ALLOWED inside each access mask type? You're doing it wrong. Create OO wrapper instead.

Re: Enum "Inheritance"?

2011-02-23 Thread %u
>> enum AccessMask { GenericRead = 0x8000 } >> enum FileAccess : AccessMask { ReadData = 1 } //Errors > Nice. Has Walter thought about the possibility of such D code? Similar > problems with typedef (that doesn't play well with OOP) have pushed Andrei to remove typedef from D. So be careful,

Re: Enum "Inheritance"?

2011-02-23 Thread Nick Sabalausky
"%u" wrote in message news:ik432q$29qu$1...@digitalmars.com... >I have a question on enum "inheritance" -- I'm wondering if what's >happening below is a bug or by > design? > > I have code like this: > > enum AccessMask { GenericRead = 0x8

Re: Enum "Inheritance"?

2011-02-23 Thread bearophile
%u: > enum AccessMask { GenericRead = 0x8000 } > enum FileAccess : AccessMask { ReadData = 1 } //Errors Nice. Has Walter thought about the possibility of such D code? Similar problems with typedef (that doesn't play well with OOP) have pushed Andrei to remove typedef from D. So be careful, o

Enum "Inheritance"?

2011-02-23 Thread %u
I have a question on enum "inheritance" -- I'm wondering if what's happening below is a bug or by design? I have code like this: enum AccessMask { GenericRead = 0x8000 } enum FileAccess : AccessMask { ReadData = 1 } //Errors void foo(FileAccess a) { /*Do something*