Wishlist proposal, documenting fn arg as in or out or mod

Dom DiSc dominikus at scherkl.de
Wed Jun 21 08:51:01 UTC 2023


On Tuesday, 20 June 2023 at 20:44:42 UTC, GrimMaple wrote:

> `const ref Type` makes 0 sense, because all references are 
> `const` already (you can't change the _reference_, you can 
> change the _referenced object_). What you probably want to mean 
> is `ref const(Type)` instead, making it a const reference to a 
> const `Type`.

Oops. This is really stupid. Then you are right, it should always 
be "ref const(T)".
But I don't understand how "const ref" can mean something 
different in D, as references are NEVER writeable. This only 
uglyfies the language :-(

So the nicer syntax is simply useless and confusing?
If anything, I would propose to change that:
"const ref T" should be identical to "ref const(T)"


More information about the Digitalmars-d mailing list