[10 Mar 2008] update to classlib uploaded and request for further help
Posted: Sat Jun 13, 2020 5:31 pm
Note: This is an archived post that was originally sent to the Hollywood mailing list on Mon, 10 Mar 2008 03:14:05 +1100
Hi all,
I have come back from my holidays and have been busy pounding the keyboard and my brain for the last two days with further debugging of the classlib files I uploaded to the test.
I am now at a point where I need some assistance as I have am not sure if theproblem is with the code or implementation as their as enough differences between lua on windows and lua in Hollywood that a great portion of the logic has been resculpted to suit our implementation. However I don't know if the problems I am currently experiencing relate to hollywood lua, buggy code or errors and assumptions made during the conversion/resculpting of the code.
In any case the files that have been posted to the site are now working albeit with a few workarounds and this is where I hope some of you can assist.
The answers may be generic enough that you can look through the questions without going through the code line by line as I am hoping some of you have encountered something similar. If not and you like the idea of having a classes system then I urge you to grab the files turn on the debugging and watch the lines go passing by.
I will pose the questions shortly but will want to know whether I am generating a lot of noise on the site to no ones benefit (one person has commented on the files uploaded so far) and whether this is a worthwhile project for people to utilise for themselves. I ask this for two reasons Michael (the other member who commented on this project) had stated that he thought Andreas was implementing classes in Hollywood in which case this would all be moot apart from the experience learnt with lua thus far. The other reason is to guage how interested people are and whether I could get some assistance for the tricky bits.
I have found three areas where I am having problems.
The first is once I have created two classes I can not access the base classes functions without explicitly identifying them i.e (keep in mind this is a very simple explanation and the actual code far exceeds the complexity of the example given but the principles are the same).
account={balance=0, getbalance=function (), deposit=function(), withdraw=function()} limitedaccount={limit=0, account={balance=0, getbalance=function(), deposit=function(), withdraw=function()}}
acc1=limitedAccount (acc1, 50.00, 500.00) ; now this assumes a great deal of things which aren't explained here and are further explained in the actual files. remember this is simply a very simple example. however in saying that I will point out that extensive metamethods are used for the __init (or initialising) or initiailising of the classes as well as a myriad of others from __call, __index, __newindex etc.
In any case from our basic example if we attempted to use the getbalance function on the windows version of lua (using the original classlib code) before it was modified by me you would simply type in.
acc1.getbalance (acc1) ; it is actually acc1:getbalance() however we cannot use the : symbol in hollywood but the line is syntactically the same i.e. it translates to the same thing if you were to expand the expression without the use of :
Now it could either be the modifications that I have made with the code or it might be a difference or limitation with hollywoods implementation of lua or there is some glue I am missing but for us to achieve the same thing we must explicitly state the class/table the function is inherited from.
acc1.account.getbalance (acc1) ; I would normally understand why this is done to attain the reference to the account table withing the limitedaccount table however I assumed (wrongly or poorly) that the classlib code would pull all of this together. There is little to no use in implementing a class system if you need to know how and indeed reference all of the inherited objects everytime you wish to do something. It should be handled for you.
This leads me to my next question:
I am having erratic behaviour with accessing a table/class/object (call it what you will) in the same manner each time and want to know whether it is again me or there is some arcane thing occurring because of a step I am missing.
using the same example:
acc1.account.getbalance (acc1) ; can actually produce an error stating that the table has not been initialized
and I need to access it via
acc1["account"].getbalance (acc1)
However I created other tables and it worked using either reference. Is there a trick or a gotcha that I need to be careful of when creating the tables so that it "initializes" each key?
The third problem relates to a problem with the acutal classlib code when dealing with inheriting from multiple classes such as the NamedLimitedAccount class and I will talk about that in detail if someone is intereted in assisting me debug this further.
If you want to have a look there is extensive debug statements throughout all of the files which it debugs to the console but you need to set one of two conditions to true at the top of the test file. In fact you can use the line anywhere in the code to turn debugging on and off so that you can target certain sections.
debugoutput=true ; this will make all calls to p_debugprint output to the console setting it back to false will stop output. debugpause=true ; will add a waitleftmouse command after every call to p_debugprint so that you can keep track of where you are at. (note you have to click in the hollywood windows that is opened up and not in the console.
I have writted several debuggint routines which are included in the constants.inc file (feel free to use them and modify for your needs and please drop me a line if you want to share your changes).
the p_debugprint routine uses two other routines p_tostring and p_tabletostring. The first simply changes values to a string so that it can be output to the console and it expands a table to show the contents of the table rather than the word table. p_tabletostring is used by p_tostring to expand tables within a table to show these contents as a string on the console.
the other is p_tabletostringindent (table, 0) that will output the table to a string with tab and newline codes inserted so that it prints in a nice hierarchical manner. the 0 is required as second parameter as an indent counter. Actually the indents aren't tab commands but four spaces as tabs were too far spread for my taste.
If anyone is interested in further explanation of what the files are and what they do (I don't know the complete inner workings but I know a lot more since starting this) or more importantly wants to assist in debugging. Please contact me via e-mail. I would be more than willing to use PM, IRC or e-mail to get this project up and running sooner rather than later.
Regards,
Dwayne
Hi all,
I have come back from my holidays and have been busy pounding the keyboard and my brain for the last two days with further debugging of the classlib files I uploaded to the test.
I am now at a point where I need some assistance as I have am not sure if theproblem is with the code or implementation as their as enough differences between lua on windows and lua in Hollywood that a great portion of the logic has been resculpted to suit our implementation. However I don't know if the problems I am currently experiencing relate to hollywood lua, buggy code or errors and assumptions made during the conversion/resculpting of the code.
In any case the files that have been posted to the site are now working albeit with a few workarounds and this is where I hope some of you can assist.
The answers may be generic enough that you can look through the questions without going through the code line by line as I am hoping some of you have encountered something similar. If not and you like the idea of having a classes system then I urge you to grab the files turn on the debugging and watch the lines go passing by.
I will pose the questions shortly but will want to know whether I am generating a lot of noise on the site to no ones benefit (one person has commented on the files uploaded so far) and whether this is a worthwhile project for people to utilise for themselves. I ask this for two reasons Michael (the other member who commented on this project) had stated that he thought Andreas was implementing classes in Hollywood in which case this would all be moot apart from the experience learnt with lua thus far. The other reason is to guage how interested people are and whether I could get some assistance for the tricky bits.
I have found three areas where I am having problems.
The first is once I have created two classes I can not access the base classes functions without explicitly identifying them i.e (keep in mind this is a very simple explanation and the actual code far exceeds the complexity of the example given but the principles are the same).
account={balance=0, getbalance=function (), deposit=function(), withdraw=function()} limitedaccount={limit=0, account={balance=0, getbalance=function(), deposit=function(), withdraw=function()}}
acc1=limitedAccount (acc1, 50.00, 500.00) ; now this assumes a great deal of things which aren't explained here and are further explained in the actual files. remember this is simply a very simple example. however in saying that I will point out that extensive metamethods are used for the __init (or initialising) or initiailising of the classes as well as a myriad of others from __call, __index, __newindex etc.
In any case from our basic example if we attempted to use the getbalance function on the windows version of lua (using the original classlib code) before it was modified by me you would simply type in.
acc1.getbalance (acc1) ; it is actually acc1:getbalance() however we cannot use the : symbol in hollywood but the line is syntactically the same i.e. it translates to the same thing if you were to expand the expression without the use of :
Now it could either be the modifications that I have made with the code or it might be a difference or limitation with hollywoods implementation of lua or there is some glue I am missing but for us to achieve the same thing we must explicitly state the class/table the function is inherited from.
acc1.account.getbalance (acc1) ; I would normally understand why this is done to attain the reference to the account table withing the limitedaccount table however I assumed (wrongly or poorly) that the classlib code would pull all of this together. There is little to no use in implementing a class system if you need to know how and indeed reference all of the inherited objects everytime you wish to do something. It should be handled for you.
This leads me to my next question:
I am having erratic behaviour with accessing a table/class/object (call it what you will) in the same manner each time and want to know whether it is again me or there is some arcane thing occurring because of a step I am missing.
using the same example:
acc1.account.getbalance (acc1) ; can actually produce an error stating that the table has not been initialized
and I need to access it via
acc1["account"].getbalance (acc1)
However I created other tables and it worked using either reference. Is there a trick or a gotcha that I need to be careful of when creating the tables so that it "initializes" each key?
The third problem relates to a problem with the acutal classlib code when dealing with inheriting from multiple classes such as the NamedLimitedAccount class and I will talk about that in detail if someone is intereted in assisting me debug this further.
If you want to have a look there is extensive debug statements throughout all of the files which it debugs to the console but you need to set one of two conditions to true at the top of the test file. In fact you can use the line anywhere in the code to turn debugging on and off so that you can target certain sections.
debugoutput=true ; this will make all calls to p_debugprint output to the console setting it back to false will stop output. debugpause=true ; will add a waitleftmouse command after every call to p_debugprint so that you can keep track of where you are at. (note you have to click in the hollywood windows that is opened up and not in the console.
I have writted several debuggint routines which are included in the constants.inc file (feel free to use them and modify for your needs and please drop me a line if you want to share your changes).
the p_debugprint routine uses two other routines p_tostring and p_tabletostring. The first simply changes values to a string so that it can be output to the console and it expands a table to show the contents of the table rather than the word table. p_tabletostring is used by p_tostring to expand tables within a table to show these contents as a string on the console.
the other is p_tabletostringindent (table, 0) that will output the table to a string with tab and newline codes inserted so that it prints in a nice hierarchical manner. the 0 is required as second parameter as an indent counter. Actually the indents aren't tab commands but four spaces as tabs were too far spread for my taste.
If anyone is interested in further explanation of what the files are and what they do (I don't know the complete inner workings but I know a lot more since starting this) or more importantly wants to assist in debugging. Please contact me via e-mail. I would be more than willing to use PM, IRC or e-mail to get this project up and running sooner rather than later.
Regards,
Dwayne