proposal: allow 'with(Foo):' in addition to 'with(Foo){..}'

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Sun Aug 10 17:23:39 PDT 2014


On 8/10/2014 2:01 PM, Era Scarecrow wrote:
> On Sunday, 10 August 2014 at 20:12:56 UTC, Walter Bright wrote:
>> On 8/10/2014 11:34 AM, Era Scarecrow wrote:
>>>  5. Access permissions (public/private/protected).
>>>  6. File length attributes (@safe: @system: @trusted:)
>>
>> Again, that is for declarations, not statements.
>
>   Does with have to be only for statements?
>
>   Real example. In my code somewhere i have a large list of enum types that
> specify a type of formatting and visibility options.
>
> enum FlagStates {
>    def        = 0x0,    //Default Value.
>    changed    = 1,      ///Has changed (From original state)
>    readOnly   = 1 << 1, ///This field/subrecord/record is readonly
>    isOriginal = 1 << 2, ///when loaded except when marked deleted/invisible
>    invisible  = 1 << 3, ///
>    deleted    = 1 << 4, ///
>    //29 out of 32 flags are defined
>   }

I'd suggest simply:

    private alias FlagStates FS;

then use FS.def, etc.



More information about the Digitalmars-d mailing list