On 2024-06-26 18:04, Andy Wingo wrote:

> On Wed 26 Jun 2024 11:36, Maxime Devos <maximede...@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.

Does it mean, we could want another eval implementation, which is a bit
havier, but will preserve additional meta-data?

not-that-primitive-and-a-bit-fancier-eval :)

>
> 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

-- 
Best regards,
Andrew Tropin

Attachment: signature.asc
Description: PGP signature

Reply via email to