Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pattern matching internally #15

Open
jnhnum1 opened this issue May 13, 2013 · 5 comments
Open

Use pattern matching internally #15

jnhnum1 opened this issue May 13, 2013 · 5 comments
Labels

Comments

@jnhnum1
Copy link
Collaborator

jnhnum1 commented May 13, 2013

A lot of our transformers could use pattern matching. It would make our code nicer.

@lihaoyi
Copy link
Owner

lihaoyi commented May 19, 2013

Trying to pattern match on AST nodes causes the pattern matcher to barf because they don't have normal __init__ methods; is there a way to force keyword-only matching to bypass this?

@jnhnum1
Copy link
Collaborator Author

jnhnum1 commented May 19, 2013

I just pushed a small change which makes positional matching as needed using generators. This should fix things.

@jnhnum1
Copy link
Collaborator Author

jnhnum1 commented May 19, 2013

and...tests

@lihaoyi
Copy link
Owner

lihaoyi commented May 19, 2013

This:

with switch(tree):
        if Str(s=s):
            return q%Parser.Raw(ast%tree), stop
TypeError: <slot wrapper '__init__' of '_ast.AST' objects> is not a Python function

Is still blowing up on me. Do you want to try refactoring our macros to use pattern matching? I feel like you'll have a better shot at getting stuff working, since I suspect it will require substantial fixes to the pattern matcher to get it to work.

@jnhnum1
Copy link
Collaborator Author

jnhnum1 commented May 19, 2013

ok. yeah ugh that's annoying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants