naught icon indicating copy to clipboard operation
naught copied to clipboard

Add __callstack__ to return methods calls

Open mrloop opened this issue 12 years ago • 2 comments

I wanted to be able to do something like this

Locals = Naught.build do |c|
  c.black_hole
  def to_s
    __callstack__.join('.')
  end
end

mrloop avatar Oct 29 '13 23:10 mrloop

Updated to record method call arguments

mrloop avatar Oct 29 '13 23:10 mrloop

I'd be willing to merge something like this, but I have some notes I'd want to see addressed first:

  • this could blow up memory use in non-obvious ways. I'd like it to only be in effect when explicitly requested. It might make sense to integrate this with the traceable setting.

  • What happens when I use a null object more than once? Will the resulting trace concatenate the two uses as if they were one long call chain? E.g.:

    my_null.foo.bar
    my_null.baz.buz
    
  • It would be nice if the returned trace(s) contained objects that were roughly similar to Thread::Backtrace::Location

  • It may make sense to share some implementation with the pebble code.

avdi avatar Jan 16 '14 16:01 avdi