lua-users home
lua-l archive

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


It was thus said that the Great Rena once stated:
> On 2013-11-26 2:28 PM, "Sean Conner" <sean@conman.org> wrote:
> >
> >   I took a look, and there's still an issue.  Take syslog for example (as
> > this is something I have looked into a bit more than the UUID libraries).
> > All the syslog modules do support a "log()" function.  So far, so good.
> > But, one module uses:
> >
> >         syslog.log(syslog.LOG_ERR,string.format("warning: x=%d",d))
> >
> > another one:
> >
> >         syslog.log('LOG_ERR',string.format("warning: x=%d",d))
> >
> > And a third one:
> >
> >         syslog.log('err',string.format("warning: x=%d",d))
> >
> > And a forth one:
> >
> >         syslog.log('error',"warning: x=%d",d)
> 
> And all of them seem to be mostly mechanical translations of the underlying
> C function, and don't use a nice Lua-friendly API like:
> syslog.log.error("problem with %s", what)

  Well, the fourth one can also be written [1]:

	syslog('error',"warning: x=%d",d)

  Now, as to the difference between:

	syslog('error',"warning: x=%d",d)

and

	syslog.error("warning: x=%d",d)

is a matter of taste.  I prefer the former, as it's actually less code (one
function vs. eight).  The later seems popular with the OO crowd (in my
opinion).  

  -spc

[1]	https://github.com/spc476/lua-conmanorg/blob/master/src/syslog.c