lua-users home
lua-l archive

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


Don't forget we would end up with very ruby-like method chaining, for methods that don't require any additional args...

> monster:selectpartymember:takedamagewithresistance(monster:selectspell:randomdamageval)

I'm not arguing the merit of this one way or the other; just pointing out it's a consequence for calling methods like this.

On Fri, Jun 12, 2015 at 6:29 AM, steve donovan <steve.j.donovan@gmail.com> wrote:
On Fri, Jun 12, 2015 at 2:05 PM, Thomas Jericke <tjericke@indel.ch> wrote:
> Essentially, once you allow metamethods to be defined you can't recognize
> calls any more by looking at the code.

Ah, but metamethods are not just any implicit function call.  We could
make 't.a = 0' do anything, like launch a rocket, but generally this
is an abuse. It really is the kind of thing that gave C++ a bad name.

So, I'd also vote for keeping function call syntax straightforward -
we know the rules, no need for new ones.  Leaving out () feels like a
very Pascal-like thing - I remember Bertrand Meyer defending it in
Eiffel - he reckoned that the user of an object's field need not know
_how_ it is implemented.  So read-only properties, basically.

Moonscript idiom is to use ! instead of (), which at least makes the
call obvious.  But I don't think it adds much to the party here - the
cool Moonscript function call feature is that the effective precedence
of the call operator is very low, so you often don't need parens at
all.  Nice for interactive DSLs.




--
Brigham Toskin