A couple of extensions to `with` that would be worthwhile
Tejas
notrealemail at gmail.com
Thu Oct 14 07:12:29 UTC 2021
On Thursday, 14 October 2021 at 02:58:32 UTC, Andrei Alexandrescu
wrote:
> On 10/13/21 4:13 PM, Timon Gehr wrote:
>> On 10/13/21 1:13 PM, Andrei Alexandrescu wrote:
>>> We can improve the `with` statement as follows:
>>
>> I don't think this is an "improvement" of the `with`
>> statement. It's a completely novel feature that happens to be
>> syntactically very close to the existing `with` statement.
>> There's an obvious meaning for the new syntax as an extension
>> of the existing feature, but it is not what you propose. Not
>> great. Maybe there is a better way to address this problem?
>
> You're right. The `while (type)` and `while (type):` at top
> level is probably good to salvage.
Maybe having the syntax as:
```d
with <construct> as <identifier>{
//do stuff
}
```
Would be better?
It could also be useful in `Python` style management for `file`
handles, plus be visually distinct enough from other uses of
`with` to not simply be overlooked.
More information about the Digitalmars-d
mailing list