Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Meaningful toString() #107

Closed
dnalot opened this Issue · 17 comments

4 participants

@dnalot

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
Owner

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.

@dnalot

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

@dnalot

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

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

@hden

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.

@dnalot

inspect method would be most useful

Added to the note above.

@raimohanska
Owner

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

@dnalot

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

@dnalot

@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
@dnalot

Exactly what I wanted :+1:

@raimohanska
Owner

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

@dnalot

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
Owner

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
Owner

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
Something went wrong with that request. Please try again.