I'm using Zerobrane and liking the debugger, though just recently I decided to add one of the OO wrappers to tidy up my code - at this stage I've used 30log and middleclass, both having the same problem - zerobrane watch window no longer shows any of the contents of these 'objects' - just the text "instance of X'
Whereas my homemade "classes" which just used setmetatable() and __index to mimic "class functions" showed up perfectly in the ZB watch window.
So is there another simple OO wrapper that does work with ZB debugger or is there a simple hack I can do to one of these to make it work>?
Zerobrane & 30log/middle class
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Zerobrane & 30log/middle class
Here is a link to the "clean" version of 30log (it isn't condensed into 30 lines). I have selected a line. Comment this out and use this file. I think it will work then. https://github.com/Yonaba/30log/blob/ma ... an.lua#L73
My Tox ID: 0F1FB9170B94694A90FBCF6C4DDBDB9F58A9E4CDD0B4267E50BF9CDD62A0F947E376C5482610
Re: Zerobrane & 30log/middle class
The best way to write clean code is to not use any OO.
Believe me I know, I write Java for a living.
Believe me I know, I write Java for a living.
Re: Zerobrane & 30log/middle class
Thanks for that - removing that line didn't fix it - however removing the entire __tostring function just above it in baseMT as well as removing the line you pointed out seems to have fixed it - now i can see the table contents in ZB watches like a normal table.I~=Spam wrote:Here is a link to the "clean" version of 30log (it isn't condensed into 30 lines). I have selected a line. Comment this out and use this file. I think it will work then. https://github.com/Yonaba/30log/blob/ma ... an.lua#L73
Will post again when i've done a bit more if this change breaks anything
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Zerobrane & 30log/middle class
Hi there,
The same happens in middleclass. If you remove the __tostring function from the main Object class, it should work too.
BTW, I personally would *always* print the dump of the table, even if it has a tostring metamethod (in inspect.lua I print both things)
The same happens in middleclass. If you remove the __tostring function from the main Object class, it should work too.
BTW, I personally would *always* print the dump of the table, even if it has a tostring metamethod (in inspect.lua I print both things)
When I write def I mean function.
Re: Zerobrane & 30log/middle class
sorry not sure what you mean - is there a setting I can change in Zerobrane to make it ignore the tostring and keep middleclass/30log unchanged but still see the contents/drill down in the ZB watch window?kikito wrote:Hi there,
The same happens in middleclass. If you remove the __tostring function from the main Object class, it should work too.
BTW, I personally would *always* print the dump of the table, even if it has a tostring metamethod (in inspect.lua I print both things)
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Zerobrane & 30log/middle class
No, I mean that If I was the author of ZB, I would always dump the tables. I have not used it so I don't know its options.pajh wrote:sorry not sure what you mean - is there a setting I can change in Zerobrane to make it ignore the tostring and keep middleclass/30log unchanged but still see the contents/drill down in the ZB watch window?kikito wrote:Hi there,
The same happens in middleclass. If you remove the __tostring function from the main Object class, it should work too.
BTW, I personally would *always* print the dump of the table, even if it has a tostring metamethod (in inspect.lua I print both things)
When I write def I mean function.
Re: Zerobrane & 30log/middle class
I just opened #457 on github for this.kikito wrote:No, I mean that If I was the author of ZB, I would always dump the tables. I have not used it so I don't know its options.pajh wrote:sorry not sure what you mean - is there a setting I can change in Zerobrane to make it ignore the tostring and keep middleclass/30log unchanged but still see the contents/drill down in the ZB watch window?kikito wrote:Hi there,
The same happens in middleclass. If you remove the __tostring function from the main Object class, it should work too.
BTW, I personally would *always* print the dump of the table, even if it has a tostring metamethod (in inspect.lua I print both things)
-
- Party member
- Posts: 227
- Joined: Thu Jun 28, 2012 8:46 pm
Re: Zerobrane & 30log/middle class
My previous (long) response got eaten by some "maintenance" message on the server, so I'll keep this one short .kikito wrote:No, I mean that If I was the author of ZB, I would always dump the tables. I have not used it so I don't know its options.
ZBS doesn't dump the table by default, because metatables can be used with things like userdata, and the assumption is that if someone wanted to have __tostring, this is the results that users want.
The idea to show both (__tostring and serialization result) looks interesting, but it may end up complicating things (and duplicating elements if some of them are already returned by __tostring.
As a quick workaround, you may add __serialize method that simply returns the same table, which will be serialized as a regular table. Something like this may work (not tested): __serialize = function(t) return t end
I do consider adding a way to suppress all metatable processing, so a better option may be available in the future. Paul.
Re: Zerobrane & 30log/middle class
Ok I suppose that makes sense. Could you have that be optional in the config?
EDIT:
If that is how you feel about OOP you probably don't know how to use it. Pure ANSI C guys tend to not use OOP not because it is awful (in fact they might prefer it) but because it can be significantly faster to write data-oriented code. This is hardly a consideration with java because objects are forced on you anyway so I just think you don't understand OOP.
It is interesting but a C programer using tables and passing a pointer to the table as the first arg to a set of functions can create a form of OOP. This is actually exactly what lua does. Why do they do this? The code is easier to read, maintain, and if they are careful also just as fast by being cache friendly.
So... again.... I don't think you fundamentally understand OOP...
EDIT:
Considering that java forces you to use java I think you might want to reconsider your programming choice...cohadar wrote:The best way to write clean code is to not use any OO.
Believe me I know, I write Java for a living.
If that is how you feel about OOP you probably don't know how to use it. Pure ANSI C guys tend to not use OOP not because it is awful (in fact they might prefer it) but because it can be significantly faster to write data-oriented code. This is hardly a consideration with java because objects are forced on you anyway so I just think you don't understand OOP.
It is interesting but a C programer using tables and passing a pointer to the table as the first arg to a set of functions can create a form of OOP. This is actually exactly what lua does. Why do they do this? The code is easier to read, maintain, and if they are careful also just as fast by being cache friendly.
So... again.... I don't think you fundamentally understand OOP...
My Tox ID: 0F1FB9170B94694A90FBCF6C4DDBDB9F58A9E4CDD0B4267E50BF9CDD62A0F947E376C5482610
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 7 guests