Weird const behavior

Marko marko at gmail.com
Thu Dec 20 14:49:10 UTC 2018


On Thursday, 20 December 2018 at 02:05:53 UTC, Adam D. Ruppe 
wrote:
> On Thursday, 20 December 2018 at 01:37:59 UTC, Simón Oroño 
> wrote:
>> The only difference (code-wise) is the `const` keyword. I've 
>> tried with both `ldc` and `dmd` with same result. Why is the 
>> output different when the variable is `const`?
>
> A const range cannot be iterated by a generic template (without 
> additional work, at least), so writeln just sees it as a blob 
> instead of something it can loop over.

I'm not the OP but I'd like to understand this:

When he is comparing "a == b" it returns true, but then it 
diverges on the usability.

So a == b compares just values without types?

But is this right? I mean if they are equal shouldn't they have 
the same behavior?

Marko.


More information about the Digitalmars-d-learn mailing list