I have a feature request: "Named enum scope inference"

Tommi tommitissari at hotmail.com
Fri Sep 28 22:08:40 PDT 2012


On Saturday, 29 September 2012 at 04:26:01 UTC, Alex Rønne 
Petersen wrote:
>
> It's an awful lot of magic (it's not as easy in the 
> implementation as it sounds like) for questionable gain when we 
> have the with statement IMO.

"it's not as easy in the implementation as it sounds like"
----------------------------------------------------------
If this argument means: "It's going to increase the compilation 
time too much", then it's obviously a good reason not to do it. 
But if it means: "It's a lot of work to modify the compiler 
source code", then that's completely an unacceptable argument. 
The question of how much work it is to implement, has nothing to 
do with whether it's a good feature to have or not. And that's 
what we're discussing.


"questionable gain"
-------------------
Well, if you never use enum flags to control the specifics of 
your types and functions, then the gain is zero. That is parallel 
to: if you never create any variables, then the gain of the 
keyword 'auto' is zero. If you do however do these things 
constantly, then the gain is: less typing and cleaner syntax. 
Comparison:

enum Size    { small, medium, big }
enum Fitness { thin, strong, weak, fat }
enum Goal    { love, build, heal, kill }

class Character(Size s, Fitness f, Motivation m)
{
     ...
}

auto c1 = new Character!(Size.big, Fitness.fat, Goal.kill);
auto c2 = new Character!(big, fat, kill);



More information about the Digitalmars-d mailing list