lua-users home
lua-l archive

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


[It's a shame that declaring blocks that limit temporary variable
scope isn't more popular, perhaps the extra two lines and bonus
character in 'end' bothers OCD people like myself.

I've started writing do-blocks structured like the following:

  local draw_list do

    <other locals and definitions>

    draw_list= function() 
      <drawing code> 
    end
  end

The convention here is that the do block acts more or less like a 1 time function call who's purpose is to define the local(s) on the line where it starts. Feels like a useful pattern when I have a bunch of function definitions that all want their own copies of common variable names like 'x','y' etc.

-Sven