From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrew Burgess Newsgroups: gmane.lisp.guile.user Subject: Looking For Advice On Updating Code From Guile 1.8.8 Date: Wed, 10 Feb 2021 21:49:02 +0000 Message-ID: <20210210214902.GN4066953@embecosm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21558"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Wed Feb 10 23:59:44 2021 Return-path: Envelope-to: guile-user@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 1l9ySV-0005WL-Tg for guile-user@m.gmane-mx.org; Wed, 10 Feb 2021 23:59:44 +0100 Original-Received: from localhost ([::1]:55886 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9ySU-00056Y-W6 for guile-user@m.gmane-mx.org; Wed, 10 Feb 2021 17:59:43 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51218) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9xMC-0004IM-1i for guile-user@gnu.org; Wed, 10 Feb 2021 16:49:08 -0500 Original-Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:40926) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l9xMA-0003Fs-5M for guile-user@gnu.org; Wed, 10 Feb 2021 16:49:07 -0500 Original-Received: by mail-wm1-x329.google.com with SMTP id o24so3250911wmh.5 for ; Wed, 10 Feb 2021 13:49:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:subject:message-id:mime-version:content-disposition :content-transfer-encoding; bh=Tc6OGkxTBp5CUiudHI+s+KdGPrwn6UQ66S6J6U2JJhs=; b=MFDkFowmzjl6vhdxjkZahAfkExEhyaFSNOT2RvkuLZQMtyGcDoVeBXU93AUsBM/uQl Wmmx9wuqS1zZYWqPkFT7tSGofRRXIXdNl6eGxkaYGqBNbZ85hhWBaZYIYjYOw4nDKGJD CTBYtJC3mpmThQH3RiZEaiH3tStjoEkzbbgmDvvuH3Ee+VB3ZCacmjuElMAB2dPCACQ6 55/pkX4M68QTeZoSlwkpiLhXLqrwyrkjsSSdCt6gJdCR0f+WOsSlT7A2zFWM7UihESdL pb9Wb5plP/CkQPbl9a+Jn99QAlEK++bMSqPzjT+kNV37BuQYovHSuFSs1x2NaiIKtxnk KQ8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:content-transfer-encoding; bh=Tc6OGkxTBp5CUiudHI+s+KdGPrwn6UQ66S6J6U2JJhs=; b=pynPXFf/PG9mQ4wruODRGftMdkyIvY1PIrJjbdYjlV6AXlKJSMSqsAP8MCmMqgyfTd y2Szpt8nRBM42Rbpty9dAWZo3A/RD3ZMHVx40+YNJ4KFLJIsfRMUrQ9uxntewD08vepT uA+M/aRsSmAwUYGUXuSt20EromC79SsVUHnc4CrwoZ/O6ATsEDCneCxnlnfrdkwQp9wf 4ylU7OyLXsNdzFbNQH/a5e9kJY8a3qApodnITs/YDHzlcmNh5vvb2YqhLWdLeF95nsNW FSEZhXbE1xDsbdnqfgh65xPECov0K38d1LOfWBLz6QzOqw6lvdIrwOvZNKD57wynfdTe II9g== X-Gm-Message-State: AOAM533hdhdS82ZChd7DwOD879gXXX8MlO7Os0ccZk3fBR0iTua4Vlgj liEMmxHgon+bGq0IeNtpBHsrqir0KkOX0g== X-Google-Smtp-Source: ABdhPJxTUutn38hjVSMUiLffm95W8+voKKGv8uT+s1KX/V2Xrx9qjRS0GC9r3qVzIht1aKOHOW9gKw== X-Received: by 2002:a05:600c:2e46:: with SMTP id q6mr1137578wmf.78.1612993743713; Wed, 10 Feb 2021 13:49:03 -0800 (PST) Original-Received: from localhost (host109-151-46-64.range109-151.btcentralplus.com. [109.151.46.64]) by smtp.gmail.com with ESMTPSA id k15sm4291615wmj.6.2021.02.10.13.49.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Feb 2021 13:49:03 -0800 (PST) Content-Disposition: inline X-Operating-System: Linux/5.8.13-100.fc31.x86_64 (x86_64) X-Uptime: 20:59:46 up 64 days, 1:44, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=andrew.burgess@embecosm.com; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 10 Feb 2021 17:58:38 -0500 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:17240 Archived-At: Hello, I'm in the process of updating a body of old code from guile 1.8.8 to either guile 2 or 3. Ideally it would be great if the final code could run on both version 2 and version 3. When I first started looking at the problem I was hitting hundreds of warnings like: ..... warning: possibly unbound variable `blah' along with lots of the expected unknown procedures as you might expect. So, I started working through the issues. In a (probably stupid) move I started passing `--no-auto-compile' on the guile command line. After a few days of hacking I actually managed to get the code running again. But then I remembered about the `--no-auto-compile' and figured I should probably remove that. At which point I ran into a few problems. Here's a small (contrived) example, which I think is representative of at least the first big problem I need to work around. Imagine two files: --- START: loader.scm --- (define (load-files) (load "loadee.scm")) (load-files) (display (blah abc)) (newline) (newline) --- END: loader.scm --- --- START: loadee.scm --- (define (process-name name) (symbol-append name '-tail)) (defmacro blah (name) (let ((new-name (process-name name))) `(quote ,new-name))) --- END: loadee.scm --- This works fine when run as: guile --no-auto-compile -s loader.scm But, when with the compiler I get: $ guile -s loader.scm ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=3D0 ;;; or pass the --no-auto-compile argument to disable. ;;; compiling /tmp/loader.scm ;;; /tmp/loader.scm:6:9: warning: possibly unbound variable `blah' ;;; /tmp/loader.scm:6:9: warning: possibly unbound variable `abc' ;;; compiled ;;; compiling /tmp/loadee.scm ;;; compiled Backtrace: 5 (apply-smob/1 #) In ice-9/boot-9.scm: 705:2 4 (call-with-prompt _ _ #) In ice-9/eval.scm: 619:8 3 (_ #(#(#))) In ice-9/boot-9.scm: 2312:4 2 (save-module-excursion _) 3832:12 1 (_) In /tmp/loader.scm: 4:0 0 (_) /tmp/loader.scm:4:0: In procedure module-lookup: Unbound variable: abc My understanding of what's happening here is that macros are expanded at compile time, while load is a run-time thing, which is happening after compilation. Hence why 'blah' and 'abc' are considered possibly undefined. Then in the compiled code the '(blah abc)' has not been macro expanded, and so the argument is first being evaluated, which leads to the error. I read the manual on 'Local Inclusion'[1] and this seems to line up with my understanding of the problem. It even makes special mention that using (include "...") instead of (load "....") will allow for the loadee to provide macros to the loader. One problem is that the program, as its currently written, makes significant use of the run-time nature of load in order to configure the program state. If I do switch to using (include "...") then I run into problems with the macros, as in loadee, where the macro blah makes use of process-names. Which again (as I understand it), at macro expand time process-names will not be defined, and so this causes problems. It feels frustratingly close that I can run the program with the compiler off, but not with it on. I suspect there's still some way to go in order to make things really guile 2/3 ready. So, is it possible for me to force the compiler off from within the program itself? This would allow me to make a first step from 1.8.8 to 2/3 (compiler off), and then work on moving to compiler on after that. Finally, I assume the model for how guile loads, expands, executes changed between v1 and v2. Is there any specific hints/tips for how to make the transition? Any help and advice offered would be gratefully received. Thanks, Andrew [1] https://www.gnu.org/software/guile/manual/guile.html#Local-Inclusion