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

Make extraction of repetitive code patterns easier in quasiquotes #8164

Closed
scabug opened this issue Jan 20, 2014 · 2 comments

Comments

@scabug
Copy link

commented Jan 20, 2014

It'd be great to have support for matching over repetitive patterns in trees:

val q"def foo(..{$names: $tpes = $defaults})" = q"def foo(x: X, y: Y = Y(0))"
// names    == List(TermName("x"), TermName("y"))
// tpes     == List(tq"X", tq"Y")
// defaults == List(q"", q"Y(0)")

Currently one has to write:

val q"def foo(..$params)" = q"def foo(x: X, y: Y = Y(0))"
val names    = params.map { case q"$_ val $name: $_   = $_"       => name    }
val tpes     = params.map { case q"$_ val $_   : $tpe = $_"       => tpe     }    
val defaults = params.map { case q"$_ val $_   : $_   = $default" => default }
@scabug

This comment has been minimized.

Copy link
Author

commented Jan 20, 2014

@scabug scabug added the enhancement label Apr 7, 2017

@scabug scabug added this to the Backlog milestone Apr 7, 2017

@SethTisue

This comment has been minimized.

Copy link
Member

commented Mar 1, 2018

closing all quasiquotes tickets; see #10755

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.