www.digitalmars.com         C & C++   DMDScript  

digitalmars.dip.ideas - binary dot assignment

reply Basile B. <b2.temp gmx.com> writes:
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.
Dec 30 2024
next sibling parent reply zjh <fqbqrr 163.com> writes:
On Monday, 30 December 2024 at 21:33:58 UTC, Basile B. wrote:
 ```d
 a .= b;
 ```
This `.` is prone to be ambiguity.
Dec 30 2024
parent Basile B. <b2.temp gmx.com> writes:
On Tuesday, 31 December 2024 at 01:18:34 UTC, zjh wrote:
 On Monday, 30 December 2024 at 21:33:58 UTC, Basile B. wrote:
 ```d
 a .= b;
 ```
This `.` is prone to be ambiguity.
`.=` would be a whole token. I already use this in styx since several monthes: ![img](https://i.imgur.com/AAKd8Vo.png)
Dec 30 2024
prev sibling parent claptrap <clap trap.com> writes:
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.
Too much syntax sugar will lead to cavities.
Jan 01