digitalmars.dip.ideas - binary dot assignment
- Basile B. (17/17) Dec 30 2024 If you look long enough at some code you'll see patterns like
- zjh (2/5) Dec 30 2024 This `.` is prone to be ambiguity.
- Basile B. (4/10) Dec 30 2024 `.=` would be a whole token. I already use this in styx since
- claptrap (2/19) Jan 01 2025 Too much syntax sugar will lead to cavities.
- IchorDev (5/22) Jan 21 2025 It’s a nice idea but it doesn’t help with the similar and perhaps
- monkyyy (6/15) Jan 21 2025 ```d
- Atila Neves (3/20) Feb 12 2025 I'm not sure `.=` (and other options?) occurs often enough for
- Walter Bright (2/3) Feb 15 2025 Yes. Need more information on how common this pattern is.
- Quirin Schroll (5/22) Feb 13 2025 It *will* fool newcomers into thinking `.` is a binary operator,
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
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
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:`.=` would be a whole token. I already use this in styx since several monthes: ```d a .= b; ```This `.` is prone to be ambiguity.
Dec 30 2024
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 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`?
Jan 21 2025
On Tuesday, 21 January 2025 at 20:55:34 UTC, IchorDev wrote:On Monday, 30 December 2024 at 21:33:58 UTC, Basile B. wrote:```d auto pop(R)(R r)=>r[1..$]; slice.=pop; ``` ?```d a .= b; ```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`?
Jan 21 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.I'm not sure `.=` (and other options?) occurs often enough for this to be worth it.
Feb 12 2025
I'm not sure `.=` (and other options?) occurs often enough for this to be worth it.Yes. Need more information on how common this pattern is. Note that the compiler doesn't evaluate the lvalue twice unless it has side effects.
Feb 15 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 *will* fool newcomers into thinking `.` is a binary operator, but it’s not. The right-hand side cannot ever be something other than an *Identifier* followed by something. I don’t think I have ever seen someone put spaces around `.` exactly because of that.
Feb 13 2025









Basile B. <b2.temp gmx.com> 