lua-users home
lua-l archive

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


Hi Anders,

On Feb 24, 2014, at 10:55 AM, Anders Petersson <andpet@gmail.com> wrote:
> Interesting how 'require' can change the behavior of standard functions. Will look closer into stdlib.

This is easy to do in Lua, although (even in the case of stdlib) probably not a good idea for a large project that needs to maintain good separation of concerns.  The trick is simply to override the core `tostring` function, which the interpreter calls on the argument to an `=` call from the interactive command line.

Stdlib uses a few other dirty tricks, albeit to make using Lua much more convenient.  But, I'm slowly re-engineering them to be cleaner between releases, and already it's much cleaner than it was this time last year, with only `require "std"` and a couple of other outliers changing the core functionality of Lua in the current incarnation.

Cheers,
-- 
Gary V. Vaughan (gary AT vaughan DOT pe)

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail