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 Ross Bencina once stated:
> On 13/06/2014 4:13 PM, Thomas Jericke wrote:
> >>I'll leave it to others to determine whether using string literals in
> >>an interface is ever good style.
> >>
> >>Ross.
> >>
> >>
> >Show me a Lua API that doesn't use string literals.
> >
> >local myLib = require "MyLib" -- Oops a string literal
> >myLib.myFunction()
> >-- which is syntactic sugar for:
> >myLib["myFunction"]() -- Oops, another one.
> >
> >So without sting literals, you cannot use globals, require, access table
> >elements of type string.
> 
> You're intentionally twisting my words.
> 
> It's one thing to be able to use a string literal, quite enough to 
> require its use in an interface.
> 
> We're not talking about module or function names here, we're talking 
> about constants that are usually integers.

  Do you mean like:

	org.conman.syslog('debug',"We have reached here")
	-- 'debug' being LOG_DEBUG

or

	magic = org.conman.fsys.magic('mime','debug')
	-- flags to magic_open()
	-- MAGIC_MIME and MAGIC_DEBUG

or

	addr = org.conman.net.address('127.0.0.1','tcp','www')
	-- 'tcp' and 'www' are integer constants

or

	sock = org.conman.net.socket('ip','tcp')
	-- same for 'ip' and 'tcp' here too!

or

	sock.reuseaddr = true 
	-- really SOL_SOCKET and SO_REUSEADDR in one
	-- hidden call to setsockopt().

or 

	org.conman.process.limits.soft.core = "20m" 
	-- the integer constant here is RLIMIT_CORE
	-- to setrlimit() way behind the scenes,
	-- which, by the way, we're limited to 20 
	-- megabytes

  -spc (I tend to use string literals quite a bit ... )