From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Maxime Devos Newsgroups: gmane.lisp.guile.devel Subject: RE: [BUG] Eval sets incorrect runtime metainformation Date: Wed, 26 Jun 2024 11:36:11 +0200 Message-ID: <20240626113611.g9cB2C0023K6y2F069cBEe@michel.telenet-ops.be> References: <87bk3pkqmt.fsf@trop.in> <87msn86ops.fsf@igalia.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="_76E94F53-DBC4-4655-BED0-BBB14DAE8D29_" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7310"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "guile-devel@gnu.org" To: Andy Wingo , Andrew Tropin Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Wed Jun 26 11:37:08 2024 Return-path: Envelope-to: guile-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sMP5Q-0001g8-Km for guile-devel@m.gmane-mx.org; Wed, 26 Jun 2024 11:37:08 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMP4m-0002U1-F8; Wed, 26 Jun 2024 05:36:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sMP4h-0002TW-TR for guile-devel@gnu.org; Wed, 26 Jun 2024 05:36:24 -0400 Original-Received: from michel.telenet-ops.be ([2a02:1800:110:4::f00:18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMP4d-0002TB-Kj for guile-devel@gnu.org; Wed, 26 Jun 2024 05:36:22 -0400 Original-Received: from [IPv6:2a02:1811:8c0e:ef00:797d:1e87:23cd:1cb3] ([IPv6:2a02:1811:8c0e:ef00:797d:1e87:23cd:1cb3]) by michel.telenet-ops.be with bizsmtp id g9cB2C0023K6y2F069cBEe; Wed, 26 Jun 2024 11:36:11 +0200 Importance: normal X-Priority: 3 In-Reply-To: <87msn86ops.fsf@igalia.com> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=telenet.be; s=r24; t=1719394571; bh=lCQ+C4/ahg8uFYCOR6JUp0b2+Jxk/KwY8sf4bqsWMIs=; h=To:Cc:From:Subject:Date:In-Reply-To:References; b=bEXlPcnEw4K+0dFw+9Ma5n0446mg1pA4QPZ9yzYkeBmXt7PIXQYK07PwjDXf7mrr+ CD0FH3yfw6rw1wDkBj/2LX6aHkSnQjKP4bCuqRUn9mJVPdv9OLuv3ZxPHYh+29/K1P 9rNNsPsl6orgryUku9dp8jOteBfK7GWp2f74SviI2v0TojQ+i6LYD8sx1JNfnUYiyN j7dm6Gb4tnKiJ+xyXebV8VkhbKHQOQBW1G9rB8//4AlmIxRmjDM8EBU83l4Tiq0SzC fSs4Q85o183CtiOuMJvdIHzxnq4M3woMiJXdXjR8ZqTjzrKXXpCLwCPCzfo5o1n6cB dpeTrYZU6Ebtg== Received-SPF: pass client-ip=2a02:1800:110:4::f00:18; envelope-from=maximedevos@telenet.be; helo=michel.telenet-ops.be X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.devel:22480 Archived-At: --_76E94F53-DBC4-4655-BED0-BBB14DAE8D29_ Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" > (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/ev= al.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.ht= ml. IIRC, the question wasn=E2=80=99t about debugging in general, it was about = source locations in particular. Surely program-sources (or, in this case, p= rocedure-source maybe?) (why are the procedures in this family even named p= rogram-whatever, this prevents doing the same for interpreted code later) c= ould be adjusted to also work for =E2=80=98eval=E2=80=99. For example, =E2= =80=98eval=E2=80=99 could set the =E2=80=98source=E2=80=99 (*) procedure pr= operty when a closure is made. Likewise for arity and procedure name. (*) Looking at https://www.gnu.org/software/guile/manual/html_node/Procedur= e-Properties.html, it appears the documentation doesn=E2=80=99t actually do= cument what the =E2=80=98source=E2=80=99 property is for =E2=80=93 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. Something else will work as well: adjusting =E2=80=98eval=E2=80=99 to set p= rocedure properties or something like that. >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.ht= ml. 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.ht= ml. But that's limited and doesn't take macros, etc into account. That=E2=80=99s the job of =E2=80=98eval=E2=80=99, not the user of =E2=80=98= eval=E2=80=99. Best regards, Maxime Devos. --_76E94F53-DBC4-4655-BED0-BBB14DAE8D29_ Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="utf-8"

> = (use-modules (system vm program)

>=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (ice-9 e= val-string))

> 

> (eval-string "(define (test-fn) 'hey)"

>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 #:file "hello.scm"

= >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 #:line 1

>=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 #:column 1

>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 #:compile? #f)

> = ;

> (format #t "~a\n" (program-s= ources test-fn))

> ;; ((0 ice-9/eval.scm 329 . 1= 3) (12 ice-9/eval.scm 330 . 21) (44 ice-9/eval.scm 330 . 15))

 

>What you are see= ing here is that in general the debugging experience is

different for interpreted and compiled procedures.=C2=A0 For example, = you

will not be able to set a breakpoint in interpr= eted code, because the

code for the closure that is= part of `eval` corresponds to potentially

many dif= ferent functions.=C2=A0 program-sources will only work usefully on

compiled procedures.

>https://ww= w.gnu.org/software/guile/manual/html_node/Compiled-Procedures.html.

 

IIRC, the questi= on wasn=E2=80=99t 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 =E2=80=98eval=E2=80=99. For example, =E2=80=98eval=E2=80= =99 could set the =E2=80=98source=E2=80=99 (*) procedure property when a cl= osure is made.

 

Likewise for arity and procedure name.

&= nbsp;

(*) Looking at https://w= ww.gnu.org/software/guile/manual/html_node/Procedure-Properties.html, i= t appears the documentation doesn=E2=80=99t actually document what the =E2= =80=98source=E2=80=99 property is for =E2=80=93 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.=C2=A0 Nothing else wil= l work as you like.

 

Something else will work as well: adjusting =E2=80=98eval=E2= =80=99 to set procedure properties or something like that.

 

>That said, the evalua= tor 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.h= tml.

If you know that you are making a procedure yo= u can insert some

meta-data for use by your run-tim= e, in an initial vector alist.=C2=A0 See

https://ww= w.gnu.org/software/guile/manual/html_node/Procedure-Properties.html.

But that's limited and doesn't take macros, etc into acco= unt.

 

That= =E2=80=99s the job of =E2=80=98eval=E2=80=99, not the user of =E2=80=98eval= =E2=80=99.

 

Best regards,

Maxime Devos.

= --_76E94F53-DBC4-4655-BED0-BBB14DAE8D29_--