Meaningful toString() #107

Closed
texastoland opened this Issue Mar 14, 2013 · 17 comments

Comments

Projects
None yet
4 participants
@texastoland
Contributor

texastoland commented Mar 14, 2013

Something innovative ReactiveCocoa did is propogate a meaningful -description/toString() for debugging purposes. Essentially the generated string looks nearly identical to its code including all applied operators (fromBinder, map, filter, etc.) and argument descriptions.

@raimohanska

This comment has been minimized.

Show comment Hide comment
@raimohanska

raimohanska Mar 14, 2013

Contributor

Sounds interesting. Would imply a major refactoring and some overhead (in terms of js size) though, unless you've got a breaktrough idea for implementation.

Contributor

raimohanska commented Mar 14, 2013

Sounds interesting. Would imply a major refactoring and some overhead (in terms of js size) though, unless you've got a breaktrough idea for implementation.

@texastoland

This comment has been minimized.

Show comment Hide comment
@texastoland

texastoland Mar 14, 2013

Contributor

I have an idea using arguments.callee.name which shouldn't bloat it. I'll explore it if I get time. Are there plans to break Bacon apart into multiple files (observable, event-stream, property, binder, etc.)?

Contributor

texastoland commented Mar 14, 2013

I have an idea using arguments.callee.name which shouldn't bloat it. I'll explore it if I get time. Are there plans to break Bacon apart into multiple files (observable, event-stream, property, binder, etc.)?

@texastoland

This comment has been minimized.

Show comment Hide comment
@texastoland

texastoland Mar 14, 2013

Contributor

Implementation:

  1. Observable gets a displayName property returned by toString() if set
  2. displayName should be styled for readability using Node's inspect()
  3. Observable gets a pushInspectContext() method passed an arguments-like object
  4. pushContext() appends '.#{arguments.callee.name}(#{[].slice.call(arguments).join(', ')}) to displayName
  5. displayName gets propagated by constructors and arguments gets pushed by operators

I think that could get it.

Contributor

texastoland commented Mar 14, 2013

Implementation:

  1. Observable gets a displayName property returned by toString() if set
  2. displayName should be styled for readability using Node's inspect()
  3. Observable gets a pushInspectContext() method passed an arguments-like object
  4. pushContext() appends '.#{arguments.callee.name}(#{[].slice.call(arguments).join(', ')}) to displayName
  5. displayName gets propagated by constructors and arguments gets pushed by operators

I think that could get it.

@RoboTeddy

This comment has been minimized.

Show comment Hide comment
@RoboTeddy

RoboTeddy Mar 15, 2013

Contributor

I'm a javascript VM newb, so I need to ask -- is there any way this could help us get more comprehensible tracebacks?

Contributor

RoboTeddy commented Mar 15, 2013

I'm a javascript VM newb, so I need to ask -- is there any way this could help us get more comprehensible tracebacks?

@hden

This comment has been minimized.

Show comment Hide comment
@hden

hden Mar 15, 2013

Contributor

In node.js console.log(obj) uses .inspect method of obj to display its content, therefore implementing a .inspect method would be most useful for debugging.

Contributor

hden commented Mar 15, 2013

In node.js console.log(obj) uses .inspect method of obj to display its content, therefore implementing a .inspect method would be most useful for debugging.

@texastoland

This comment has been minimized.

Show comment Hide comment
@texastoland

texastoland Mar 15, 2013

Contributor

inspect method would be most useful

Added to the note above.

Contributor

texastoland commented Mar 15, 2013

inspect method would be most useful

Added to the note above.

@raimohanska

This comment has been minimized.

Show comment Hide comment
@raimohanska

raimohanska Mar 15, 2013

Contributor

To me this sounds worth trying. Maybe a proof-of-concept that would add inspect/toString capabilities to a subset of bacon.js features?

Contributor

raimohanska commented Mar 15, 2013

To me this sounds worth trying. Maybe a proof-of-concept that would add inspect/toString capabilities to a subset of bacon.js features?

@texastoland

This comment has been minimized.

Show comment Hide comment
@texastoland

texastoland Mar 15, 2013

Contributor

I'll try it as soon as I can (early next week). Do you have a feature branch to PR to?

Contributor

texastoland commented Mar 15, 2013

I'll try it as soon as I can (early next week). Do you have a feature branch to PR to?

@raimohanska

This comment has been minimized.

Show comment Hide comment
@texastoland

This comment has been minimized.

Show comment Hide comment
@texastoland

texastoland Mar 15, 2013

Contributor

🤘

Contributor

texastoland commented Mar 15, 2013

🤘

@texastoland

This comment has been minimized.

Show comment Hide comment
@texastoland

texastoland Mar 15, 2013

Contributor

@hden I only found one link about customizing Node's inspect(). In particular I'm curious how to apply color styles to displayName like the default output?

Contributor

texastoland commented Mar 15, 2013

@hden I only found one link about customizing Node's inspect(). In particular I'm curious how to apply color styles to displayName like the default output?

@hden

This comment has been minimized.

Show comment Hide comment
@hden

hden Mar 16, 2013

Contributor

From node source code, we can see that it calls the .inspect method and try to stringify it by calling String(result). 
As of colors in terminal, see these awesome project
https://github.com/marak/colors.js/
https://github.com/visionmedia/debug

Sorry for the short reply.
I'll be back with more detail on Monday.

Cheers
Haokang Den

On Sat, Mar 16, 2013 at 1:01 AM, Jonathan Toland notifications@github.com
wrote:

@hden I only found one link about customizing Node's inspect(). Could you send a couple more? In particular I'm curious whether I could return an object to be serialized to JSON or better yet how to apply color styles to our output like the default?

Reply to this email directly or view it on GitHub:
raimohanska#107 (comment)

Contributor

hden commented Mar 16, 2013

From node source code, we can see that it calls the .inspect method and try to stringify it by calling String(result). 
As of colors in terminal, see these awesome project
https://github.com/marak/colors.js/
https://github.com/visionmedia/debug

Sorry for the short reply.
I'll be back with more detail on Monday.

Cheers
Haokang Den

On Sat, Mar 16, 2013 at 1:01 AM, Jonathan Toland notifications@github.com
wrote:

@hden I only found one link about customizing Node's inspect(). Could you send a couple more? In particular I'm curious whether I could return an object to be serialized to JSON or better yet how to apply color styles to our output like the default?

Reply to this email directly or view it on GitHub:
raimohanska#107 (comment)

@texastoland

This comment has been minimized.

Show comment Hide comment
@texastoland

texastoland Mar 17, 2013

Contributor

Exactly what I wanted 👍

Contributor

texastoland commented Mar 17, 2013

Exactly what I wanted 👍

@raimohanska

This comment has been minimized.

Show comment Hide comment
@raimohanska

raimohanska Apr 9, 2013

Contributor

What's up here? Are you still planning to do this, Jonathan? Just checking!

Contributor

raimohanska commented Apr 9, 2013

What's up here? Are you still planning to do this, Jonathan? Just checking!

@texastoland

This comment has been minimized.

Show comment Hide comment
@texastoland

texastoland Apr 9, 2013

Contributor

My apology! I got pulled away on different technologies again and busy traveling and moving. I could provide a POC/unfinished implementation if it'd help posterity/ideation?

Contributor

texastoland commented Apr 9, 2013

My apology! I got pulled away on different technologies again and busy traveling and moving. I could provide a POC/unfinished implementation if it'd help posterity/ideation?

@raimohanska

This comment has been minimized.

Show comment Hide comment
@raimohanska

raimohanska Apr 9, 2013

Contributor

Sure, if you've got a link. I don't have the time/energy to drive this issue myself so I guess we'll postpone this until someone steps up :)

Contributor

raimohanska commented Apr 9, 2013

Sure, if you've got a link. I don't have the time/energy to drive this issue myself so I guess we'll postpone this until someone steps up :)

@raimohanska

This comment has been minimized.

Show comment Hide comment
@raimohanska

raimohanska May 28, 2013

Contributor

Closing for now. Doesn't seem to draw enough interest :(

Contributor

raimohanska commented May 28, 2013

Closing for now. Doesn't seem to draw enough interest :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment