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
[10 Mar 2008] update to classlib uploaded and request for further help
-
Dwayne
[10 Mar 2008] RE: update to classlib uploaded and request for further help
Note: This is an archived post that was originally sent to the Hollywood mailing list on Mon, 10 Mar 2008 12:10:57 +1100
Hi again,
I made a mistake as it was very early in the morning when I posted this and several hours had gone past between checking what I had last done (I took a few hours break and watched the King of Kong documentary
).
I do have a problem as noted when checking an inherited function but I am explicilty referring to the base function that it was inherited from rather than the top level function as a workaround to the actual problem I simply forgot I had done this and was explaining to you theworkaround and had to resolve it when the code had already been implemented by I was circumventing it due to issues.
A refresher on the problem is I can choose to use acc1.getbalance () as the limitedfunction.getbalance function is created and is supposed to return the result of the account.getbalance function unfortunately this seems to be broken, that in all likely hood is a coding thing.
I have tested the logic and it works however it does not seem to work within the framework of my code for some reason and I need assistance debugging as it maybe a matter of it not working because of the second problem or something else.
To make things simpler during test if you wanted to work with me I have the amiga connected to an IP KVM so that it is possible using internet explorer (the Avocent IP Switch uses an activex control) you can view or even control the amiga from somewhere on the net.
I could set this up for sessions so that I can explain (skype? or simply IM/IRC) what is happening and visually prompt or show you where the problems are occurring.
Anyone interested please let me know.
Regards,
Dwayne
Hi again,
I made a mistake as it was very early in the morning when I posted this and several hours had gone past between checking what I had last done (I took a few hours break and watched the King of Kong documentary
I do have a problem as noted when checking an inherited function but I am explicilty referring to the base function that it was inherited from rather than the top level function as a workaround to the actual problem I simply forgot I had done this and was explaining to you theworkaround and had to resolve it when the code had already been implemented by I was circumventing it due to issues.
A refresher on the problem is I can choose to use acc1.getbalance () as the limitedfunction.getbalance function is created and is supposed to return the result of the account.getbalance function unfortunately this seems to be broken, that in all likely hood is a coding thing.
I have tested the logic and it works however it does not seem to work within the framework of my code for some reason and I need assistance debugging as it maybe a matter of it not working because of the second problem or something else.
To make things simpler during test if you wanted to work with me I have the amiga connected to an IP KVM so that it is possible using internet explorer (the Avocent IP Switch uses an activex control) you can view or even control the amiga from somewhere on the net.
I could set this up for sessions so that I can explain (skype? or simply IM/IRC) what is happening and visually prompt or show you where the problems are occurring.
Anyone interested please let me know.
Regards,
Dwayne
-
Dwayne
[10 Mar 2008] RE: update to classlib uploaded and request for further help
Note: This is an archived post that was originally sent to the Hollywood mailing list on Mon, 10 Mar 2008 18:07:32 +1100
Hi,
I have resolved one of my problems. i.e. not having consistency with referring to tables within a table and having to use ["account"] instead of .account In the end it was very simple and a real pain in the ass to track down and identify. The names of the "keys/variables/tables" etc. were all being translated internally by hollywood to lowercase whereas the stored name was being preserved in a string. I assume this ["Account"] reference must be internally converted to ["account"]
in any case the message is clear whilst Andreas internally changes variable names to lowercase it is best that all of your programming uses lowercase and not a mix as you never know when you need to reference something and the internal conversion has not happened. It is nice that this occurs saving people the grief of having to deal with case sensitivity when referencing variables but for me it has caused a bit of a headache.
Unfortunately I did not resolve my other problem and I have to look a little deeper for this one but at least I am one step closer. I have converted all of the files to lowercase (including the constants for the time being) and will upload them once I have tracked this other bug down.
Regards,
Dwayne
Hi,
I have resolved one of my problems. i.e. not having consistency with referring to tables within a table and having to use ["account"] instead of .account In the end it was very simple and a real pain in the ass to track down and identify. The names of the "keys/variables/tables" etc. were all being translated internally by hollywood to lowercase whereas the stored name was being preserved in a string. I assume this ["Account"] reference must be internally converted to ["account"]
in any case the message is clear whilst Andreas internally changes variable names to lowercase it is best that all of your programming uses lowercase and not a mix as you never know when you need to reference something and the internal conversion has not happened. It is nice that this occurs saving people the grief of having to deal with case sensitivity when referencing variables but for me it has caused a bit of a headache.
Unfortunately I did not resolve my other problem and I have to look a little deeper for this one but at least I am one step closer. I have converted all of the files to lowercase (including the constants for the time being) and will upload them once I have tracked this other bug down.
Regards,
Dwayne
- airsoftsoftwair
- Posts: 5834
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
[13 Mar 2008] RE: update to classlib uploaded and request for further help
Note: This is an archived post that was originally sent to the Hollywood mailing list on Thu, 13 Mar 2008 22:34:47 +0100
Whenever you use a string enclosed in quotes ("") to access a variable, it will be case sensitive.
Yes. This is the only place where Hollywood still uses case sensitive access because I did not find an effective way to convert these strings to lower case in lua's table accessing code. So this is considered a "known bug" since Hollywood 2.0 but I have yet to find a solution for it.Hi,
I have resolved one of my problems. i.e. not having consistency with referring to tables within a table and having to use ["account"] instead of .account In the end it was very simple and a real pain in the ass to track down and identify. The names of the "keys/variables/tables" etc. were all being translated internally by hollywood to lowercase whereas the stored name was being preserved in a string. I assume this ["Account"] reference must be internally converted to ["account"]
Whenever you use a string enclosed in quotes ("") to access a variable, it will be case sensitive.