lua-users home
lua-l archive

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

On Thu, Nov 26, 2009 at 12:47 PM, David Kastrup <> wrote:
> Sometimes the task you have to do is in the deep end of the pool, to a
> degree where you can't sensibly start with parts at the shallow end,
> because you need to establish a framework for your task first.

This is very true, but there is an in between way.  One of the skills
of experienced learners is that they don't try to learn to swim by
half-drowning, but by playing.  Maybe you have already a big
application that needs Lua scripting, with GUI, database access, ad

This is not the place to start.  Better to write a few toy programs
with Lua embedded in them.  How can we call a named Lua function? OK,
that worked. How to pass arguments, testing by simply calling 'print'?
 Cool!  How to receive results back from a Lua function?  What if the
function failed (say the named function did not exist)?  And so forth.

So you have a hundred-line program which you understand _thoroughly_,
and any function that could possibly return a status is checked.

Then you move on, make the example more interesting: setting a Lua
callback by making a reference to it, and calling that reference

The added advantage of this is that a short program is easier for
other people to understand; no one here will mind if you post forty
lines that are self-contained, but 400 lines of obscure library calls
is likely to go straight into /dev/null

steve d.