wolfe-pack / wolfe

Wolfe Language and Engine
https://wolfe-pack.github.io/wolfe
Apache License 2.0
135 stars 17 forks source link

Matching should happen on fully typed trees #42

Closed riedelcastro closed 10 years ago

riedelcastro commented 10 years ago

Currently pattern matching on ASTs happens partly on untyped trees (those we get through inlining of other trees in the enclosed class). Only the arguments to the macro are typed. This means that we are often checking for method name matches, which can be risky. Ideally all trees we match on should be typed.

Connected to #40: ideally ASTs should incrementally enter the macro code, and always in a typed fashion. There should be a class responsible for this functionality.

riedelcastro commented 10 years ago

Have a look at 2def4a507b71b0d1344f1e16f4922d057bb197d0. The inliner should be used incrementally during matching.

rockt commented 10 years ago

Cool! Two very basic questions for my understanding:

riedelcastro commented 10 years ago
  • Is the tree that I get by calling inlineOnce already typed?

Yes! It's unfortunate that this doesn't really show in the Spec right now.

  • Does the Inliner companion object already avoid the problem of "method name matches" by working with Symbols in definitions?

Yes, at least at the inlining level. The other problem is that a lot of pattern matching afterwards is still done by name.

riedelcastro commented 10 years ago

Done by using inlineOnce in

https://github.com/wolfe-pack/wolfe/blob/dev/src/main/scala/ml/wolfe/macros/CodeRepository.scala

S