Long Chang wrote:
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 );
}

----
class Foo
{
        enum Option
        {
                X = 2,
                Y = 4,
                Z = 8
        }
        int options;
        this(int opts = 0)
        {
                options = opts;
        }
}

void main()
{
        Foo foo;
        with( foo.Option )
        {
                foo = new Foo( X | Y | Z );
                assert( X | Y | Z == foo.options  );
        }
}
----

Is this the kind of thing you're looking for? That looks nicer than your proposed syntax in my opinion :)

Reply via email to