Regarding the proposed Binray Literals Deprecation

Kagamin spam at here.lot
Tue Sep 20 07:41:24 UTC 2022


On Sunday, 18 September 2022 at 11:00:12 UTC, Loara wrote:
> Binary literals aren't efficient (too many digit to represent 
> relatively small numbers) and aren't essential to the language 
> itself (hex literals are far more efficient). If you need to 
> set flags an enum approach makes code much more readable:
>
> ```d
> enum MyFlag {A = 0, B, C}
>
> T asFlag(T)(in T f) pure @safe nothrow @nogc{
>   return (1 << f);
> }
>
> ...
>
> int field = MyFlag.A.asFlag & MyFlag.B.asFlag;
> ```

You made an error right away.


More information about the Digitalmars-d mailing list