lua-users home
lua-l archive

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


On Mon, Oct 17, 2005 at 05:56:49PM -0500, Rici Lake wrote:
> I'm getting quite used to the run-time "warning"; it looks like this:
> 
> foo:27: attempt to call a table value

The point of the warning is to give it in advance, during the deprecation
period, before it becomes an error.  A "warning" that's put in quotes
because it's a fatal error isn't a warning.  :)

> Now, Lua has no compile-time warning mechanism, and it is not 
> particularly clear how one would even add one to the compiler (possibly 
> an optional callback function to accept warnings?), but in principle it 
> is easy enough to detect most instances of the "missing-pairs" problem 
> at compile-time: you simply check for the case in "for <varlist> in 
> <exprlist> do" where <exprlist> is a single expression which is not a 
> function call of some kind. That's an imperfect check, but it would be 
> good enough for a warning.

The case I was thinking of is

  function f(it) for x,y in it do print(x) end end
  t = { 1, 2, 3 }
  f( pairs(t) )

However, that doesn't work.  It's obvious why with a little poking.  I
keep finding Lua's multiple-results unintuitive and rather forced compared
to the rest of the language; I guess I'll get used to them eventually.

> I'm not sure why Lua deserves any more Yucking than C in this pair of 
> vaguely comparable cases, although one would certainly prefer Lua to be 
> less Yuckworthy.

A runtime warning mechanism would be Yuck, since it would mean runtime
overhead if enabled and not catch things as quickly as a compile-time
warning.  (Never mind compilation done at run-time ...)

-- 
Glenn Maynard