lua-users home
lua-l archive

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


> About 3 months ago, Xavier suggested extending Peter Shook's (in) syntax to
> allow "namelist 'in' expr" anywhere the parser might otherwise accept a
> standard exprlist.

In C, where assignment statements are also expressions, it is very
useful to name subexpressions (e.g f(x = expr) ) to avoid evaluating
anything twice. 

In something like

for _,record in ipairs(list) do
  display(name,adr,email,job in record)  -------- (*)
end

we would have an instance of a multi-assignment being used as an 
expressionlist. I thought I would nudge the thread toward this
slightly more general aspect of the matter.

The form in regular use in RiscLua is

for _,record in ipairs(list) do
 local name,adr,email,job in record
 display(name,adr,email,job)
end

which might be seen as a lambda-lifting of (*). I have a vague recollection
from the distant past of work by Andy Pitts ( http://www.cl.cam.ac.uk/_amp12/ ) 
on extensions of the lambda-calculus that model naming and assignment; but I am 
not sure to what extent stuff at this level of abstraction can useful for Lua. 
 
-- 
Gavin Wraith (gavin@wra1th.plus.com)
Home page: http://www.wra1th.plus.com/