March 13

On Thursday, 13 March 2025 at 12:38:51 UTC, Basile B. wrote:

>

What you want has nothing to do with the WithStatement, what you want is "inline variables", i.e a VariableDeclaration as an Expression.

Thanks for clearing that up! :) I am not a language expert so I do not know the terminology. Obviously I want something similar to what the for statement gives us - ability to initialise the variable and use it in inside the block.

March 13

On Wednesday, 12 March 2025 at 19:01:46 UTC, Dejan Lekic wrote:

>

On Wednesday, 12 March 2025 at 18:55:45 UTC, Dejan Lekic wrote:

>

the with block. Since with statement does not allow initialisation one would try:

As usual, I forgot to give an example of what I am actually asking for...

auto app = new Application();
with (auto win = new Window) { // currently not allowed
  setTitle("Example");
  setDefaultSize(200, 200);
  setChild(mainBox);
  app.addWindow(win);
}

Seems like a totally uncontroversial change to me. We already allow using a declaration in if, while, and switch statements; there's no reason with shouldn't work the same way.

March 14

On Wednesday, 12 March 2025 at 19:01:46 UTC, Dejan Lekic wrote:

>

On Wednesday, 12 March 2025 at 18:55:45 UTC, Dejan Lekic wrote:

>

the with block. Since with statement does not allow initialisation one would try:

As usual, I forgot to give an example of what I am actually asking for...

auto app = new Application();
with (auto win = new Window) { // currently not allowed
  setTitle("Example");
  setDefaultSize(200, 200);
  setChild(mainBox);
  app.addWindow(win);
}

Just to mention that there's an issue filed for this (in 2014 and duplicate in 2015):
https://github.com/dlang/dmd/issues/18890

1 2
Next ›   Last »