lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Wed, 3 Feb 2010 19:15:48 +0000
Tony Finch <dot@dotat.at> wrote:

> On Wed, 3 Feb 2010, steve donovan wrote:
> >
> > Adding a new keyword once in a blue moon is not a great disaster, if
> > it gives us such excellent convenience.
> 
> Douglas Crockford argues that programming languages should not have
> reserved words. His idea is that if you happen to give a variable
> the same name as a keyword, then that keyword becomes unusable in the
> variable's lexical scope. If you use a keyword in a given scope then you
> cannot subsequently declare a variable with the same name.
> 
> If you follow Crockford then adding keywords becomes much easier.
> 
> See the last couple of paragraphs in the "scope" section of
> http://javascript.crockford.com/tdop/tdop.html
> 
> Tony.

Quote:
"We need a policy for reserved words. In some languages, words that are used structurally (such as if) are reserved and cannot be used as variable names. The flexibility of our parser allows us to have a more useful policy. For example, we can say that in any function, any name may be used as a structure word or as a variable, but not as both. We will reserve words locally only after they are used as reserved words. This makes things better for the language designer because adding new structure words to the language will not break existing programs, and it makes things better for programmers because they are not hampered by irrelevant restrictions on the use of names."

I like this policy very much. But I'm not sure it's manageable for a language like Lua where globals and so prominent (and even the default). I imagine this very well in a language where there are no globals at all (only locals and struct/object attributes).

Denis
________________________________

la vita e estrany

http://spir.wikidot.com/