www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Proposal: Enum types as valid With-statement parameters

reply Chris Nicholson-Sauls <ibisbasenji gmail.com> writes:
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
next sibling parent xs0 <xs0 xs0.com> writes:
 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
Actually, 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
prev sibling parent Deewiant <deewiant.doesnotlike.spam gmail.com> writes:
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