Decorator Macro stacking #8

Closed
lihaoyi opened this Issue May 9, 2013 · 1 comment

Projects

None yet

2 participants

Owner
lihaoyi commented May 9, 2013

Decorator macros are currently hardcoded to only work with a single decorator:

if  (isinstance(tree, ClassDef)
                    and len(tree.decorator_list) == 1
                    and tree.decorator_list[0]
                    and type(tree.decorator_list[0]) is Name
                    and tree.decorator_list[0].id in module.decorator_registry):

because I was lazy when i was getting it done and just wanted to hack something together. Ideally, we would have proper decorator stacking semantics for our macros, allowing multiple decorator macros or decorator macros mixed with normal decorators.

@jnhnum1 jnhnum1 was assigned May 14, 2013
Collaborator
jnhnum1 commented May 14, 2013

This is mostly done. There are some unresolved questions about what the semantics should be, like in case classes where the @case macro generates a list of class declarations. If you stack something like

@decorator1
@case
class List:
  class Cons(x, xs):  pass
  class Nil(): pass

Should @decorator1 be applied to all of the generated classes?  Or should this be disallowed?  Anyways, the current behavior disallows this.
@jnhnum1 jnhnum1 closed this May 14, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment