Programming in D, page 306. opAssign to return const ref

monkyyy crazymonkyyy at gmail.com
Fri Feb 13 22:46:27 UTC 2026


On Friday, 13 February 2026 at 21:43:58 UTC, Ali Çehreli wrote:
> I definitely do not believe in immutable data structures.

> As a general rule, prefer immutable variables over mutable 
> ones. - https://ddili.org/ders/d.en/const_and_immutable.html

> When expectations are laid out explicitly by unit tests and 
> contracts, functions that are initially correct have a greater 
> chance of staying correct. I recommend that you take full 
> advantage of any feature that improves program correctness. - 
> https://ddili.org/ders/d.en/contracts.html

Have you had a change of heart on the subject?

>> either make a linked list or a handle of some kind.
> It's not clear who you are imperating with "make" or "handle" 
> but if it's me, then you may delude as much as you can but I 
> will not "make" nor "handle" whatever you are talking about.

a `handle` is something returned from an opIndex or a `&` that is 
a fake reference, to simulate value schematics, or whatever.

A linked list or handle would be capable of being returned as a 
ref despite being const or immutable. If brother bill wants to 
have something that const-ref opIndex-return, he would have to 
pick a data structure that isnt plain-old-data.

> And try waking up without hate some days.

Moralizing emotions doesnt work.


More information about the Digitalmars-d-learn mailing list