Skip to content

Conversation

@nicolasstucki
Copy link
Contributor

@nicolasstucki nicolasstucki commented Apr 2, 2019

This PR adds:

  • runtime logic for pattern matching on '{ ... }
  • Literal pattern to match a literal expression and extract its value

With this we will be able to write and run pattern matches like

def optimize(expr: Expr[Int]): Expr[Int] = expr match {
  case '{ 0 + $y } => optimize(y)
  case '{ ${Literal(a)} + ${Literal(b)} } => (a + b).toExpr
  case '{ ${x} + ${y @ Literal(_)} } => optimize('{ $y + $x })
  ...
  case expr => expr
}

@nicolasstucki nicolasstucki force-pushed the add-quote-patterns-runntime branch 4 times, most recently from 2a264a8 to 2094f9a Compare April 2, 2019 12:47
@nicolasstucki nicolasstucki marked this pull request as ready for review April 2, 2019 12:49
@nicolasstucki nicolasstucki requested a review from odersky April 2, 2019 12:49
@nicolasstucki nicolasstucki mentioned this pull request Apr 2, 2019
5 tasks
@nicolasstucki nicolasstucki force-pushed the add-quote-patterns-runntime branch from 1233e51 to ac58dc2 Compare April 5, 2019 07:35
@nicolasstucki
Copy link
Contributor Author

Rebased

@odersky odersky assigned nicolasstucki and unassigned odersky Apr 5, 2019
This PR adds:
* runtime logic for pattern matching on `'{ ... }`
* `Literal` pattern to match a literal expression and extract its value
@nicolasstucki nicolasstucki force-pushed the add-quote-patterns-runntime branch from ac58dc2 to 41d24df Compare April 5, 2019 14:53
@nicolasstucki nicolasstucki requested a review from odersky April 5, 2019 16:04
@odersky odersky merged commit 449008e into scala:master Apr 6, 2019
@ghost ghost removed the stat:needs review label Apr 6, 2019
@allanrenucci allanrenucci deleted the add-quote-patterns-runntime branch April 6, 2019 16:18
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

Successfully merging this pull request may close these issues.

2 participants