D1.5 anyone?

IGotD- nise at nise.com
Fri Apr 14 21:32:21 UTC 2023


On Friday, 14 April 2023 at 18:33:50 UTC, ryuukk_ wrote:
>
> The only reason i personally use ``const`` is to be able to 
> pass things either by reference or to avoid GC allocation

I think that const as function parameter designation is a mistake 
in computer science history. Swift has done this more right. ALL 
parameters are immutable, if you write to a parameter then the 
compiler will create a copy of it on the callee stack frame (not 
caller stack frame as often today, but it is also a definition 
who it belongs to).

The copy parameter by default is one of these mysteries to me 
that is adopted by many languages.

I actually think that writes to parameters (that are not 
references) should be disallowed. If you want to write to it you 
should make a copy of it by assignment (ie. manually copy it).


More information about the Digitalmars-d mailing list