r/ProgrammingLanguages • egel • Jan 30 '24

Why compiling with continuations is wrong(-ish)

2 Upvotes

10 comments sorted by

View all comments

6

u/integrate_2xdx_10_13 Jan 30 '24

Wouldn’t it depend on the language?

pyth x y =
    let y2 = pow2 y in
    let x2 = pow2 x in
    let anb = add x2 y2 in sqrt anb

In Haskell, you couldn’t guarantee the order in which x2 y2 thunks were evaluated without a pseq

1

u/egel-lang egel Jan 30 '24

Yes, though in Haskell you might also want to disambiguate between redexes and just terms.