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

Syntax class for specifying port on submodule #1

Closed
sgpthomas opened this issue Jul 18, 2019 · 2 comments
Closed

Syntax class for specifying port on submodule #1

sgpthomas opened this issue Jul 18, 2019 · 2 comments

Comments

@sgpthomas
Copy link
Collaborator

Right now I have this nonsense:

    (pattern (u:id @ uport:id -> v:id @ vport:id)
             #:with fun #'(connect 'u 'uport 'v 'vport))
    (pattern (u:id -> v:id @ vport:id)
             #:with fun #'(connect 'u 'inf# 'v 'vport))
    (pattern (u:id @ uport:id -> v:id)
             #:with fun #'(connect 'u 'uport 'v 'inf#))
    (pattern (u:id -> v:id)
             #:with fun #'(connect 'u 'inf# 'v 'inf#))

It really seems like I should be able to factor out a syntax class that has two forms:
(x:id @ port:id) -> 'x , 'port and (x:id) -> 'x, 'inf#
and then rewrite the above in a single line. However, I wasn't able to do this without
needing parenthesis around the syntax class. In other words, I could factor it out, but then I would need to write (define/module ..... [(sub @ left) -> (out)] instead of [sub @ left -> out].
I wanted to avoid more parenthesis. I know, blasphemy.

@rachitnigam
Copy link
Contributor

I've been previously able to do this using ~seq and ~optional.

See this macro in the array visualizer.

Also, this blog post series is very useful: https://www.greghendershott.com/fear-of-macros/

@sgpthomas
Copy link
Collaborator Author

Got it! I needed a splicing syntax class and some ~seq's and ~optionals

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

No branches or pull requests

2 participants