|
On 15/06/2011 11.36, Jerome Vuarand wrote:
2011/6/15 Miles Bader<miles@gnu.org>:"Joseph Manning"<manning@cs.ucc.ie> writes:The whole point here is to use a keyword. That keyword does not need to be the actual word "label". Alternatives include "spot", "point", "place", "target", "location", "destination", ... No doubt any choice could cause breakage for *some* existing programs, but it's a matter of the best *overall* way forward for Lua users.Why do you think a keyword would be better? AFAICS, a keyword would be worse: besides the obvious problem of messing up some peoples' programs, it would make labels significantly less visible (no, highlighting by editors isn't sufficient), and we _want_ labels to be highly visible.That "we" is not everybody. I for one don't want labels to be more visibel than other statements. The simple fact that they are usually indented differently makes them stand out, and an all lowercase short keyword is much more comfortable to read to some of us than an @.Even though Lua uses keywords in many places, it's certainly not necessary that it use keywords for _everything_.It's not necessary, but IMHO consistency makes the language elegant.
Sorry, but I don't agree.Labels IMO should be really highly visible. Elegance shouldn't hamper readability.
Labels are not intended as a mechanism to be used liberally, otherwise we really risk going back to the "harmful goto thing" and turn Lua in a sort of high level assembler (spaghetti code warning!).
I think labels and gotos should be used only for special purpose needs. Those that cannot (or are too difficult/ugly to) be coped with otherwise: automatic code generation, breaking out from nested loops, continue statement replacement (if refactoring code with usual constructs doesn't make it more readable/maintainable).
What's the use of an elegant label keyword if then we are forced to stick a comment beside it to warn against possible abuse/errors? Much better have @MyLabel: or $$Mylabel$$ or ::MyLabel:: or [:Mylabel:] (or whatever is most readable and eye-catching) standing out and yelling "BEWARE!" by itself.
Moreover, making a label ugly _is_ consistent with other ugly things in Lua, such as _ENV. It would be more elegant to have a new keyword even for that, say an "environment ... end" block, but the authors chose to make that ugly to prevent abuse and to visually give a warning to the code reader.
-- Lorenzo