java - Scala, Maven, and preprocessors -


I know all the philosophical arguments against preprocessors and macros in Java. I do not agree that some people can abuse a language facility, it should be excluded for everyone.

I have macros in my java and scala codes for efficient code logging for __ file __ and __ line __ . Any use of exception due to runtime performance effects is unacceptable. Those people argue that logging can be turned off in the "Production Code", Brian Kerngan's advice should be kept in mind:

Removing error messages "Now that the program works "It's like wearing a parachute on the ground, but taking it away when it comes in the air.

Can a macro make it in this language? If not, is there any way to run a preprocessor like M4 using Maven?

Thank you.

update @relalf Well, this is a question 2+ years ago, But since I had mentioned the __ line __ and __ file __ and you SCALA; Here are some ideas that I'm using Scala macros (like v2.10.0-RC1 )

  def $ currentPosition: String = macro _currentPosition; Def _currentPosition (c: context): c.Expr [string] = {import c.universe._; Val pos = c.enclosingPosition; C. Xp (limited ("($ {pos.source.path}": line $ {pos.line}, column $ {pos.column} "))))}  

macros Assessed on compile-time , $ currentPosition is replaced with a literal string that describes its position in the source code. For example, In line 13, a println is inserted, it displays:

  /sandbox/tmp_juno_workspace2/LogMacro_Test/src/test/Trial.scala: line 13, column 15  

I used to extensively with these mechanisms Only played, but by tweaking this thing, one may need to develop logging feature (s) (I need that writing macros can be trick - this is for me!).


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -