On Saturday, 20 January 2024 at 09:00:22 UTC, Danilo wrote:
>I thought this should easily work, but I was wrong:
[...]
Those actually would not be aliases but more "parameter-less expression macros".
In order to make those aliases working, it would be necessary to monomorphize and recontextualize the source expression for each use:
struct Vec3 {
Vec2 v;
alias x = v.x; // cannot contextualize, no "this"
}
Vec3 v1, v2;
v1.x = 0; // -> create v1.v.x, contextualize
v2.x = 0; // cannot reuse, "this" has changed
// you have to copy and recontextualize
So you think that it's nice but it's actually more like a mixin.
An old PR would have allowed that but quickly a reviewer noticed that these are not classic aliases, but something more complex, bringing possible issues.
On top of that, as there's no "scope", contextualization can lead to ambiguous situations, reproducing the problem of what is called "unhygienic macros"... although for dot chains, that should not happen too much 🤞😐🤞.