Skip to content

Allow multiple splices in macros #4801

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

Closed
nicolasstucki opened this issue Jul 18, 2018 · 4 comments
Closed

Allow multiple splices in macros #4801

nicolasstucki opened this issue Jul 18, 2018 · 4 comments

Comments

@nicolasstucki
Copy link
Contributor

nicolasstucki commented Jul 18, 2018

We want to be able to write macros that have several top level splices such as

inline def foo(b: Boolean): Int = {
  if (b) ${bar(true)}
  else ${bar(false)}
}
def bar(b: Boolean)(using QuoteContext): Expr[Int] = if (b) '{1} else '{0}
@nicolasstucki
Copy link
Contributor Author

To allow macros in classes and any non-static location this is a compromise we have to do.

@Blaisorblade
Copy link
Contributor

Is the restriction documented?

@nicolasstucki
Copy link
Contributor Author

Woking on it

@nicolasstucki
Copy link
Contributor Author

This might actually be possible dot do.

@nicolasstucki nicolasstucki reopened this Jul 21, 2018
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 23, 2018
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 23, 2018
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 24, 2018
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 24, 2018
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 27, 2018
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 27, 2018
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 27, 2018
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 27, 2018
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 27, 2018
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 27, 2018
For example a transparent method can be defined as
```
transparent def foo(b: Boolean): Int =
  if (b) ~bar(true)
  else ~bar(false)
```

Removing this restriction also allows us to have a simpler implementation
of splicing and transparent def checking.
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 27, 2018
For example a transparent method can be defined as
```
transparent def foo(b: Boolean): Int =
  if (b) ~bar(true)
  else ~bar(false)
```

Removing this restriction also allows us to have a simpler implementation
of splicing and transparent def checking.
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 27, 2018
For example a transparent method can be defined as
```
transparent def foo(b: Boolean): Int =
  if (b) ~bar(true)
  else ~bar(false)
```

Removing this restriction also allows us to have a simpler implementation
of splicing and transparent def checking.

Removes last use of `Macro` flag in `ReifyQuotes`.
@nicolasstucki nicolasstucki removed their assignment Sep 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants