|
On 9/29/2010 2:39 PM, Peter Sommerfeld wrote:
Am 29.09.2010, 22:27 Uhr, schrieb Christopher Eykamp <chris@eykamp.com>:On 9/29/2010 12:19 PM, Peter Sommerfeld wrote: He wants to unify two confusingly similar concepts to reduce common mistakes and errors, and I do too.There are no confusing similar concepts. Dot is "get value" and colon is "call". Easy to grasp, isn't it? Anyway, I won't argue anymore, may be a matter of taste...
I agree with Christopher here, and disagree that it's just a matter of taste.
When you pull in a library, you (frequently) get a table with functions. So calling one of those functions is (typically) done with:
t.foo(); But if you have an "object", you need to call the function with t:foo();...unless it's been bound with coroutines, or by using the __call trick, at which point you're back to
t.foo();There are no simple "call" vs "get value" semantics here; either can work, depending on the situation. Frankly that's a really poor UI design. Saying that you need to understand what's going on in order to use Lua is counterproductive (and needlessly insulting, since the OP obviously DID understand the distinction), especially since Lua is frequently used as a scripting language for non-professional-programmers (who WOULDN'T understand). Even though I know exactly what . and : mean, I still make the mistake more often than I'd like to admit, and I've been using Lua for years professionally. It's a classic PITA problem, and it would be awesome to make it go away.
The response of "get used to it" (AKA RTFM) is a classic apologist response for a bad UI, when the correct response to a bad UI is to fix the UI, not to make people try harder to use it "correctly". Most of us would still have a flashing 12:00 on our VCRs if we listened to the engineers who said that people just need to learn how to program it -- yes, anyone on this list COULD figure out how to program an old VCR, but it was a PITA, and after the first power failure it'd likely stay flashing.
Throwing a blanket on a solution just because you've gotten used to dealing with the problem is rarely the right answer. The OOBit suggestion (if it can be accomplished without hurting performance in the normal case) is a valid one, and merits serious consideration. And it wouldn't even cause you to have to change any of your usage, if it's done right. I'd say it's the definition of a good Lua enhancement: It should be a very low-impact/minimal side-effect set of changes, if done well.
Why do I care? I could just patch my distribution, right? No. I use LuaJIT; if I can't at least convince Mike Pall that it's an important feature, then I don't get to use it. Unless I want to try to rewrite the patch for LuaJIT, which doesn't seem like fun to me. And frankly I want to be presenting the default distribution to my users, not some hacked-up personalized version, because the more changes you make the fewer existing developers will be able to use it.
My 2 cents. Tim