lua-users home
lua-l archive

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


Mark Hamburg wrote:

> Okay. "_" is a good example. I'm not as squeamish about
> treating it as a special case, however, if it's the
> primary reason to use the facility.

This may be no surprise to you, but I think what Rici was
pointing out was that your second example actually
subdivides into two examples.  (In other words, the
underscore identifier itself doesn't really enter into it.)
So here are all three:

  -- #1 -- One scope with duplicate identifiers (or at least
  -- there's only one 'local' keyword, but I don't know how
  -- that's dealt with internally):
  do
    local foo, foo, bar = somethingorother() -- Each foo is
      -- a junk variable.
  end

  -- #2 -- "Improperly" nested scopes (they begin in
  -- different places, but end in the same place -- no big
  -- deal except for the duplicate identifiers):
  do
    local foo = somethingorother()
    local foo = somethingelse()
  end

  -- #3 -- Properly nested scopes (they end in different
  -- places):
  do
    local foo = somethingorother()
    do
      local foo = somethingelse()
    end
  end

I would not mind too much if #2 was prohibited; I can't
think of a practical use for it.  However, allowing it does
seem more orthogonal.

On the other hand, I use both #1 and #3 and would not like
either of them to be prohibited.

-- 
Aaron