digitalmars.D - Proposal: Enum types as valid With-statement parameters
- Chris Nicholson-Sauls (52/52) Jul 20 2006 I recently found myself writing the following code:
I recently found myself writing the following code: It would have been nice to be able to write this as: Walter: how difficult would it be to allow named Enum types as valid With-statement parameters? When named Enums are used in tandem with constructs such as Switch, this could save quite a lot of typing, and is still perfectly clear when reading code. -- Chris Nicholson-Sauls
Jul 20 2006
Walter: how difficult would it be to allow named Enum types as valid With-statement parameters? When named Enums are used in tandem with constructs such as Switch, this could save quite a lot of typing, and is still perfectly clear when reading code. -- Chris Nicholson-SaulsActually, there's no need for that with(). If the switch value of of a named enum type, the corresponding constants could automatically become available for cases. It could be even better, if no other value was allowed (except default), as it's almost by definition a mistake? xs0
Jul 21 2006
Chris Nicholson-Sauls wrote:Walter: how difficult would it be to allow named Enum types as valid With-statement parameters? When named Enums are used in tandem with constructs such as Switch, this could save quite a lot of typing, and is still perfectly clear when reading code.I asked for this myself a while back: http://www.digitalmars.com/d/archives/digitalmars/D/37925.html It would indeed be a handy feature.
Jul 22 2006