float init 0 request
Alexandru Ermicioi
alexandru.ermicioi at gmail.com
Sat Aug 22 10:15:29 UTC 2026
On Friday, 21 August 2026 at 20:54:25 UTC, Mindy Batek (0xEAB)
wrote:
> On Friday, 14 August 2026 at 17:26:04 UTC, Walter Bright wrote:
>> It's a small point, but D is an elegant language, and
>> requiring people to write smelly code is not elegant.
>
> I suppose that should make us rethink transitive `const`, too.
> Currently, there’s a hole in D’s expressiveness with regard to
> *mutable* variables holding values of `const` types.
>
>
> ```d
> int foo() const
> {
> for (auto next = this.next; next !is null; next = next.next)
> // Error: cannot modify `const` expression `next`
> {
> // […]
> ```
>
> … has to be rewritten to the not-so-elegant …
>
> ```d
> int foo() const
> {
> for (auto next = (() @trusted => cast() this.next)(); next !is
> null; next = next.next)
> {
> // […]
> ```
Maybe, for should allow in third section redeclaration of the
variable? That way, redeclared variable is not reassigned but
actually a new variable, thus preserving the const rules.
More information about the Digitalmars-d
mailing list