[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Overdoing 'local' (Was: [ANN] luaposix 33.4.0 released)
- From: Dirk Laurie <dirk.laurie@...>
- Date: Sun, 28 Feb 2016 07:42:28 +0200
2016-02-28 1:02 GMT+02:00 Sean Conner <sean@conman.org>:
> 2) But it does mean that when I'm doing a heavy POSIX program, it's a lot
> of:
>
> local process = require "org.conman.process" -- fork(), etc
> local signal = require "org.conman.signal" -- signals
> local getopt = require "org.conman.getopt" -- parse command line
> local syslog = require "org.conman.syslog" -- syslog
> local errno = require "org.conman.errno" -- defines for errors
> local fsys = require "org.conman.fsys" -- file system calls
> local net = require "org.conman.net" -- network code
> local sys = require "org.conman.sys" -- um ... [2]
This can obviously be done in a loop, or by a single function call
import"process signal getopt syslog errno fsys net sys"
if you did not 'local' all those names. After all, you are probably
going to follow all that with `local fork = process.fork` etc for the
particular functions you actually need.
I wonder if the dogma of "Don't pollute the global namespace"
is not being clung to too religiously. In this sort of situation, where
the names are those of near-standard libraries (at least within
conman.org), I think there is something to be said for keeping them
in _ENV.