lua-users home
lua-l archive

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


On 8/16/07, David Manura <dm.lua@math2.org> wrote:
> Patrick Donnelly writes:
> > I'm curious what features people would like to see added to Lua.
>
> See http://lua-users.org/wiki/FeatureProposals .
>
> Some of my own favorites include
>
>  http://lua-users.org/wiki/ResourceAcquisitionIsInitialization
>    (RAII or scope guards to more effectively solve some cleanup problems)
>  http://lua-users.org/wiki/LuaModuleFunctionCritiqued
>    (modules should not touch global variables)
>  http://lua-users.org/wiki/StatementsInExpressions
>    (e.g. the "let" syntax)
>  http://lua-users.org/wiki/LuaVirtualization
>    (e.g. __len, __pairs, and other metamethods on tables)
>
> Possibly also: macros (in the LISP sense).
>
> > I'd like to see some sort of "default" value for function arguments
> > added. Something along the lines of:
> >
> > function foo(a or 5)
> >   ...
> > end;
> > ..... a = a or 5; ... end;. Syntactic sugar maybe?
>
> Function argument processing involves a lot of things, including type and range
> checking for named and positional elements.  I think the above might add more
> complexity to the language but only address one special case.

I think what I meant was that this facility be added to the language
as "syntactic sugar". This should really add much if any complexity to
the language. Basically:

function foo( a or 5 )
  ...
end;

would be expanded to

function foo( a )
  a = a or 5;
  ...
end;

This is similar to how other things are expanded internally, such as
"foo.print" => "foo["print"]". I just think it makes for a nice little
addition.

-- 
-Patrick Donnelly

"One of the lessons of history is that nothing is often a good thing
to do and always a clever thing to say."

-Will Durant