[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Let's talk about __call
- From: Sean Conner <sean@...>
- Date: Fri, 22 Jul 2016 00:43:32 -0400
It was thus said that the Great Patrick Donnelly once stated:
> For some slightly early "It's Friday" discussion, what do you use the
> __call metamethod for? Discuss your favorite hacks, strange problems
> solved, code golf hole-in-ones, etc.
I used __call in my syslog module [1]. I got tired of
syslog.log('debug',"this is a test message")
which I felt redundant. Sure, I could have just returned the function as
the module, but then I would lose syslog.open() (to set the identity of the
program and the facility to log to).
I've also used it for two other modules where the module names are
basically the same as the function name (iconv [2], magic [3] and uuid [4]
are some other examples). I don't use it often, but when I do, I like it.
-spc
[1] https://github.com/spc476/lua-conmanorg/blob/master/src/syslog.c
[2] https://github.com/spc476/lua-conmanorg/blob/master/src/iconv.c
[3] https://github.com/spc476/lua-conmanorg/blob/master/src/magic.c
[4] https://github.com/spc476/SPCUUID