Using 'with'
user1234
user1234 at 12.de
Tue Jan 13 07:27:54 UTC 2026
On Monday, 12 January 2026 at 18:20:37 UTC, Nick Treleaven wrote:
> On Monday, 12 January 2026 at 11:58:01 UTC, user1234 wrote:
>> To go further, while this trick is great, there's been
>> discussions [last
>> years](https://forum.dlang.org/thread/zbugncpaooowjsxldzue@forum.dlang.org) about _Parent Enum Inference_. Instead of
>>
>> ```
>> bitset |= 1 << EnumType.enumerator;
>> ```
>>
>> people want to the language to allow writing
>>
>> ```
>> bitset |= 1 << .enumerator; // EnumType can be infered from
>> the OrAssign LHS
>> ```
>
> How can it be inferred? There's no expected type for the
> right-hand side of the `<<` operator. Of course the link has
> cases that could be inferred.
>
>>
>> in this case `with` is of no help because it introduces a
>> scope, because it's not an expression, and finally because
>> it's only used once.
Yeah you're right with that remark... better example
```
bitset |= .enumerator
```
assuming the C style with the pre-shifted value defined for each
enumerator.
More information about the Digitalmars-d-learn
mailing list