Extended Type Design.

Deewiant deewiant.doesnotlike.spam at gmail.com
Fri Mar 16 11:31:27 PDT 2007


Andrei Alexandrescu (See Website For Email) wrote:
> Deewiant wrote:
>> The problem with "super const" is that "super" modifies the other keyword, 
>> "const", instead of saying something about the 
>> expression/statement/whatever (in this case, the type). Even "static", in
>> all its horror, can be seen as specifying one of "module-level" or
>> "compile-time". The other keywords mentioned above use their English
>> meaning as such an explanation, and so can be understood without too much
>> thought. "super const" would make "super" another "static": lacking
>> context, you can't be sure about about even the general meaning, let alone
>> the one in a specific instance.
>> 
>> Upon reflection it may be moot, since one probably rarely cares about 
>> keywords' meanings without context, but I'm sure some psychologist could
>> come up with something about intuitiveness which affects coding speed, or
>> whatever.
> 
> Working in NLP myself, I totally disagree. Natural language is rife with 
> homonimy and synonimy, and we're all very, very happy with that. But in this
> case we don't even have to go that far: "super" is an adjective meaning
> primarily "of high grade or quality" and qualifies a noun. If there's no
> noun, you don't know what is "of high grade or quality". It's a fact, and we
> don't even blink.

Oh, I didn't say I was of that opinion myself. In fact, I have a tendency to
disagree with psychology in general. <g> You're right and that's good a point.

> The reality behind super const is that it expresses a stronger form of const.
> It makes a lot of sense if I dub it "super const" in natural language, to
> express it in the same way in the programming language. I thought that that's
> too verbose and devised "const!" as a shortcut (again with obvious
> conotations in natural language), but I'm thinking of dropping it and let
> type inference add "super" to "const" whenever it can. That should ensure
> exactness of the type system without verbosity in source code.

"const!" has the advantage of being one word, but not really a new keyword.
"super const" is two words. I still can't really express why I see that as a bad
thing, but it _is_ better than adding a new keyword like "superconst" (or
"keepyourgrubbyhandsoff"). I wouldn't be opposed to something like "readonly"
though. Maybe I've just been coding too much Java recently: if I have to write
"private final static double" much more I'm going to puke. <g>

It's largely a question of what one's used to. Elsewhere in the thread the fact
that some languages have "elsif" or "elif" or equivalent instead of "else if"
was mentioned. I don't really see much of a difference, except that "elif" takes
a bit too long to process for me since the "el" -> "else" relation isn't
intuitive. But, just like an eventual "super const" (and the current "static"),
coding enough in a language with such will make it intuitive to me, and I won't
complain (much).

In general, I do agree with your view, found elsewhere in the thread, that using
existing keywords is best. That, or constructs like "scope (success)" where
success isn't a keyword. I'm just currently a bit repelled by the pair "super
const".

-- 
Remove ".doesnotlike.spam" from the mail address.



More information about the Digitalmars-d mailing list