Update
@ Ralph Well, this is a question from 2+ years ago, but since I have the same need for __LINE__and __FILE__, and you mentioned SCALA; here are some ideas that I have using Scala macros (from version v2.10.0-RC1)
def $currentPosition:String = macro _currentPosition;
def _currentPosition(c:Context):c.Expr[String]={ import c.universe._;
val pos = c.enclosingPosition;
c.Expr(Literal(Constant(
s"${pos.source.path}: line ${pos.line}, column ${pos.column}" )))
}
Macros, estimated at compile time , $currentPositionreplaced by a literal string that describes its position in the source code. For example, enter line printlnon line 13, it will display:
/sandbox/tmp_juno_workspace2/LogMacro_Test/src/test/Trial.scala: line 13, column 15
, , , ( , - !).