lua-users home
lua-l archive

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


I started poking around in the Lua code to see how "." and ":" are implemented internally, and I am now wondering what the rationale behind having these two operators is. Why not have "." do the same thing that ":" does (allowing us to eliminate ":" at some future point)? I can see that having two operators allows tiny efficiencies (don't need to create and dispose of the local variable self), but also adds complexity and leads to user error until users are fully trained up on how these operators work.

It seems to me that it would be worth a tiny machine inefficiency to get rid of a real human inefficiency. Am I missing something obvious?

Chris

PS I know the language won't change because of this email, but I would like to understand the issues better.



On 2/17/2010 7:12 AM, Phoenix Sol wrote:
On Feb 16, 2010, at 6:05 PM, Christopher Eykamp <chris@eykamp.com> wrote:

When the scripters should be writing:

bot:setAngle(angle)

they often write:

bot.setAngle(angle)

I think the real issue is that your scripters just aren't beaten enough.

Beat them like you mean business, and teach them to associate the colon with 'self':

SELF! COLON! (( WHACK! ))

This could possibly be supplemented with some automated electroshock feedback, by testing whether the first parameter to your function is the desired userdata, and if not then calling the needed routine (with an X10 interface for example) to deliver the necessary electric current to the poor tester. If said tester is not the responsible script author, he should be supplied with the script author's name and a large rubber bludgeon to complete the feedback loop.

You should, of course, avoid hiring masochists (which may be increasingly challenging).

See the whitepaper for details.