Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request to return local vars #19

Closed
Futurile opened this issue May 9, 2020 · 2 comments
Closed

Request to return local vars #19

Futurile opened this issue May 9, 2020 · 2 comments

Comments

@Futurile
Copy link

Futurile commented May 9, 2020

I found a useful function in the Postmortem that provides the local variables of a function. It's really useful for trying to understand the local context of the function. Would you consider adding a feature to debux?

For example, something like this:

(let [i 10]
    (* 2 (dbg (+ i 5) :locals ))

{:ns user, :line 1}
    dbg: (+ 10 5) :locals {:i 10} =>
    |   15
    30

(dbgn :locals (defn stats [fname [height weight] ]
            (let [i 10]
            (println fname "is" height))))

(stats "Bob" [178 68])

| fname =>
|   "Bob"
| height =>
|   178
Bob is 178
| (println fname "is" height) =>
|   nil
| (let [i 10] (debux.common.util/insert-blank-line) (println fname "is"  ... =>
|   nil
nil
| :locals {name "Bob", height 178,  weight 68, i 10}
     

A new option called :locals provides any local vars.

In Postmortem there's a specific function called debug, see the link for an example. Hash-meta has played with some interesting ideas and its implementation does this:

{:locals {}, :result 23, :form (+ 3 (* 4 5))}

The only way I could figure out how to do this with debux at the moment was to specifically call the vars in a dbg such as (dbg [fname height weight i])

@philoskim
Copy link
Owner

Your suggestion is reflected in the new 0.6.6 version of debux library. Thanks a lot for the suggestion!

@Futurile
Copy link
Author

Futurile commented Jun 4, 2020

I wrote a post about a few tools including Debux here: http://www.futurile.net/2020/05/16/clojure-observability-and-debugging-tools/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants