equivariant functions
Robert Fraser
fraserofthenight at gmail.com
Mon Oct 13 17:31:09 PDT 2008
Andrei Alexandrescu wrote:
> Jason House wrote:
>> Andrei Alexandrescu Wrote:
>>
>>> ore-sama wrote:
>>>> Andrei Alexandrescu Wrote:
>>>>
>>>>> typeof(s) stripl(const(char)[] s);
>>>>>
>>>>> This signature states that it returns the same type as an
>>>>> argument. I propose that that pattern means stripl can accept
>>>>> _any_ subtype of const(char)[] and return that exact type.
>>>>> Inside the function, however, the type of s is the type
>>>>> declared, thus restricting its use.
>>>> this conflicts with current definition of typeof. Currently
>>>> typeof(s) stripl(const(char)[] s); should be interpreted exactly
>>>> as const(char)[] stripl(const(char)[] s); it's unclear that
>>>> typeof here gets type of actual argument rather than parameter.
>>>> Currently typeof applies to parameter.
>>> That is correct.
>>>
>>> Andrei
>>
>> I've never understood the reuse of keywords for new meanings. I much
>> prefer new keywords for new concepts.
>
> Even in natural language identical words are reused for various
> different meanings. This suggests that people would not feel comfortable
> with a very large vocabulary. The size of vocabularies varies
> dramatically, but if you look closer you'll see that languages with
> large vocabularies tend to have simpler grammars, suggesting that a
> language's overall complexity is a constant-sum game.
>
> In programming languages growing the vocabulary indiscriminately is
> worse because it chews into the vocabulary available to user-defined
> symbols.
>
> Also, whenever a feature is to be integrated into the language, it is
> preferable if possible to integrate it under an existing concept instead
> of "allocating" a new concept to it.
>
>
> Andrei
Just read this paper by Herb Sutter last night:
http://www.gotw.ca/publications/C++CLIRationale.pdf
In particular, the Bjarne Stroustrup quote is quite poignant:
""
My experience is that people are addicted to keywords for introducing
concepts to the point where a concept that doesn’t have its own
keyword is surprisingly hard to teach. This effect is more important
and deep-rooted than people’s vocally expressed dislike for new
keywords. Given a choice and time to consider, people invariably choose
the new keyword over a clever workaround.
— B. Stroustrup (D&E, p. 119)
""
And Herb himself:
""
When a language feature is necessary, programmers strongly
prefer keywords. Normally, all C++ keywords are also re-
served words, and taking a new one would break code that
is already using that word as an identifier (e.g., as a type or
variable name).
C++/CLI avoids adding reserved words so as to preserve the
goal of having pure extensions, but it also recognizes that
programmers expect keywords. C++/CLI balances these re-
quirements by adding keywords where most are not reserved
words and so do not conflict with user identifiers.
""
More information about the Digitalmars-d
mailing list