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.
confused somewhat
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: confused somewhat
Which mistakes are those? I skimmed the page but didn't see any glaring errors.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
Help us help you: attach a .love.
Re: confused somewhat
They're not glaring errors, but sometime stuff is hard to understand what the author meant, for example:
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.
Code: Select all
mode
This metamethod should be a string that can contain the letter "k" or "v" (or both).
There are some similar weird formulations in other parts of the book, but nothing too bad.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: confused somewhat
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.
It's always kind of interesting how the lack of information is information too, in these cases.
Re: confused somewhat
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.Robin wrote:...something has to "click" in your head...
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?
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: confused somewhat
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.Ramcat wrote:What has not clicked for me yet, is: What does "closure" mean? The end of a function?
Help us help you: attach a .love.
- jasper.davis
- Prole
- Posts: 24
- Joined: Fri Oct 25, 2013 2:32 pm
Re: confused somewhat
I look forward to seeing that. would documentation through comments in the code be possible?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.
Re: confused somewhat
That would be lovely.Robin wrote:but if you want I could write you up something about closures tomorrow.
Thou doest stab at my heart. 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.jasper.davis wrote:...would documentation through comments in the code be possible?
Who is online
Users browsing this forum: Ahrefs [Bot], aikusuuta, Bing [Bot] and 10 guests