[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 11:24:47 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Hello,
On Tue 25 Jun 2024 17:07, Andrew Tropin <andrew@trop.in> writes:
> (use-modules (system vm program)
> (ice-9 eval-string))
>
> (eval-string "(define (test-fn) 'hey)"
> #:file "hello.scm"
> #:line 1
> #:column 1
> #:compile? #f)
>
> (format #t "~a\n" (program-sources test-fn))
> ;; ((0 ice-9/eval.scm 329 . 13) (12 ice-9/eval.scm 330 . 21) (44
> ice-9/eval.scm 330 . 15))
What you are seeing here is that in general the debugging experience is
different for interpreted and compiled procedures. For example, you
will not be able to set a breakpoint in interpreted code, because the
code for the closure that is part of `eval` corresponds to potentially
many different functions. program-sources will only work usefully on
compiled procedures.
https://www.gnu.org/software/guile/manual/html_node/Compiled-Procedures.html.
I would suggest that if you are working on a rich IDE, that you pass
#:compile? #t. Nothing else will work as you like.
That said, the evaluator does attach so-called "meta-data" information
to procedures, such as the procedure name.
https://www.gnu.org/software/guile/manual/html_node/Procedure-Properties.html.
If you know that you are making a procedure you can insert some
meta-data for use by your run-time, in an initial vector alist. See
https://www.gnu.org/software/guile/manual/html_node/Procedure-Properties.html.
But that's limited and doesn't take macros, etc into account.
Regards,
Andy