head const (again), but for free?

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Wed Jan 13 20:17:16 UTC 2021


On Wednesday, 13 January 2021 at 19:42:14 UTC, Meta wrote:
> Is there even any value to having head-const in a language? As 
> I think Walter has said before, it's basically just 
> documentation/convention in C++. I can see the value in 
> head-immutable, in terms of type system guarantees, but not 
> head-const.

Well, yes, but in the case of C++ there are no guarantees, so it 
is for catching bugs, parametric typing and overloading. I don't 
think it brings optimization benefits?

In the case of head-immutable it allows caching of calculations 
across FFI calls and assembly code for instance. With transitive 
immutable much less data can be protected.



More information about the Digitalmars-d mailing list