Skip to content

Print intermediate results of dbg for boolean operators - #14217

Merged
sabiwara merged 1 commit into
elixir-lang:mainfrom
sabiwara:dbg-and-or
Jan 23, 2025
Merged

sabiwara merged 1 commit into
elixir-lang:mainfrom
sabiwara:dbg-and-or

Conversation

@sabiwara

@sabiwara sabiwara commented Jan 23, 2025 •

Copy link
Copy Markdown
Contributor

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
@sabiwara
sabiwara deleted the dbg-and-or branch January 23, 2025 08:25
@sabiwara

Copy link
Copy Markdown
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
Copy Markdown
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