Clojure

Add a pseudo-variable containing the current line number

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: Release 1.3
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    Any
  • Patch:
    Code and Test

Description

Add a pseudo-variable (similar to *file*), containing the current line number. This should be available during AOT compilation. The name "*line-number*" might be good.

It will be useful for diagnostic log messages. Using exception stack traces has poor runtime performance and the line number should be available to the compiler at minimal cost.

Activity

Hide
Peter Siewert added a comment - - edited

Adding initial patch. A symbol's position is now stored in its metadata, just like a seq when it is read with the LispReader.

The Compiler.LINE and Compiler.COLUMN values are now updated as each symbol is analyzed. This provides more exact line and column numbers for Compiler errors which will resolve ticket CLJ-420.

The Compiler.LINE variable has been interned as clojure.core/line-number

Adding extra metadata to symbols resulted in some tests failing due to the extra values. The failing tests have been updated to ignore the new metadata keys.

Show
Peter Siewert added a comment - - edited Adding initial patch. A symbol's position is now stored in its metadata, just like a seq when it is read with the LispReader. The Compiler.LINE and Compiler.COLUMN values are now updated as each symbol is analyzed. This provides more exact line and column numbers for Compiler errors which will resolve ticket CLJ-420. The Compiler.LINE variable has been interned as clojure.core/line-number Adding extra metadata to symbols resulted in some tests failing due to the extra values. The failing tests have been updated to ignore the new metadata keys.
Hide
Andy Fingerhut added a comment -

Patch CLJ-849-line-number-pesudo-variable.diff dated Nov 14, 2012 used to apply cleanly and pass tests, but no longer applies cleanly after Jul 7 2013 when a conflicting change with subject "don't presume Integer for LINE and COLUMN, fixes round-trip" was committed to Clojure: https://github.com/clojure/clojure/commit/229bf8fe9a751e4f48bb2b7ea57e27ebc43d26ae

Show
Andy Fingerhut added a comment - Patch CLJ-849-line-number-pesudo-variable.diff dated Nov 14, 2012 used to apply cleanly and pass tests, but no longer applies cleanly after Jul 7 2013 when a conflicting change with subject "don't presume Integer for LINE and COLUMN, fixes round-trip" was committed to Clojure: https://github.com/clojure/clojure/commit/229bf8fe9a751e4f48bb2b7ea57e27ebc43d26ae

People

Vote (0)
Watch (3)

Dates

  • Created:
    Updated: