lua-users home
lua-l archive

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


2014-02-23 2:38 GMT+02:00 Anders Petersson <andpet@gmail.com>:

> I didn't receive the Programming in Lua book yet so this is all from online
> sources.

PiL 3 is available online, though not gratis.

> Also, I don't see why the standard interpreter can't
> make the default behavior easier to use.

Because it's the same interpreter that runs an interactive
session or a read-in script.

> I'm surprised there's no built-in function to print the contents of a table.
> I looked at lua-stdlib [2] but it doesn't define such a function either.

Because tables can be printed in so many ways, there is no
one-size-fits-all.

> In particular I haven't found a good description of syntax and semantics of
> __pairs/__ipairs metamethods.

Those in the official reference manual are good, though terse. See
under global functions `pairs` and `ipairs`. But the really decent
explanation is in PiL.

> The wiki [4] talks of 'pairs' as an experimental feature and also mentions
> 'next' which wasn't even included in 5.2? I think the page isn't updated for 5.2?

A wiki is written by users. There is the occasional contributor that
has a sense of ownership and occasionally revises his pages, but
by and large, when you put something on a Wiki, it is there for
everybody to modify and correct. Even newbies with two weeks
of experience.

> These metamethods are not listed in the 5.2 manual:
> __mode, __pairs, __ipairs, __gc, __metatable, __tostring

They don't have their own entries, but search and you shall find. E.g.

| The weakness of a table is controlled by the __mode field of its metatable.
| If the __mode field is a string containing the character 'k', the keys in the
| table are weak. If __mode contains 'v', the values in the table are weak.

> And 6.2 'Coroutine Manipulation' states that coroutine operations "comprise
> a sub-library of the basic library", which is no longer true.

Why is it not true? There is a "coroutine" sublibrary.

> Also, 6.4.1 'Patterns' doesn't explain the now official %f pattern.

What version of the manual do you have? The one that comes
with Lua 5.2.3 does explain the frontier pattern.

> I've also not seen an official explanation of '_' as a variable.

It's a mere idiom.

> Online information quite often refers to 5.1, not 5.2.

If officially part of the Lua distribution, please give details.
Otherwise, go argue with that particular volunteer.

> Would someone be kind enough to put disclaimers in the online versions
> of manual 1.5 and PIL where information changed to 5.2?

Those are historical documents without clairvoyant powers. The place to
look for what changed from 5.1 to 5.2 is in the 5.2 documentation.

> Many thanks to PUC-Rio and the community for this great language!

Thanks for these comments. Every newbie is entitled to one
e-mail like yours. We've all been through that.

But please, please, wait till you have read the most recent PiL before
compiling another round of constructive criticism.