Skip to content

Conversation

@rtfpessoa
Copy link
Contributor

Allows to get string representations for code passed in the interpolated
values

inline def logged(p1: => Any) = {
  val c = code"code: $p1"
  val res = p1
  (c, p1)
}
logged(indentity("foo"))

is equivalent to:

("code: indentity("foo")", indentity("foo"))

Copy link
Member

@dottybot dottybot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, and thank you for opening this PR! 🎉

All contributors have signed the CLA, thank you! ❤️

Have an awesome day! ☀️

@rtfpessoa rtfpessoa force-pushed the add-code-interpolation branch from 7899ae0 to 78e65e4 Compare June 11, 2019 13:20
Allows to get string representations for code passed in the interpolated
values

```scala
inline def logged(p1: => Any) = {
  val c = code"code: $p1"
  val res = p1
  (c, p1)
}
logged(indentity("foo"))
```

is equivalent to:
```scala
("code: indentity("foo")", indentity("foo"))
```
@rtfpessoa rtfpessoa force-pushed the add-code-interpolation branch from 78e65e4 to 3142de6 Compare June 11, 2019 13:22
@rtfpessoa
Copy link
Contributor Author

Thanks a lot to @nicolasstucki and @biboudis for the help, coaching and patience.

@biboudis
Copy link
Contributor

Nice work!

@allanrenucci
Copy link
Contributor

What is the rational to implement this in the compiler instead of as a macro?

@nicolasstucki
Copy link
Contributor

As we plan to use this feature inside the standard library we cannot use a macro due to potential bootstrapping issues.

@nicolasstucki nicolasstucki merged commit 655fbfe into scala:master Jun 14, 2019
@nicolasstucki
Copy link
Contributor

Thanks @rtfpessoa

@anatoliykmetyuk anatoliykmetyuk added this to the 0.17 Tech Preview milestone Jul 22, 2019
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.

6 participants