lua-users home
lua-l archive

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

Fancy syntaxes tend to improve your ability to map your own thoughts onto code, but make your code more impenetrable by anybody else. Fancy operators, with their impronouncability, associativity, commutativity, precedence, tokenization rules, and with people's overloaded prejudices about what they mean, almost always end up costing more in maintainability than they afford in expressiveness. <troll> Just look at the debacle of ">>" / "<<" overloading by C++ streams </troll>.

For this reason, new operators definition isn't consistent with Lua's design principles. I even have some reserves about user-overloading of arithmetic operators: you should only overload them with operations which respect their algebraic properties, and I don't think it should happen on anything but userdata.

Now there are reasons to play with them: first it's fun, and that's good enough a reason in some contexts. More importantly, out of wacky experiments sometimes come great ideas, worth implementing in serious languages. Think of Lisp's legacy: it's a language entirely tuned for fun and personal expressiveness, with a very bad record in terms of large-scale long-term collaboration, but half of the ideas that make modern languages productive started as Lisp macro experiments. So yeah, there's already a dialect of Lua optimized for language tinkering, and it's called Scheme ;-)

TL;DR: I might enjoy playing with mine, but not at the price of risking having to play with those of other people I didn't personally select :)