[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Autolocals?
- From: Mark Hamburg <mhamburg@...>
- Date: Sat, 22 Mar 2008 00:08:11 -0700
on 3/21/08 8:17 PM, David Manura at firstname.lastname@example.org wrote:
> local Corge = require 'qux.quux.Corge'
> local foo = Corge.foo
> local bar = Corge.bar
> local baz = Corge.baz
> There can, however, be an advantage in removing some or all of the last three
> lines and, for example, referencing "Corge.foo" rather than "foo" in the code
> since the prefix "Corge." indicates explicitly where the function "foo" comes
> from, and the Hungarian-ish prefix makes obvious the fact that "foo" is
> to the current module. The "local foo = Corge.foo" is called a "static
> in a some other languages and its use is recommended only sparingly.
When used frequently, however, it can be a performance win since it
eliminates a table lookup. I've started to use the convention:
local Corge_foo = Corge.foo