D const design rationale
Bruno Medeiros
brunodomedeiros+spam at com.gmail
Sat Jun 23 10:49:00 PDT 2007
Bill Baxter wrote:
> Walter Bright wrote:
>> http://www.digitalmars.com/d/const.html
> """
> But there is a need for a constant declaration referencing a mutable type.
> """
>
> Also in the discussion of final, the word that always comes to my mind
> is 'binding'. It's the binding of the variable name to its value that's
> final. You say, "A final declaration, once it is set by its
> initializer or constructor, cannot ever change its value for its
> lifetime." which to me is kind of vague. I not sure what it means that
> "a declaration cannot change its value". Does a declaration even have a
> value? "I'm setting this declaration to 5" -- seems like unusual
> terminology to me.
>
>
I highly agree. That terminology usage made me grind my teeth when
reading the article! A declaration "having a value"/"referencing a
mutable type"? It's not just unusual, it's plain nonsensical!
'Binding' is better, but I'm also not 100% keen on it. I've been using
terms such as 'top-level type', and also 'immediate value'.
BTW, the 'immediate value' of a variable/expression is what I call, by
definition: the value that changes when an assignment is made to that
variable/expression.
I've found that in Walter's article, when he mentions "declaration", in
most cases he means either 'top-level type', or 'immediate value'.
--
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
More information about the Digitalmars-d
mailing list