[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Operators on functions
- From: Lorenzo Donati <lorenzodonatibz@...>
- Date: Tue, 19 Nov 2013 11:34:10 +0100
On 19/11/2013 7.17, steve donovan wrote:
> On Mon, Nov 18, 2013 at 8:20 PM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
>> With the aid of debug.setmetatable it is possible to define
>> expressions involving functions.
>
> I briefly got very excited about the possibilities of doing this, and
> in fact seq.import in PL makes all functions accept seq 'methods'.
> When first experimenting with Microlight I found that composition and
> binding could be very elegantly expressed in the way you describe
> (which feels less ad-hoc than the seq hack). However, it _is_ a
> global hack.
>
> Now, if the shared metatable of functions was relative to _ENV, then
> we could have the situation that a person could organize things to
> their satisfaction within their modules, without trampling on the
> design space of other modules.
>
>
I fear that what you say is not easy without giving non-table objects
individual metatables (what would happen in your envisioned case if an
object bound to an _ENV "escapes" that env?).
Sometimes I found the idea of having individual metatables for non-table
objects very interesting for some DSL design techniques,
but I fear that it is not easy to do without sacrificing overall Lua
performance or code size (I'd like to be proven wrong, though).
-- Lorenzo
--
() ascii ribbon campaign - against html e-mail
/\ www.asciiribbon.org - against proprietary attachments