First draft: added with-colon statement
cookiewitch
artha at samerion.com
Sun Jan 19 14:59:30 UTC 2025
On Thursday, 16 January 2025 at 06:53:23 UTC, Walter Bright wrote:
> This was requested in the newsgroups. Adds the syntax:
>
> ```
> {
> with (E):
> statement;
> statement;
> }
> ```
>
> which is equivalent to:
>
> ```
> {
> with (E)
> {
> statement;
> statement;
> }
> }
> ```
>
> and that's all there is to it.
>
> https://github.com/dlang/dmd/pull/20715
This seems a bit inconsistent to me with current syntax; `with`
is a statement, and the colon syntax previously only worked at
declaration level. i.e.
```
void foo() {
@safe: // can't do this!
}
```
Otherwise I don't have any comments regarding this syntax, but if
we're bringing up changes to `with`, I would be interested in
`with` as an expression.
```
auto theme = with (Rule) Theme(
rule!Node(
backgroundColor = color("#123"),
textColor = color("#123"),
),
);
// as opposed to
Theme theme;
with (Rule) theme = ...;
```
More information about the dip.development
mailing list