moodymudskipper / boomer

Debugging Tools to Inspect the Intermediate Steps of a Call
https://moodymudskipper.github.io/boomer/
137 stars 3 forks source link

Recursive and nested calls of rigged functions not displayed right #48

Open moodymudskipper opened 3 years ago

moodymudskipper commented 3 years ago

Because of the way we store ..FIRST_CALL.. and ..EVALED_ARGS.. in the mask.

fake_package("fake", list(
  add2 = function(a, b) {
    a + b
  }, 
  add4 = function(a, b, c, d) {
    add2(a, b) + add2(c, d)
  },
  rec_factorial = function(x) {
    if(x == 1) return(1)
    x * rec_factorial(x-1)
  } 
))

rig_in_namespace(add2, add4, rec_factorial, print_args = TRUE)

# works
add4(1, 2, 3, 4)

# rigged functions calling themselves are not opened/closed right
add2(add2(1, 2), add2(3, 4))

# recursive calls of rigged functions are not opened/closed right
rec_factorial(2)

works :

image

doesn't :

image

doesn't either:

image

I believe the mask might contain a variable ..STATE.. that would be a list, the first call of a rigged function would add an item to that list, and set up that it would be peeled off on exit (with withr::defer_parent as done atm). then wrap()ped functions would look at the last item.

moodymudskipper commented 3 years ago

It's not as easy as I thought it'd be, I have ideas, but I'm not sure if I like them. Let's move to next milestone.