[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [BUG] Eval sets incorrect runtime metainformation
From: |
Andy Wingo |
Subject: |
Re: [BUG] Eval sets incorrect runtime metainformation |
Date: |
Wed, 26 Jun 2024 18:04:40 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
On Wed 26 Jun 2024 11:36, Maxime Devos <maximedevos@telenet.be> writes:
> IIRC, the question wasn’t about debugging in general, it was about
> source locations in particular. Surely program-sources (or, in this
> case, procedure-source maybe?) (why are the procedures in this family
> even named program-whatever, this prevents doing the same for
> interpreted code later) could be adjusted to also work for ‘eval’. For
> example, ‘eval’ could set the ‘source’ (*) procedure property when a
> closure is made.
I think it's really valuable to imagine how things should be but if you
are going to argue they should be different, you should first try to
understand how they are.
`program-sources` is a mapping from bytecode offsets to source
locations. For compiled procedures we can make this mapping because
each bytecode position has a single source. For interpreted procedures,
what you end up getting is the bytecode-to-source mapping *for eval*,
not for the code being interpreted.
Is it a great thing that there is a debugging (I use the term on purpose
to mean all kinds of run-time reflection etc) difference between eval
and compile? No, of course not. I would rather there not be a
difference and not have to document something that is at best
extraneous. There are differing pressures on eval: for bootstrap times
(and macro expansion time) you want it to have the least amount of
overhead possible, whereas for debugging you want to attach meta-data
that isn't strictly needed at run-time. Attaching that meta-data has
memory and time overheads.
If we are looking to get the source location *just of the interpreted
closure* -- that is possible; see eval.scm:581, there you would attach
some other properties. You would have to define a different debugging
interface that looks for source location information in a way different
from program-sources. For me it's not worth it but I encourage you to
experiment with (ice-9 eval); it's just another Scheme program. (You
would need to take a different approach to memoization, in order to pass
through source location information.)
Andy