2

In this post Find all implicits I've seen that there is an -Xlog-implicit-conversions option for scalac which shows implicit applications during compilation. There is also -Xprint:<phase> option which shows program code after a specified compilation phase.

But is it possible to somehow output the human-readable code after all syntactic sugar translations and implicit conversions (applications) are made?

Such ability may be useful if you are optimizing some part of the code for performance.

Community
  • 1
  • 1
Link42
  • 43
  • 4
  • What other translations would you like to see besides implicit applications? If it's just implicits you're looking for, then this is probably a duplicate of: http://stackoverflow.com/questions/34903520/figuring-out-chain-of-implicit-invocations/34903876#34903876 – Michael Zajac Nov 18 '16 at 16:52
  • @MichaelZajac I meant syntactic sugar translations. For example, for comprehension is translated to foreach, flatMap, map, filter or withFilter. And the answer you mentioned requires that you know the place where an implicit is applied, but I'm asking about the method to show all of them. – Link42 Nov 18 '16 at 17:01
  • `reify` will help, but you can only use it on expressions rather than an entire code-base. Keep in mind though, the more syntactic sugar you remove, the less human-readable the code will get. So it really depends on where you draw the line with "human readable". For example, anonymous functions like `x => x + 1` will eventually expand into something very ugly. – Michael Zajac Nov 18 '16 at 17:33

0 Answers0