Thread overview
[Issue 24654] Parameters in contracts should be `const`
3 days ago
Bolpat
3 days ago
Nick Treleaven
3 days ago
Bolpat
3 days ago
Nick Treleaven
3 days ago
https://issues.dlang.org/show_bug.cgi?id=24654

Bolpat <qs.il.paperinik@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |qs.il.paperinik@gmail.com

--
3 days ago
https://issues.dlang.org/show_bug.cgi?id=24654

Nick Treleaven <nick@geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nick@geany.org

--- Comment #1 from Nick Treleaven <nick@geany.org> ---
The problem with requiring const for out parameters is that the return type might not convert to const if it has mutable indirections.

--
3 days ago
https://issues.dlang.org/show_bug.cgi?id=24654

--- Comment #2 from Bolpat <qs.il.paperinik@gmail.com> ---
(In reply to Nick Treleaven from comment #1)
> The problem with requiring const for out parameters is that the return type might not convert to const if it has mutable indirections.

Of course they convert to const. They might not be copyable to initialize a const variable, but it shouldn't be copied, so I don't see the problem. In particular, for parameters that already have a definite address and thus are trivial to reference.

--
3 days ago
https://issues.dlang.org/show_bug.cgi?id=24654

--- Comment #3 from Nick Treleaven <nick@geany.org> ---
> Of course they convert to const

Sorry, yes. The Issue 24565 problem was calling methods not annotated with const. So if this was implemented, it should be done in an edition to avoid breaking working correct code.

--