On Mon, 30 Jul 2012 12:14:05 +1200, "Pete Dashwood"
<
dash...@removethis.enternet.co.nz> wrote:
>Richard Maine wrote:
>> Pete Dashwood <
dash...@removethis.enternet.co.nz> wrote:
>>
>>> Robin Vowels wrote:
>>
>>>> When new keywords are introduced into the language, reserved words
>>>> cause some existing programs to fail.
>>
>>> If you use a proper Editor with Intellisense (Visual Studio/Eclipse
>>> are just 2 very good ones...) you will NEVER use a reserved word
>>> improperly so that argument carries no weight for me.
>>
>> That might be so for limitted values of "never". It won't help the
>> case where you have existing code and have to deal with a newer
>> version of the language that adds new reserved words.
>
>I take your point. Existing code MIGHT contain something which has now
>become a reserved word.
>
>But the first time you compile it, it will fail and that should prompt you
>to run a Global edit.
I'm not going to comment about how valid the concern actually is, but
the Cobol-85 standard was held up for years over that issue, as
several big participants wanted to avoid new reserved words. The
final (unhappy) compromise was requiring a way to disable reserved
words on a program-by-program basis.
Newer versions of C, for example, have gone out of their way to
minimize the problem by putting most of the new keywords in the
reserved part of the name space (thus we have _Bool and _Complex in
C99), or overload preexisting keywords (*another* new meaning for
"static", new meanings for "auto"). Still some keywords were deemed
important enough to allow into the normal name space ("inline" and
"restrict" were added in C99, although all of the new C11 keywords
have the underscore prefix).
Cobol magnifies the problem with an extremely large list of reserved
words, including many you might reasonably want to use as a name. And
that list has grown substantially over time. By comparison, other
than the two additions in C99, C has not added any keywords in the
public name space since the original 32 defined in C89.
Trivially, make user defined names and "reserved words" syntactically
distinct. "add #var1 to #var2". (Hideous, but it works).
Or consider old-style Basic where all the "verbs" started at the
beginning of a line, plus all variables were one or two characters
long, the second character always being a digit (so no legal variable
names could be the same string as a keyword). Likewise most
assemblers don't prevent you from using most mnemonics as labels
(since they're syntactically distinct). Or something like Forth where
almost all the words can be redefined.
I'm not sure a language designed to have no reserved words is a good
idea, but it's not a big trick to pull off.