Zerobrane & 30log/middle class

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
pajh
Prole
Posts: 8
Joined: Fri Jan 30, 2015 4:52 pm

Zerobrane & 30log/middle class

Post by pajh »

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>?
User avatar
I~=Spam
Party member
Posts: 206
Joined: Fri Dec 14, 2012 11:59 pm

Re: Zerobrane & 30log/middle class

Post by I~=Spam »

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
User avatar
cohadar
Prole
Posts: 25
Joined: Mon May 04, 2015 5:46 am
Contact:

Re: Zerobrane & 30log/middle class

Post by cohadar »

The best way to write clean code is to not use any OO.
Believe me I know, I write Java for a living.
pajh
Prole
Posts: 8
Joined: Fri Jan 30, 2015 4:52 pm

Re: Zerobrane & 30log/middle class

Post by pajh »

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
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.

Will post again when i've done a bit more if this change breaks anything
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Zerobrane & 30log/middle class

Post by kikito »

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.
pajh
Prole
Posts: 8
Joined: Fri Jan 30, 2015 4:52 pm

Re: Zerobrane & 30log/middle class

Post by pajh »

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)
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?
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Zerobrane & 30log/middle class

Post by kikito »

pajh wrote:
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)
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?
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.
When I write def I mean function.
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: Zerobrane & 30log/middle class

Post by s-ol »

kikito wrote:
pajh wrote:
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)
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?
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.
I just opened #457 on github for this.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
paulclinger
Party member
Posts: 227
Joined: Thu Jun 28, 2012 8:46 pm

Re: Zerobrane & 30log/middle class

Post by paulclinger »

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.
My previous (long) response got eaten by some "maintenance" message on the server, so I'll keep this one short ;).

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.
User avatar
I~=Spam
Party member
Posts: 206
Joined: Fri Dec 14, 2012 11:59 pm

Re: Zerobrane & 30log/middle class

Post by I~=Spam »

Ok I suppose that makes sense. Could you have that be optional in the config?

EDIT:
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.
Considering that java forces you to use java I think you might want to reconsider your programming choice...

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
Post Reply

Who is online

Users browsing this forum: Google [Bot], pgimeno and 63 guests