Lua short reference part 1 - draft 1

classic Classic list List threaded Threaded
21 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Lua short reference part 1 - draft 1

Enrico Colombini
Here is the first draft of my "Lua short reference", part 1 (language and 
libraries - part 2 will cover the C API):

http://www.erix.it/shortref-d1.pdf

It is undoubtedly full of the most horrible mistakes and omissions, so 
feedback at any level is greatly appreciated.

Please do not distribute this draft version.

  Enrico

Reply | Threaded
Open this post in threaded view
|

RE: Lua short reference part 1 - draft 1

Virgil Smith
Looks like a great start.
2 Quick comments...

<quote>
[[ ... ]] Multi-line comment
</quote>

should be...
--[[ ... ]] Multi-line comment


and, you missed __fenv in the metatable listing.


This last isn't terribly surprising.

Included is a copy of a previous post of mine that both explains why this
was easy to miss, and reflects that I am indeed thankful for your simple
(and somewhat tedious), but very helpful contribution to the Lua community.


------

As a side note it would be nice if a listing of all of the "special
modifiers" was made and added to the manual (perhaps as a side note in the
metatable section).  The listing could just refer to the relevant section.
The reason for the suggestion is because it would make it easier to find
these options when thinking along the lines of "what can I do with object X"
as opposed to "what can function/system Y do with objects it receives".

If nothing else these items could at least be added to the glossary.

Below are some of the ones that a search of the manual for "__" turned up.
__pow -- global

__gc
__mode
__fenv
__metatable
__tostring


As a side note, now that I am thinking about this again it would be
interesting to see a compilation of common extensions / best practices for
libraries etc.  For instance, the metatable naming/querying system from the
aux. lib.  Similarly, in transitioning a file saving/loading system I threw
together from Lua4 to Lua5 I replaced a table of specializations per
userdata tag with entries in the metatable of the userdata "types".  Anyway,
I was just curious what other uses for "specialization" methods people have
thought up.




-----Original Message-----
From: [hidden email]
[[hidden email] Behalf Of Enrico
Colombini
Sent: Monday, March 08, 2004 8:01 AM
To: Lua list
Subject: Lua short reference part 1 - draft 1


Here is the first draft of my "Lua short reference", part 1 (language and
libraries - part 2 will cover the C API):

http://www.erix.it/shortref-d1.pdf

It is undoubtedly full of the most horrible mistakes and omissions, so
feedback at any level is greatly appreciated.

Please do not distribute this draft version.

  Enrico



Reply | Threaded
Open this post in threaded view
|

RE: Lua short reference part 1 - draft 1

Stewart
In reply to this post by Enrico Colombini
Title: RE: Lua short reference part 1 - draft 1

Thanks for your efforts on this reference.

BTW, I can't retrieve the pdf file from the given URL. The message I get is:

---
File Not Found

(!) The requested URL was not found on this server.
---



- - - - - - - Appended by Scientific-Atlanta, Inc. - - - - - - -
This e-mail and any attachments may contain information which is confidential, proprietary, privileged or otherwise protected by law. The information is solely intended for the named addressee (or a person responsible for delivering it to the addressee). If you are not the intended recipient of this message, you are not authorized to read, print, retain, copy or disseminate this message or any part of it. If you have received this e-mail in error, please notify the sender immediately by return e-mail and delete it from your computer.
Reply | Threaded
Open this post in threaded view
|

Re: Lua short reference part 1 - draft 1

Ando Sonenblick
In reply to this post by Virgil Smith
That doc rocks!

One thing people might find useful in the assignments section:

a = "X: "   a = a..4		Yields a = "X: 4"

Or something similar for putting numbers into strings...

ando


Reply | Threaded
Open this post in threaded view
|

Re: Bad URL - Lua short reference

Michael Newberry-2
In reply to this post by Enrico Colombini
Bad URL. Where do I get the doc?

Thanks.

Michael

----- Original Message ----- 
From: "Enrico Colombini" <[hidden email]>
To: "Lua list" <[hidden email]>
Sent: Monday, March 08, 2004 7:00 AM
Subject: Lua short reference part 1 - draft 1


Here is the first draft of my "Lua short reference", part 1 (language and 
libraries - part 2 will cover the C API):

http://www.erix.it/shortref-d1.pdf

It is undoubtedly full of the most horrible mistakes and omissions, so 
feedback at any level is greatly appreciated.

Please do not distribute this draft version.

  Enrico



Reply | Threaded
Open this post in threaded view
|

Re: Lua short reference part 1 - draft 1

Philippe Lhoste
In reply to this post by Virgil Smith
Here is the first draft of my "Lua short reference", part 1 (language and
libraries - part 2 will cover the C API):

http://www.erix.it/shortref-d1.pdf

It is undoubtedly full of the most horrible mistakes and omissions, so
feedback at any level is greatly appreciated.

Please do not distribute this draft version.

  Enrico

I first couldn't be able to download it, but since Virgil's message, I could.
It looks very nice and complete.

Notes:

"escape sequences are not interpreted between [[ ]]" .. "but newlines are allowed."

In t = {x=5, y=10; "yes", "no"}
the semi-colon is no longer required in Lua 5.0, but of course is still valid.
Perhaps you should mention ';' and ',' are equivalent.

"function ( ... ) body [return values] end": it is not obvious that ellipsis can go after an actual list of parameters.

"Object function getting extra arg self": you should find a way to mention that self is the first argument, ie. equivalent to "obj.name = function(self, ...) ... end"

Strictly speaking, you mention '..' operator several times before explaining its function.

tonumber: "Converts string x to a number in base b": I would rather write something like "Convert string x representing a number in base b to a decimal number" or something shorter :-)

GC: I don't know what KiB are... You should write KB, or Kbytes as in the manual.

I don't like much the notation "print ([, values])", it may be ambiguous, perhaps use "print(val[, val...])", or "print(args)" like you do elsewhere.

I am not sure to understand what "normalized fraction" (math.frexp and math.ldexp) is, but that's not your fault :-)

Typo: "(index -1 refers to the last charactr)." in note about string indexes.

Some of my remarks are irrelevant if you are not looking for exhaustivity, but I believe the more infos you put, the better.

I like that you details stuff that Lua team didn't mention explicitely because it is part of the C library... (math library, format patterns...)

I don't see why you mention two times io.stdxxx (in Complete I/O and Simple I/O).

io.input: "in the latter case the file is opened for reading" .. " in text mode". Same of io.output.


It looks like a lot of criticism, but that's just to help you improve your excellent reference. Obviously you put a lot of work in it, and it will be a valuable document to keep next to the keyboard when programming Lua.

Thank you for your efforts.

--
--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--
Philippe Lhoste (Paris -- France)
Professional programmer and amateur artist
http://jove.prohosting.com/~philho/ (outdated)
http://philho.multimania.com (in French, for files to download)
--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--

Reply | Threaded
Open this post in threaded view
|

RE: Lua short reference part 1 - draft 1

Nick Trout
In reply to this post by Enrico Colombini

> Here is the first draft of my "Lua short reference", part 1 (language
and
> libraries - part 2 will cover the C API):
> 
> http://www.erix.it/shortref-d1.pdf
> 
> It is undoubtedly full of the most horrible mistakes and omissions, so
> feedback at any level is greatly appreciated.
> 
> Please do not distribute this draft version.

This is a great reference, well done. Sorry I have disobeyed your wish
because...

> BTW, I can't retrieve the pdf file from the given URL. The message I
get is:

For the people who are having trouble downloading the document I put it
on the wiki. 

http://lua-users.org/wiki/LuaShortReference

Perhaps you could update the above link on the wiki when you have newer
versions (add keep a history of changes there???)

Nick


Reply | Threaded
Open this post in threaded view
|

Re: Lua short reference part 1 - draft 1

Enrico Colombini
In reply to this post by Philippe Lhoste
On Monday 08 March 2004 20:12, Philippe Lhoste wrote:
> GC: I don't know what KiB are... 

Neither did I till not long ago. It happened outside our field, and looks like 
it's here to stay:
http://physics.nist.gov/cuu/Units/binary.html

> It looks like a lot of criticism

It looks like very good and welcome feedback to me :-)

  Enrico

Reply | Threaded
Open this post in threaded view
|

Re: Lua short reference part 1 - draft 1

Enrico Colombini
In reply to this post by Nick Trout
On Monday 08 March 2004 20:24, Nick Trout wrote:
> For the people who are having trouble downloading the document 
> I put it on the wiki.

Good; that solves the DNS update problem (I moved my pages about a week ago).

> http://lua-users.org/wiki/LuaShortReference
>
> Perhaps you could update the above link on the wiki when you have newer
> versions (add keep a history of changes there???)

Thanks, I was about to put up a temporary page just to do that. Sorry for 
always having been too lazy to learn how to use the wiki, I'll do it now :-)

Thanks also to all those that are sending in fixes and suggestions.

  Enrico

Reply | Threaded
Open this post in threaded view
|

Re: Lua short reference part 1 - draft 1

Asko Kauppi-3
In reply to this post by Enrico Colombini

Well (and this _is_ out-of-topic..) I for one won't be using 'kibibits' ;DD

Same as C99?  Funny standard no-one uses, or even takes seriously!

-ak

Enrico Colombini kirjoittaa maanantaina, 8. maaliskuuta 2004, kello 23:31:

On Monday 08 March 2004 20:12, Philippe Lhoste wrote:
GC: I don't know what KiB are...

Neither did I till not long ago. It happened outside our field, and looks like
it's here to stay:
http://physics.nist.gov/cuu/Units/binary.html

It looks like a lot of criticism

It looks like very good and welcome feedback to me :-)

  Enrico



Reply | Threaded
Open this post in threaded view
|

Re: Lua short reference part 1 - draft 1 (OT)

Jamie Webb-3
In reply to this post by Enrico Colombini
On Monday 08 March 2004 21:31, Enrico Colombini wrote:
> On Monday 08 March 2004 20:12, Philippe Lhoste wrote:
> > GC: I don't know what KiB are...
>
> Neither did I till not long ago. It happened outside our field, and looks
> like it's here to stay:
> http://physics.nist.gov/cuu/Units/binary.html

Not entirely out of our field. Raw hard drive capacity for example is always 
quoted in MiB.

-- Jamie Webb

Reply | Threaded
Open this post in threaded view
|

RE: Lua short reference part 1 - draft 1 (OT)

Richard Ranft
Thought MiB was a tongue-in-cheek jab at American Pop-culture....

I guess it's about time someone stepped in and straightened things out for
the laymen.  I've always just understood what the terms meant in context,
but there are always those people who have to have it spelled out by a
standards committee before they're happy - and someone will still have to
know what the heck is being discussed....

How many of us still regularly work in nibbles?

-----Original Message-----
From: [hidden email]
[[hidden email] Behalf Of Jamie Webb
Sent: Monday, March 08, 2004 1:49 PM
To: Lua list
Subject: Re: Lua short reference part 1 - draft 1 (OT)


On Monday 08 March 2004 21:31, Enrico Colombini wrote:
> On Monday 08 March 2004 20:12, Philippe Lhoste wrote:
> > GC: I don't know what KiB are...
>
> Neither did I till not long ago. It happened outside our field, and looks
> like it's here to stay:
> http://physics.nist.gov/cuu/Units/binary.html

Not entirely out of our field. Raw hard drive capacity for example is always
quoted in MiB.

-- Jamie Webb


Reply | Threaded
Open this post in threaded view
|

Re: Lua short reference part 1 - draft 1

Reuben Thomas-5
In reply to this post by Asko Kauppi-3
> Funny standard no-one uses, or even takes seriously!

Once GCC implements C99 fully, I will be using it. I already have found
myself using some bits (especially those that can be implemented in C89),
and the pressure as time goes on to use more is hard not to give in to,
because there are so many good extra bits.

-- 
http://www.mupsych.org/~rrt/ | traddutore, v.t.  traditore (Anon)

Reply | Threaded
Open this post in threaded view
|

RE: Lua short reference part 1 - draft 1 (OT)

RLak-2
In reply to this post by Richard Ranft

Jamie Webb escribió:

>  Not entirely out of our field. Raw hard drive capacity for example is always
> quoted in MiB.

Not so. Raw hard drive capacity is always quoted in mega = 10^6 or giga = 10^9 bytes.
RAM, on the other hand, is almost always quoted in mibi = 2^20 or gibi = 2^30 bytes.

And the icing on the cake is the famous and now fortunately almost obsolete
1.44 M?B floppy drive, whose capacity is actually 1.44 x 10^3 x 2^10 bytes,
mixing a kilo and a kibi in an ambiguous M (miga?).

Standardising stuff like this might actually make it easier for the layperson.

Although manufacturers often like to use the biggest numbers possible, as
witness the bizarre convention for monitor sizes which makes it impossible to
compare flat screens with CRTs, and means that a 17" CRT screen in the US is a
15.7" CRT screen in Canada -- or at least it used to be -- not because
Canadian inches are smaller but because the Canadian government is
(was?) fussier about what you are allowed to measure.
Reply | Threaded
Open this post in threaded view
|

Re: Lua short reference part 1 - draft 1

John Belmonte
In reply to this post by Enrico Colombini
Enrico Colombini wrote:
On Monday 08 March 2004 20:24, Nick Trout wrote:

For the people who are having trouble downloading the document I put it on the wiki.

Good; that solves the DNS update problem (I moved my pages about a week ago).

Due to the size of this file and its potential popularity, I've moved it to the download area of the lua-users sourceforge project. This way it will be mirrored automatically, and we won't run the risk of bogging down the project web server (wiki, etc.). We can also keep a history of releases there nicely. To download, go to:

http://sourceforge.net/project/showfiles.php?group_id=32250&package_id=111829

Currently Reuben Thomas and I can do new releases. If you'd like and are familiar with sourceforge, I can add you to the project so that you can do them also. Or if Nick would volunteer to make the releases for you, we could add him.

By the way, I don't know much about PDF creation, but if there is some source format of the reference, I'd encourage you to distribute that also.

Regards,
-John


--
http:// if  ile.org/

Reply | Threaded
Open this post in threaded view
|

RE: Lua short reference part 1 - draft 1

Nick Trout
In reply to this post by Enrico Colombini

> can do them also.  Or if Nick would volunteer to make the releases for
> you, we could add him.

I can do that if you like. 

Nick


Reply | Threaded
Open this post in threaded view
|

Re: Lua short reference part 1 - draft 1 (OT)

Jamie Webb-3
In reply to this post by RLak-2
On Tuesday 09 March 2004 00:15, [hidden email] wrote:
> Jamie Webb escribió:
> >  Not entirely out of our field. Raw hard drive capacity for example is
>
> always
>
> > quoted in MiB.
>
> Not so. Raw hard drive capacity is always quoted in mega = 10^6 or giga =
> 10^9 bytes.
> RAM, on the other hand, is almost always quoted in mibi = 2^20 or gibi =
> 2^30 bytes.

Dammit. I knew the difference, but was getting them the wrong way round. I 
assumed Mi was short for Million. A quick search on google suggests I'm not 
alone, so that'll be fun...

-- Jamie Webb

Reply | Threaded
Open this post in threaded view
|

Re: Lua short reference part 1 - draft 1 (OT)

Clemens Wacha
Am Die, den 09.03.2004 schrieb Jamie Webb um 12:05:
> On Tuesday 09 March 2004 00:15, [hidden email] wrote:
> > Jamie Webb escribió:
> > >  Not entirely out of our field. Raw hard drive capacity for example is
> >
> > always
> >
> > > quoted in MiB.
> >
> > Not so. Raw hard drive capacity is always quoted in mega = 10^6 or giga =
> > 10^9 bytes.
> > RAM, on the other hand, is almost always quoted in mibi = 2^20 or gibi =
> > 2^30 bytes.

Actually its very simple.
Bits are only 0 and 1 so they are just counted. 1 Mega bit is therefore
10^6 bits

With bytes its different. Because one byte is 2^3 Bits they are usually
counted in powers of 2

In the majority of the cases if someone speaks of bits he thinks in
powers of 10 and if he speaks of bytes he thinks in power of 2

As always there are exceptions
1. The classical 1.44M Floppy 
2. as already mentioned: Hard Drives because they are "getting bigger"
if their size is given in powers of 10 :-) Bigger harddrives sell
better.

If I was you I would always write KB for 1024 bytes MB for 1024KB. In
other words: since lua has nothing to do with network you will never
need to write in (mega/kilo) bits so always write in power of 2 and
define that in a footnote.

Regards
Clemens
-- 
Clemens Wacha           [hidden email]           ICQ:12620942

proudly running Debian/GNU Linux. See http://www.debian.org


Reply | Threaded
Open this post in threaded view
|

Re: Lua short reference part 1 - draft 1 (OT)

Enrico Colombini
On Tuesday 09 March 2004 12:29, Clemens Wacha wrote:
> If I was you I would always write KB for 1024 bytes MB for 1024KB. In
> other words: since lua has nothing to do with network you will never
> need to write in (mega/kilo) bits so always write in power of 2 and
> define that in a footnote.

I'll admit I was curious to see the reactions to my Si-correctness ;-)
Your suggestion is reasonable, but I'll have to omit the footnote for lack of 
space. 

Anyway, "KB" being officially wrong on both counts (it's neither "kB" nor 
"KiB") it's universally understood, so I'll use it :-)

  Enrico

Reply | Threaded
Open this post in threaded view
|

Re: Lua short reference part 1 - draft 1 (OT)

Andreas Stenius-2
Enrico Colombini wrote:
[nsip]
Anyway, "KB" being officially wrong on both counts (it's neither "kB" nor "KiB") it's universally understood, so I'll use it :-)

LMAO.. that was the best reason to reach a decision I've seen in a long time!

//K

--
(sorry for the band-width eater non-sense e-mail, hopefully, most if it get's transported with ecological electrons)



12