lua-users home
lua-l archive

Re: [PROPOSAL] [PATCH] simple method call

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


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.

AltStyle によって変換されたページ (->オリジナル) /