Good Morning Everyone,
I recently found myself wanting to introduce a bunch of member variables into the scope of the function I was currently working on.
Of course D has a nice way to do that; The with
statement.
so
struct S { int x; }
int fn()
{
S s;
with(s)
{
x = 12;
return x;
}
}
this code works but it forces another level of indentation which makes it a little ugly.
So I did a small patch to my local version of dmd.
And now this works:
struct S { int x; }
int fn()
{
S s;
with(s):
x = 12;
return x;
}
It is a really simple patch and I think it's worthwhile to have this in the main language.