unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Andrew Tropin <andrew@trop.in>
To: Andy Wingo <wingo@pobox.com>
Cc: Maxime Devos <maximedevos@telenet.be>,
	"guile-devel@gnu.org" <guile-devel@gnu.org>
Subject: RE: [BUG] Eval sets incorrect runtime metainformation
Date: Wed, 26 Jun 2024 15:41:45 +0400	[thread overview]
Message-ID: <87tthgj5hi.fsf@trop.in> (raw)
In-Reply-To: <20240626113611.g9cB2C0023K6y2F069cBEe@michel.telenet-ops.be>

[-- Attachment #1: Type: text/plain, Size: 4109 bytes --]

On 2024-06-26 11:36, Maxime Devos wrote:

>>> (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.
>
> 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.
>
> Likewise for arity and procedure name.
>
> (*) Looking at
> https://www.gnu.org/software/guile/manual/html_node/Procedure-Properties.html,
> it appears the documentation doesn’t actually document what the
> ‘source’ property is for – It could be interpreted in multiple ways
> currently.
>
>>I would suggest that if you are working on a rich IDE, that you pass
>> #:compile? #t.  Nothing else will work as you like.

I do pass (use compile directly to be more precise) :) but there is
another very important problem related to this approach:
https://yhetil.org/guile-devel/20240621164008.eEg72C00D1xd29F01Eg7DF@baptiste.telenet-ops.be/T/#t

It also leads to problem with define-once, which sets the value to
#<unspecified> in most cases, when "evaluated" with compile.

>
> Something else will work as well: adjusting ‘eval’ to set procedure
> properties or something like that.

Agree with Maxime here, and that is what I propose in the original
message.

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

Yep, that's is why I wrote:

--8<---------------cut here---------------start------------->8---
The another related problem is that the metainformation is stored in
prodecures properties, but not in variables, which makes it impossible
to implement a proper goto definition in general case.
--8<---------------cut here---------------end--------------->8---

How hard is to make a generic metainformation, which is attachable to
macros, symbols and other objects of the language, not only to
procedures?

>> 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.
>
> That’s the job of ‘eval’, not the user of ‘eval’.

Think the same, eval should respect information provided by reader and
attach it to corresponding objects.

-- 
Best regards,
Andrew Tropin

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

  reply	other threads:[~2024-06-26 11:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-25 15:07 [BUG] Eval sets incorrect runtime metainformation Andrew Tropin
2024-06-26  9:24 ` Andy Wingo
2024-06-26  9:36   ` Maxime Devos
2024-06-26 11:41     ` Andrew Tropin [this message]
2024-06-26 22:06       ` Philip McGrath
2024-06-28 13:20         ` Andrew Tropin
2024-06-29 19:55           ` Philip McGrath
2024-06-29 23:05         ` Maxime Devos
2024-06-30 22:27           ` Philip McGrath
2024-07-01  9:06             ` Maxime Devos
2024-07-06 16:42             ` Rob Browning
2024-07-06 18:56             ` Matt Wette
2024-06-26 16:04     ` Andy Wingo
2024-06-28 13:27       ` Andrew Tropin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tthgj5hi.fsf@trop.in \
    --to=andrew@trop.in \
    --cc=guile-devel@gnu.org \
    --cc=maximedevos@telenet.be \
    --cc=wingo@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).