[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Metatables for functions
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 25 Mar 2009 10:35:18 -0300
> Is there any reason not to support metatables for functions? Obviously
> the __call metamethod is superfluous for functions, but I could imagine
> uses for other cases. In particular, one could then consider using
> operators to combine functions. Since these cases would currently just
> end in an error or in the generic metatable for functions and given that
> functions aren't particularly tiny objects to begin with, the cost seems
> like it ought to be small.
>
> I'll have to think about whether this would be truly useful or just
> interesting, but I was wondering whether there is a reason why it would
> be a bad idea.
The main problem is that function metatables are global. So, if a
library defines * as function composition (for instance), all other
libraries (and the main application) cannot use * for other purposes.
-- Roberto