Thread overview
[Issue 24654] Parameters in contracts should be `const`
Jul 09
Bolpat
Jul 09
Bolpat
July 09
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

--
July 09
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.

--
July 09
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.

--
July 09
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.

--