Decrease syntax cost of usage
Opened this issue · 0 comments
Hey, thanks for sharing this example here (and, of course, the original paper). I somehow missed it back at the time but recently found it. It seems somewhat similar in spirit to my speed project from 2014 built on Scala 2 macros (with a custom enhanced reify
implementation), but without staging.
The staging approach is nice because it very explicitly moves the stream creation to compile time. I wonder, though, if this would be implemented for real there are some issues with using it:
- user needs some understanding of staging
- need two defs per stream (inline def + actual definition)
- multiple file restriction for
inline def
usage - need to pass expressions for integer literals
- lambdas require explicit
Expr => Expr
form ("manual beta reduction")
etc.
I wonder what would be needed to make this more convenient to use. The approach used in speed
was to pattern match on a given stream expression to extract the structure of a stream. The staging approach seems nicer but introduces some ceremony. Is there a middle ground? Also how far could you get with just inlining and powerful constant propagation?
/cc @nicolasstucki