Re: equivalent of Perl's "AUTOLOAD"
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: equivalent of Perl's "AUTOLOAD"
- From: Andreas Stenius <kaos@...>
- Date: 2006年6月27日 13:36:51 +0200
Yes, you'ld want to look into the __newindex meta method.
George Jempty skrev:
Is there an equivalent of Perl's "AUTOLOAD" in Lua? Autoload is a
method that you implement that gets called when you call a method on an
object but that method name has not been defined. Somewhere in the
online Lua book regarding metatables (I just ordered a hardcopy of the
2nd edition through Amazon) I recall reading that if you call a method
that has not been named on an object in Lua, an error will be raised.
So if Lua does not have an equivalent of Perl's "AUTOLOAD", it would
seem it could be emulated when trapping this error.
Feedback will be appreciated
George