alexander-myltsev / parboiled2

a Macro-Based PEG Parser Generator for Scala
Other
13 stars 2 forks source link

Lots of warnings when compiling with -Xlog-implicits=true #3

Closed NicolasRouquette closed 10 years ago

NicolasRouquette commented 10 years ago

I really like parboiled2 and to better understand what's going on, I configured the project's Scala compiler settings in Eclipse (Luna with Scala IDE 4.0 M3) with: -Xlog-implicits=true

This results in lots of warnings; e.g., in the JsonParser.scala example:

{code} def JsonTrue = rule { "true" ~ WhiteSpace ~ push(JsTrue) } {code}

{quote} Multiple markers at this line

Here is a different kind of problem:

{code} object JsonParser extends App { for (i <- 0 to 100) new JsonParser(Test.json).Json.run().get // << markers } {code}

{quote} Multiple markers at this line

What do these messages really mean?

If these messages are harmless, Is there a way to write the code in a way that does not produce these?

alexander-myltsev commented 10 years ago

@NicolasRouquette ,

why do you need implicits log? What are you trying to build? parboiled2 from sources or your own project? Take a look at https://github.com/alexander-myltsev/parboiled2-samples , might be helpful.

NicolasRouquette commented 10 years ago

@alexander-myltsev ,

In love Scala and I feel that I am responsible to be proficient in using the language effectively for my job. This implies that where my code leads to implicit conversions and macros from third-party libraries (e.g. parboiled2), I need to be cognizant about that this does for me. Finally, I am also interested in the prospect of compiling scala => js because I abhor the idea of working with an untyped language. Since I really like parboiled2, I felt that this would be a good place to start exploring this topics incrementally.

When working with parboiled2, I noticed that as I managed to take better advantage of powerful features such as case class instance creation, then the Eclipse scala presentation compiler worked faster. So, better use of parboiled2 translates into less overhead in the Eclipse scala presentation compiler. Gee, that's cool! How does this work?

This led me to trying to "see" what the compiler does; i.e:

-Xlog-implicits=true is a good start but the result is not very user-friendly to read.

I'm looking for the Scala equivalent of "macroexpand-1" and "macroexpand" from Common Lisp -- see: http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node99.html#SECTION001220000000000000000

I haven't ventured into scala=>js compilation yet.

alexander-myltsev commented 10 years ago

@NicolasRouquette

there is nothing else in Scala world that -Xlog-implicits=true. Only eyeball-ing at your own code. IDEA could provide you some handy information too.

You can run scalac in verbose mode and see what each scalac phase looks like. I warn you that there is lots of text there as well.

You could also experiment with println-ing scala AST here

alexander-myltsev commented 10 years ago

Ah, as for parboiled2-js. I had time only for porting some parboiled2 examples to scala-js. They seems to be working, and I'm happy with that. But honestly I fully trust to scalajs team, and not completely sure if parboiled2.js actually does what it is supposed to. You are welcomed to investigate it yourself and share your results to community.