From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Han-Wen Nienhuys Newsgroups: gmane.lisp.guile.devel Subject: Re: unhandled constant? Date: Sat, 1 Feb 2020 10:54:01 +0100 Message-ID: References: <8d77f905-31e9-4d0b-973a-82be38360e07@www.fastmail.com> <07e36ec2-0c0c-4786-9040-ffcb3418e0bb@www.fastmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="8875"; mail-complaints-to="usenet@ciao.gmane.io" Cc: guile-devel@gnu.org To: =?UTF-8?Q?Linus_Bj=C3=B6rnstam?= Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Sat Feb 01 10:54:31 2020 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 1ixpTy-00029A-6m for guile-devel@m.gmane-mx.org; Sat, 01 Feb 2020 10:54:30 +0100 Original-Received: from localhost ([::1]:37306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixpTw-0007b8-TK for guile-devel@m.gmane-mx.org; Sat, 01 Feb 2020 04:54:28 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39438) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixpTk-0007aq-TW for guile-devel@gnu.org; Sat, 01 Feb 2020 04:54:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixpTj-0005Iw-Dm for guile-devel@gnu.org; Sat, 01 Feb 2020 04:54:16 -0500 Original-Received: from mail-oi1-x22f.google.com ([2607:f8b0:4864:20::22f]:45363) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ixpTj-0005Im-92 for guile-devel@gnu.org; Sat, 01 Feb 2020 04:54:15 -0500 Original-Received: by mail-oi1-x22f.google.com with SMTP id v19so9872179oic.12 for ; Sat, 01 Feb 2020 01:54:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=D0ITO1fxTFgO2ZAAdqefgKP7efn2F/DVnMSQEoX4ZVM=; b=gsXWS/OxwUSKqQfxh0lKjIGFji9Fv8JhGn5LzRYmdz12c7WlkEJvwkzGs33UB6Xjtx MiS634ELwrMGgoEJM6TJX2JRw4JSHjEyFB4Leq1yhtXuYT2hJ+Cz45JEcGCG9VTWWacN wcDfqaW/ZVCNJ+HKh/87PfMwXkJ0ciuES0skim5ynJwSOAUzByDLmqNwzHBx+cnUJtZt h8AxZZC+zuki33ReinEWlzgpzPqajjYpmgyboLkxcMHymWaZXeN2y24iLBLAwMVsdfZh rf8ZRZ0lm7lg0SGVDlzYOSBeSw7R+r7toXZUibMlcIvMurqr4Q0qtC3yd7vmzbEOn7b+ L41A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=D0ITO1fxTFgO2ZAAdqefgKP7efn2F/DVnMSQEoX4ZVM=; b=UzH98+ezVg9O7xBC5y0Ki8uRoPnBNsOkkQ2fnzGWVxPGCHU+m3UJUVTR3zyVS5Dr34 roiZfYzms75WiwSC91LbIT+RHLzvX62QISyI0fjsPG2dI3VLPSVR6HfRJlbvwoKQS5xL 8TEeb5pDCNQ0CeOjXY7wcTa6zhMVDJeVgGrQPAceGff+7SgA8WS/T6cHW1TMCMVxKB56 Pgvvuts7R3ppygRpFaJzhHTegS+LkFgSr23nj4fJmbdvTFiZ1E7h6sExBWlyCeZJI3oX V9C2bcOTOJz/MzMAEbEMTv/5vEb/QBOrwtsXp+mtEr7sN2lI5KpmY4OGAf2hK5gXdHjm Fi4A== X-Gm-Message-State: APjAAAW1OxRBAY3DTckdkgoH8lfPBMeYoyTZLRjhGUYH/e6xb2rQS1ep H9x+MDG97j2w+qAlhd/4ZTSolO+WliTTFBvlD1PbPoZrf6o= X-Google-Smtp-Source: APXvYqwP8yCWZrQX5sM4RwCFqod2itWMgZZiWU6hHfbyxrzVOpMlyLwMTL9hG89R3zvP8offgU55eGfAClcv1N+s+yM= X-Received: by 2002:aca:503:: with SMTP id 3mr9310050oif.106.1580550854146; Sat, 01 Feb 2020 01:54:14 -0800 (PST) In-Reply-To: <07e36ec2-0c0c-4786-9040-ffcb3418e0bb@www.fastmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::22f X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.23 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" Xref: news.gmane.io gmane.lisp.guile.devel:20365 Archived-At: Here is an example that shows better how things work, and what might be the cause of my problems. Is it right that programmatically set contents of "current-module" are not serialized into the compiled file? (define (run-at-compile-time cmd) (module-define! (current-module) (string->symbol cmd) #t) (format (current-error-port) "I-am-called-at-compile-time ~a\n" cmd)) (define (runtime-call cmd) (format (current-error-port) "I-am-called-at-runtime ~a\n" cmd) (format (current-error-port) "val ~a\n" (module-ref (current-module) (string->symbol cmd)))) (defmacro foo (cmd . rest) (run-at-compile-time cmd) `(runtime-call ,cmd)) (foo "xy") $ guile1.8 ew.scm I-am-called-at-compile-time xy I-am-called-at-runtime xy val #t this is compatible with 2.2 without compilation, $ GUILE_AUTO_COMPILE=3D0 guile2.2 ew.scm I-am-called-at-compile-time xy I-am-called-at-runtime xy val #t but compilation fails $ GUILE_AUTO_COMPILE=3D1 guile2.2 ew.scm ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=3D0 ;;; or pass the --no-auto-compile argument to disable. ;;; compiling /home/hanwen/vc/lilypond/ew.scm ;;; WARNING: compilation of /home/hanwen/vc/lilypond/ew.scm failed: ;;; Unbound variable: run-at-compile-time $ guild2.2 compile ew.scm Backtrace: In system/base/target.scm: 57:6 19 (with-target _ _) In system/base/compile.scm: .. Unbound variable: run-at-compile-time If I encapsulate the run-at-compile-time definition with (eval-when (compile eval) it works if I remove the module manipulation, but the module-ref doesn't work. It looks like the settings from module-define! are not serialized into the byte code, so I can't have code that relies on correspondence between module-define driven from macros and module-ref during evaluation. [hanwen@localhost lilypond]$ guild2.2 compile ew.scm I-am-called-at-compile-time xy wrote `/home/hanwen/.cache/guile/ccache/2.2-LE-8-3.A/home/hanwen/vc/lilypon= d/ew.scm.go' [hanwen@localhost lilypond]$ GUILE_AUTO_COMPILE=3D0 guile2.2 ew.scm I-am-called-at-runtime xy Backtrace: 6 (apply-smob/1 #) In ice-9/boot-9.scm: 705:2 5 (call-with-prompt ("prompt") # =E2=80=A6) In ice-9/eval.scm: 619:8 4 (_ #(#(#))) In ice-9/boot-9.scm: 2312:4 3 (save-module-excursion #) 3832:12 2 (_) In ew.scm: 10:10 1 (runtime-call "xy") In unknown file: 0 (scm-error misc-error #f "~A ~S ~S ~S" ("No variabl=E2=80=A6" = =E2=80=A6) =E2=80=A6) ERROR: In procedure scm-error: No variable named xy in # On Fri, Jan 31, 2020 at 9:01 PM Linus Bj=C3=B6rnstam wrote: > > Read the docs. That seems to be a documentation bug. Try fiddling with th= e arguments to eval when and see if you can make it work. > > -- > Linus Bj=C3=B6rnstam > > On Fri, 31 Jan 2020, at 20:17, Han-Wen Nienhuys wrote: > > On Fri, Jan 31, 2020 at 7:20 PM Linus Bj=C3=B6rnstam > > wrote: > > > I don't really understand your question. With defmacro and syntax-cas= e you can run arbitrary code. If you just output code that does module-defi= ne! that won't be run until runtime, and thus you cannot depend on the resu= lt of that module-define! during expansion. You can however wrap it in an e= val-when to solve that issue. That allows you to specify when code gets run= . With module-define! I personally find it all a bit icky, but I usually st= ay as far away from phasing as I can :) > > > > eval-when looks like it might be a solution to the puzzle , but > > honestly, the doc at > > > > https://www.gnu.org/software/guile/manual/html_node/Eval-When.html > > > > has me mystified. When I run the example through guile 2.2 and > > display *compilation-date*, > > > > I get a different answer each time. Shouldn't it be a fixed timestamp > > (of when the compile happened?) > > > > [hanwen@localhost lilypond]$ guile2.2 e.scm > > ;;; note: source file /home/hanwen/vc/lilypond/e.scm > > ;;; newer than compiled > > /home/hanwen/.cache/guile/ccache/2.2-LE-8-3.A/home/hanwen/vc/lilypond/e= .scm.go > > ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=3D0 > > ;;; or pass the --no-auto-compile argument to disable. > > ;;; compiling /home/hanwen/vc/lilypond/e.scm > > ;;; compiled > > /home/hanwen/.cache/guile/ccache/2.2-LE-8-3.A/home/hanwen/vc/lilypond/e= .scm.go > > Fri Jan 31 20:15:57+0100 2020 > > [hanwen@localhost lilypond]$ guile2.2 e.scm > > Fri Jan 31 20:15:58+0100 2020 > > [hanwen@localhost lilypond]$ guile2.2 e.scm > > Fri Jan 31 20:16:00+0100 2020 > > > > -- > > Han-Wen Nienhuys - hanwenn@gmail.com - http://www.xs4all.nl/~hanwen > > --=20 Han-Wen Nienhuys - hanwenn@gmail.com - http://www.xs4all.nl/~hanwen