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: Seeking Advice on syntax/macros in separate files Date: Mon, 1 Mar 2021 18:03:57 +0000 Message-ID: <20210301180357.GN265215@embecosm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5695"; 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 Mon Mar 01 19:04:21 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 1lGmu5-0001MA-13 for guile-user@m.gmane-mx.org; Mon, 01 Mar 2021 19:04:21 +0100 Original-Received: from localhost ([::1]:41120 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lGmu4-0003j6-1I for guile-user@m.gmane-mx.org; Mon, 01 Mar 2021 13:04:20 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lGmtp-0003gI-IB for guile-user@gnu.org; Mon, 01 Mar 2021 13:04:05 -0500 Original-Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:38579) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lGmtn-00050h-FN for guile-user@gnu.org; Mon, 01 Mar 2021 13:04:05 -0500 Original-Received: by mail-wm1-x329.google.com with SMTP id n4so94152wmq.3 for ; Mon, 01 Mar 2021 10:04:01 -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; bh=d23hmWOFrxeaKnLhZOal+5rmeDr3ZBqh7BnAhMDz0PA=; b=GaWWjuNNuyRSCB232RXdPZgHcWYu73ykqdUGAgZBAxtvvvRaDOxgr+pouwKFHVwZE7 YFkROWyZSdThrO2omVwFroDHoDt7rJtWnc81artGekDZ/GGR3n8Hup6Jwb29dEybdMQ6 pB8zr4J5Y2T8uLGpBCBeF18hc5m1ta/sg1uKEDcEwX3f5rh8hC4e4hrQ0ti8QMIbfhWw O/ubmtAXsjtdC4xLInTtPodJhWR+ybSPQX9aNAJWhJifTM4Ga7+MvSauVVvz1kdamau1 gz1E3DS3fEdgIHQ5ybMItK0u6oLdxd69Rkp6RCquzg/MvODrvpO0ateEaTP3dDACOLZW q8og== 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; bh=d23hmWOFrxeaKnLhZOal+5rmeDr3ZBqh7BnAhMDz0PA=; b=U7qYp0YUkWnRgNHa0akofiDmwGpGDi7hsGCyC44BnhtEKuD1iHmoFdySRcKIPuIRP2 lfNM+Iav2yoWJHaA0prRBhscysm7qRBy77DS+fK37cRpbynVyqmwEFWajc9lDXueK9zj F1pyuEtCangJpceXJktxoMVXOZfWjFLn8JlRWk9gYVpFCLD3XVQkoGDtA3yIVRwPetzH WASF1OgbxrXcoQRuEmfs3gVhHiL3BDDSRfbfA67Ka9jvGem1itZSZyKv0Xalqx5gYaR1 eR207fTKOLD4ahULXH6hPugr/+Rs1auQmNOjCdnPIAx0E60v9NIuD0QqPPfCPyy+6tRd GbQg== X-Gm-Message-State: AOAM530G1/WCnwVlGAvLfjwhg2hF+oPvdBUmMzUJ/ZwyJSnoubrsDf+e bCzfydruoBPM8wMoOMewd+emeZ2FD4y1SQ== X-Google-Smtp-Source: ABdhPJyE3FS4ZX/GZ3eF7VGfiYlDkTA1Hx3iJZAxSJGAz5yW6ejsu4XzxDvyXBnuPPIkIYIP1gRgCA== X-Received: by 2002:a05:600c:2946:: with SMTP id n6mr119929wmd.52.1614621838988; Mon, 01 Mar 2021 10:03:58 -0800 (PST) Original-Received: from localhost (host86-186-80-154.range86-186.btcentralplus.com. [86.186.80.154]) by smtp.gmail.com with ESMTPSA id b131sm62153wmb.34.2021.03.01.10.03.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Mar 2021 10:03:58 -0800 (PST) Content-Disposition: inline X-Operating-System: Linux/5.8.13-100.fc31.x86_64 (x86_64) X-Uptime: 17:29:58 up 82 days, 22:14, 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-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:17328 Archived-At: Hello, I'm trying to understand how I am supposed to make use of define-syntax type constructs (or possibly, when working with older code define-macros) in a code base split over many files I'm updating a code base from guile 1.8.8, and currently having it running successfully on guile 2 and 3. With the new auto-compilation in guile 2 and 3 I'm now trying to work out how users will invoke the tool. My concerns are based on this page of the guile manual: https://www.gnu.org/software/guile/manual/html_node/Compilation.html#Compilation specifically this: "... Guile does not yet do proper dependency tracking, so that if file a.scm uses macros from b.scm, and b.scm changes, a.scm would not be automatically recompiled." And just to confirm what the manual says, here's my test: $ cat f1.scm (use-modules (f2)) (foo 123) (define-accessor xxx 3) (xxx 9) $ cat f2.scm (define-module (f2) #:export (foo) #:export-syntax (define-accessor)) (define (foo arg) (display "foo: ") (display arg) (newline)) (define-syntax-rule (define-accessor name n) (define (name obj) (display "accessor for field: ") (display n) (display " in ") (display obj) (newline))) I'm then running `guile -L . -s f1.scm`, and indeed, as the manual suggests, changes to `foo' are visible, but, unless I force recompilation, changes to `define-accessor` are not. I also tried replacing the use of `use-modules` with raw `include`, but this is even worse, as now changes to `foo` are not seen either. My choice of `define-accessor' is not random, this is drawn from an example in the guile manual here: https://www.gnu.org/software/guile/manual/html_node/Vtable-Example.html And here lies my confusion: First, let me say I'm pretty much a scheme/guile newbie, but I thought that macros (or syntax extensions) were a huge part of the power of languages like scheme. The guile manual itself uses them to show how an object like system could be created. However, it would seem natural to place such a system into a separate file, presumably as a module. But, and here's my problem: the first time I ship this software to the user, everything's fine. But if I ship them an update that touches any of the macros, then I'm stuck. The user now needs to be aware that they have to take special steps in order to ensure the previously compiled code is deleted. And that's not great for a user experience. So, my current thinking is to wrap the invocation of the guile script in a shell script, which _always_ forces recompilation. But, if I'm doing that, I may as well just disable compilation completely. But this doesn't seem right. So, I'm sure I must be missing something here. How do others deal with this situation? - Am I missing an obvious solution for working with syntax/macros and multiple files? - Am I wrong to think that syntax/macros are such a big part of the language? Should I be limiting syntax/macro usage to small scopes, i.e. within a single file, and only true defines should be exposed outside of a file? - Maybe Guile just isn't designed for writing large, multi-file projects? - Maybe Guile projects are only ever shipped to users who are happy managing the compile cache themselves, e.g. more power users, and not really for general users? As I said, I'm fairly new to guile/scheme so my expectation here is that it's me that's missing something here. Thank you for any help you can offer, Andrew