Page 2 of 2

Re: confused somewhat

Posted: Tue Jul 08, 2014 9:54 pm
by murks
Thanks Robin.
Most cases where I have seen them used were OOP implementations, and that stuff looks complicated.
I found this book and although it contains some mistakes it is helpful because it shows some somewhat simpler examples for a change. https://en.wikibooks.org/wiki/Lua_Programming/Tables

I guess I'll read the PiL explanation again and have another look at the OOP implementations again.

Re: confused somewhat

Posted: Tue Jul 08, 2014 11:15 pm
by Robin
murks wrote:I found this book and although it contains some mistakes it is helpful because it shows some somewhat simpler examples for a change. https://en.wikibooks.org/wiki/Lua_Programming/Tables
Which mistakes are those? I skimmed the page but didn't see any glaring errors.

Re: confused somewhat

Posted: Wed Jul 09, 2014 2:16 pm
by murks
They're not glaring errors, but sometime stuff is hard to understand what the author meant, for example:

Code: Select all

mode
    This metamethod should be a string that can contain the letter "k" or "v" (or both).
How can a method be a string? What is this supposed to mean? A method that returns a string? The name of a method as string? Can the string consist of anything other than "k", "v", "kv" ("vk"?)?

There are some similar weird formulations in other parts of the book, but nothing too bad.

Re: confused somewhat

Posted: Wed Jul 09, 2014 6:13 pm
by bartbes
I'm guessing calling it a "metamethod" may confuse matters, but you're just supposed to assign a string to it, that can indeed be "k", "v" or "kv", and probably "vk", too. It can't contain other letters, from the looks of it, but the actual results are unspecified.

It's always kind of interesting how the lack of information is information too, in these cases.

Re: confused somewhat

Posted: Wed Jul 09, 2014 8:22 pm
by Ramcat
Robin wrote:...something has to "click" in your head...
Oh, how I would like to be able to explain this to common folk. For most people, I think, this "clicking" is a rare thing, less than once every 6 months. Said another way, more than 6 months passes between clicks. For me as a software engineer this can be an every day thing when I am working hard or learning a new language.

As for "Stage Manager" and "LoveTank", I had a "click" as to how objects should be done in Lua and have re-written LoveTank from the ground up. Soon, I'll release another version of both.

What has not clicked for me yet, is: What does "closure" mean? The end of a function?

Re: confused somewhat

Posted: Wed Jul 09, 2014 10:27 pm
by Robin
Ramcat wrote:What has not clicked for me yet, is: What does "closure" mean? The end of a function?
It's late and I'm tired, so no informative post from me right now, but if you want I could write you up something about closures tomorrow.

Re: confused somewhat

Posted: Wed Jul 09, 2014 11:42 pm
by jasper.davis
Ramcat wrote: As for "Stage Manager" and "LoveTank", I had a "click" as to how objects should be done in Lua and have re-written LoveTank from the ground up. Soon, I'll release another version of both.
I look forward to seeing that. would documentation through comments in the code be possible?

Re: confused somewhat

Posted: Thu Jul 10, 2014 8:01 pm
by Ramcat
Robin wrote:but if you want I could write you up something about closures tomorrow.
That would be lovely.
jasper.davis wrote:...would documentation through comments in the code be possible?
:x Thou doest stab at my heart. :cool: Usually my commenting is better. LoveTank is a bit light on comments, partially because Lua has no /// (triple slash) or /** (Java style) commenting mechanism for functions. I'll remember that as I edit the last class I have left to finish and take a quick look over the others to see if I can bring it up to par with my professional stuff.