-
Notifications
You must be signed in to change notification settings - Fork 3.5k
First implementation of Kernel.dbg/2 #11974
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
Conversation
It is looking awesome, I have added some comments. I am wondering if we should call it |
@josevalim this is ready for another round of review. |
lib/elixir/lib/macro.ex
Outdated
|
||
quote do | ||
unquote(values_ast) | ||
{:pipe, unquote(escape(asts)), Enum.reverse(unquote(values_acc_var))} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am almost 100% you can convert the asts to string here, instead of escaping them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done ✅
lib/elixir/lib/macro.ex
Outdated
|
||
# Any other AST. | ||
defp dbg_ast_to_debuggable(ast) do | ||
quote do: {:value, unquote(escape(ast)), unquote(ast)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done ✅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just very minor comments left. :)
Co-authored-by: José Valim <jose.valim@dashbit.co>
Co-authored-by: José Valim <jose.valim@dashbit.co>
Co-authored-by: José Valim <jose.valim@dashbit.co>
Co-authored-by: José Valim <jose.valim@dashbit.co>
Co-authored-by: José Valim <jose.valim@dashbit.co>
defmacrop dbg_format(ast, options \\ quote(do: [syntax_colors: []])) do | ||
quote do | ||
ExUnit.CaptureIO.with_io(fn -> | ||
unquote(Macro.dbg(ast, options, __CALLER__)) | ||
end) | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opted to avoid the "no I/O" testing strategy for now in favor of simplicity. Testing with capturing I/O lets us keep the code in Macro
simpler, with less functions involved. This should be fast enough for now. If we add a lot more tests, we can always go back to a purely-functional testing approach by reworking the new Macro
functions slightly.
lib/elixir/lib/macro.ex
Outdated
|
||
quote do | ||
unquote(values_ast) | ||
{:pipe, unquote(escape(asts)), Enum.reverse(unquote(values_acc_var))} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done ✅
lib/elixir/lib/macro.ex
Outdated
|
||
# Any other AST. | ||
defp dbg_ast_to_debuggable(ast) do | ||
quote do: {:value, unquote(escape(ast)), unquote(ast)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done ✅
64ed871
to
6330524
Compare
@josevalim ready for final review, I think. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful!!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😍
This is amazing! Two quick questions. For this file: # foo.exs
dbg("foo")
"foo" |> String.upcase() |> dbg I'm getting:
|
@whatyouhide fantastic job!! 🐱 |
No description provided.