r/ProgrammingLanguages • Futhark • Jun 18 '26

Data parallel pretty-printing

https://futhark-lang.org/blog/2026-06-18-data-parallel-pretty-printing.html
16 Upvotes

4 comments sorted by

View all comments

Show parent comment

2

u/matthieum Jun 19 '26

Eytzinger is generally used for a balanced binary tree. An expression tree is quite different however.

I mean, let's take the OP's operation:

[#op 3 #mul 4, #num 8, #num 20, #op 1 #add 2, #num 42]

Encodes:

(8 + 20) * (42)

It's arguable balanced because the first two levels (* and + & 42) are full, but we can already see the left-hand side could extend into more levels without the right-hand side following.

Also, for parsing, it'd be easier if we just pushed as we go:

  • [#num 8]
  • [#num 8, #num 20, #op 0 #add 1]
  • [#num 8, #num 20, #op 0 #add 1, #num 42, #op 2 #mul 3]

Which here so happens to be a reversed Eytzinger layout, but once again just 'cuz it's so short in the first place.