miniblog.

← Back to all posts
19
What's the best string representation of a function? Comparing with other PLs: Python: <function __main__.add_one()> JS: [Function: addOne] Clojure: #function[user/add-one] Scheme: #<procedure add-one (x)> I'm currently thinking about <fun add_one() foo.gdn:123>

9 Comments

@wilfredh it would be interesting to lever some special terminal escape characters for metadata. You could use the "click to open url" one to point (your browser?) to the source code where function could be defined
> I'm currently thinking about <fun add_one() foo.gdn:123> Looks good 👍 @wilfredh
@wilfredh I generally feel that having the parentheses in the name is unhelpful and makes it look like a function call rather than a function name; unless the parameters are shown too.
It's currently just the file name. I'm concerned that the full path or project relative path would be too long. I need to play with it more to get a feel for it, but open to opinions :)
@davep Interesting, thanks. I've been trying to use `fun_name()` more in docs as I think it often reads better. I guess in this context it's overkill.
if you're adding file name and line, might as well add project relative path that way the user can click and jump to the function if you can print anonymous closures then I can imagine it helping with debugging
there was some performance optimization I read / watched where they had to use a beta feature of rust compiler to get names for closures in flamegraph maybe it was fasterthanlime?