Which language futures make D overcompicated?
Ralph Doncaster
nerdralph at github.com
Fri Feb 9 15:37:12 UTC 2018
On Friday, 9 February 2018 at 15:09:10 UTC, Mike Parker wrote:
> On Friday, 9 February 2018 at 14:59:38 UTC, Ralph Doncaster
> wrote:
>
>> const auto MAX_IN = 20;
>
> const MAX_IN = 20;
>
> The auto is superfluous and is only needed when there's no
> storage class or type.
>
>>
>> Others say to use enums. It turns out enums seems to be the
>> best, as they don't create a symbol in the object file, but
>> const auto does.
>
> If you need to take the address of a constant, use immutable or
> const (doesn't really matter, but I prefer immutable). If you
> don't need the address, use enum.
I think you are proving my point. You say there is no difference
between:
const MAX_IN = 20;
vs
immutable MAX_IN = 20;
So now I have to try both, and look at the generated code to be
sure.
p.s. I prefer const since it is easier for C/C++ coders to
understand. Using immutable invites the coder to go down the
whole rat hole of trying to understand how is it different than
const.
More information about the Digitalmars-d
mailing list