Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Decorator Macro stacking #8

Closed
lihaoyi opened this Issue · 1 comment

2 participants

@lihaoyi
Owner

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
@jnhnum1
Collaborator

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.