New syntax for comma expression
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Thu Nov 21 21:42:18 UTC 2024
On 22/11/2024 6:56 AM, Nick Treleaven wrote:
> Maybe:
>
> |(){ class __anonclass1 : BaseClassList { void* this; } return new
> __anonclass1 args; }() |
>
> Could that work correctly with the context pointer?
Context pointer is irrelevant, it won't work.
```d
bool b;
auto v = b ? (
new class LeClass, LeInterface {}
) : (
new class LeClass, LeInterface {}
);
```
```
bool b = false;
LeClass v = b ? LeClass, LeInterface
{
void* this;
@system this()
{
super.this();
return this;
}
}
, new __anonclass2 : (LeClass, LeInterface
{
void* this;
@system this()
{
super.this();
return this;
}
}
, new __anonclass3);
```
The joys of expressions being a tree.
> Otherwise to generally fix it, there would need to be a way of declaring
> inline types in an expression. (We also might want inline template syntax).
The only type we need to declare inline is classes, as far as I'm aware,
which I did add to the grammar (but may have forgotten the class name
identifier *sigh*).
More information about the dip.ideas
mailing list