Open bmyerz opened 9 years ago
Limitations in case classes: https://github.com/lihaoyi/macropy#limitations
in particular,
__slots__
is used, we cannot rely on adding attributes dynamically. This is generally a good thing! But I know there is some logic that will have to be rewrittenAlgebra
elements then inherit from it (not sure how this works with __slots__
for additional attributes)
We currently have very strict rules about Algebra classes, such as repr that can be used to construct the object, and yet we write the same code over and over for each new operator. MacroPy has algebraic data types to avoid much of this.
https://github.com/lihaoyi/macropy#case-classes
While writing an overly complicated rule match and hating it, I came across macropy. The second benefit of these macros is that you can do case pattern matches, which would simplify and better-document the checks of rules. Find any compiler/interpreter written in a functional-friendly language like OCaml or Scala and you'll see pattern matching on algebraic data types.