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

Print intermediate results of dbg for boolean operators #14217

Merged
merged 1 commit into from
Jan 23, 2025

Conversation

sabiwara
Copy link
Contributor

@sabiwara sabiwara commented Jan 23, 2025

Taking 40164fc one step further and support and/or boolean operators, leveraging the new list of nodes approach:

Screenshot 2025-01-23 at 19 26 58

Basically we'll generate these:

# node 1
{:multi_value, {:falsy, [], nil}, result = falsy}

# node 2
(
  result = result || x
  {:multi_value, {:||, [], [{:falsy, [], nil}, {:x, [], nil}]}, result}
)

# node 3
(
  result = result && 1 / x
  {:value, {:&&, [], [...args]},, result}
)

I think __block__ would make sense too and could be done in a same way.

@sabiwara sabiwara merged commit fb7a22e into elixir-lang:main Jan 23, 2025
8 of 9 checks passed
@sabiwara sabiwara deleted the dbg-and-or branch January 23, 2025 08:25
@sabiwara
Copy link
Contributor Author

@josevalim for code blocks, I think we could do it if we simplify it a bit (no loss IMHO):

(a=1; b=2; a + b) |> dbg()

Current:

Code block:
(
  a = 1 #=> 1
  b = 2 #=> 2
  a + b #=> 3
)

Instead I propose:

a = 1 #=> 1
b = 2 #=> 2
a + b #=> 3

WDYT?

@josevalim
Copy link
Member

Agreed!

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

Successfully merging this pull request may close these issues.

2 participants