lua-users home
lua-l archive

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


On Tue, 2005-01-18 at 03:51, Philippe Lhoste wrote:

> BTW, obviously Lua can be used as pure procedural language, it can make 
> a decent OO language as it seems, but does functional programming 
> purists see it as a functional language or only as a language with some 
> FP features? (Like functions as first-class object, closures, lexical 
> scoping (whatever it is...), etc.; If I understood all that I read ;-) )

Clearly Lua just has a couple of FP features, that any
sane procedural language could and should have.

Neither first class functions nor lexical scoping
are peculiar to functional languages. Pascal has lexical 
scoping for example.

The point really is that Lua provides really simple and
basic constructions all languages should provide: first class
lexically scoped functions are just basic tools. They're nothing
special, just that languages like C++ and Java don't have
these basics and so don't even qualify as entry level high
level languages.

It is these basic constructions that make Lua powerful
despite being minimalist. OO on the other hand is very
hard to do minimalistically .. because it really isn't
a basic tool.

So, Lua isn't a functional language, but it does provide
a few powerful basic tools that many more complex languages
do not. You will be surprised just how much you can do
with these constructions.

Coroutines are also fairly basic. They're not used heavily
because there isn't much understanding yet how to use them.
However once you have coroutines, you can emulate
subroutines .. so in some sense subroutines are really
just special cases of coroutines.

A subroutine return is just a tail coroutine yield,
and a subroutine call is just a resumption of a tail
yielding coroutine ..

So one can argue Lua could be simplified by eliminating
function calls entirely.

In Felix, procedures are ALL coroutines.

-- 
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net