Fix SB-EXT:COMPILE-FILE-LINE

Bug #1604554 reported by Andrzej Walczak
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
SBCL
New
Undecided
Unassigned

Bug Description

Having the ability to derive file and line numbers at compile time would be very useful for a functionality like logging, assertions, or other application specific forms of reporting.

Douglas Katzman provided us with SB-EXT:COMPILE-FILE-LINE macro in version 1.2.11.

Unfortunately, after few attempts we gave up on this macro for various reasons:

- it contained several bugs that surfaced when compiling a large (>> 1M LOC) Lisp project.
  E.g. the code relied on the assumption that forms referenced by form-paths are always lists,
  while quotes and commas in macros generate structures that have form-paths.

- it was difficult to debug and understand the code. I.e. it contained multiple loops, multiple
  ways to call itself recursively, duplicated code with slight alterations, and virtually
  no comments about how it works besides: "Modulo any bugs due to near-total lack of testing."

- the interface was a macro that would produce a (VALUES <line> <column>) form,
  which is strange when what the user wants is a function that can be called at compile time.

Attached is a fix that simplifies the code and does not break at compile time for the aforementioned project. We had to rewrite/remove the "compute-compile-file-position" and "compile-file-position-helper" functions because the code was hardly debug-able and transparent at compile time.

Things for further consideration.
It would be nice if the function "compute-compile-line-and-column" was exported from SB-EXT
to provide functional access to the information without need of macroexpand.

Tags: reader
Revision history for this message
Andrzej Walczak (andrzejwalczak) wrote :
tags: added: reader
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Patches

Remote bug watches

Bug watches keep track of this bug in other bug trackers.