Can we have this Syntactic sugar.

Long Chang changedalone at gmail.com
Tue Nov 24 15:01:53 PST 2009


2009/11/24 Steven Schveighoffer <schveiguy at yahoo.com>:
> On Tue, 24 Nov 2009 10:26:08 -0500, Nick Sabalausky <a at a.a> wrote:
>
>> "Long Chang" <changedalone at gmail.com> wrote in message
>> news:mailman.499.1259061212.20261.digitalmars-d at puremagic.com...
>>>
>>> class RegExp
>>> {
>>>   enum Option{
>>>       X, Y, Z
>>>   }
>>>   int options;
>>>   this(int options = 0){ this.options = options; }
>>> }
>>>
>>> void main(){
>>>      auto reg  = new RegExp("^A.",   .Option(  X |Y|Z ) );
>>>      assert( RegExp .Option.X | RegExp .Option.Y| RegExp .Option.Z   ==
>>> reg.options );
>>> }
>>>
>>
>> That's a very good idea, I like that a lot.
>
> The .Option is already taken, it means "look in the global scope".
>
> However, doing RegExp.Option(X|Y|Z) would be cool.
>
> -Steve
>
It 's not "look in the global scope";
we can write this way:

RegExp.Option.(X|Y|Z)

there is a DOT befor (



More information about the Digitalmars-d mailing list