binary dot assignment

IchorDev zxinsworld at gmail.com
Tue Jan 21 20:55:34 UTC 2025


On Monday, 30 December 2024 at 21:33:58 UTC, Basile B. wrote:
> If you look long enough at some code you'll see patterns like
>
> ```d
> a = a.b;
> ```
>
> this pattern strangely looks like binary assignment operators
>
> ```d
> a = a + b;
> ```
>
> which can be rewritten as
>
> ```d
> a += b;
> ```
>
> In the same fashion we could have
>
> ```d
> a .= b;
> ```
>
> The point is to evaluate te left hand side only once.

It’s a nice idea but it doesn’t help with the similar and perhaps 
more commonly used pattern `slice = slice[1..$]`. Is there any 
way we could redesign the syntax so it works for any case of 
`Identifier = Identifier Expression`?


More information about the dip.ideas mailing list