From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: prj@case.edu (Paul Jarc) Newsgroups: gmane.lisp.guile.user Subject: custom module loading and compilation Date: Sat, 11 May 2024 04:02:34 -0400 Organization: What did you have in mind? A short, blunt, human pyramid? Message-ID: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9022"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sat May 11 10:03:22 2024 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 1s5hhR-00023Z-Ok for guile-user@m.gmane-mx.org; Sat, 11 May 2024 10:03:22 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s5hgr-0002MH-79; Sat, 11 May 2024 04:02:45 -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 1s5hgn-0002Lu-Ra for guile-user@gnu.org; Sat, 11 May 2024 04:02:41 -0400 Original-Received: from mpv-out-ksl-1.cwru.edu ([129.22.103.228] helo=mpv-out-ksl-1.case.edu) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s5hgl-0007IV-I6 for guile-user@gnu.org; Sat, 11 May 2024 04:02:41 -0400 Original-Received: from mpv-local-cfd-1.CWRU.Edu (EHLO mpv-local-cfd-1.case.edu) ([129.22.103.203]) by mpv-out-ksl-1.case.edu (MOS 4.4.8-GA FastPath queued) with ESMTP id CGI39646; Sat, 11 May 2024 04:02:35 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=case.edu; s=smtp-primary; t=1715414555; bh=dY7PfALGZgCpDw9UlkkyIskxLmcK0K8NPwaOA+WUusk=; l=1430; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=y3OYeLwTAVcfUo9vyONBRH46Malkx6hz6dzJ8GPvLrAcexKGbCQGBuIHKL6Dwhg8Fx cgzNMGb29E8bw2mLCmUKCGFnZyRlxwP7f5JY44F6Gw6yxU9M6Pr+eFxNDZdsnnF72Iv jB/Z6kwiSKJBIRhRuXbUGaz5UBz6U0rUAgTiybnuB4DFTfopaNn7FYQq5KGmDrPQJaC IImIzhPG2JE6B5x3oOH+3rxPlt5f3LTOymUl1+SsFf7UaIFPAlqoHiAgWuDEJaD/m1v jVsHsgZxyrxxzaDJG99dPooiKCIJjpK8tcJqOOmDt62DOGh1oaWoT3/fXQ6E4Rg9fPQ DveedwrA== Original-Received: from h-129-22-9-114.ins.cwru.edu (EHLO webapps-d-4.cwru.edu) ([129.22.9.114]) by mpv-local-cfd-1.case.edu (MOS 4.4.8-GA FastPath queued) with ESMTP id DOP88502; Sat, 11 May 2024 04:02:35 -0400 (EDT) Original-Received: by webapps-d-4.cwru.edu (Postfix, from userid 513778) id D024219DFB09; Sat, 11 May 2024 04:02:34 -0400 (EDT) Mail-Copies-To: nobody Original-Lines: 42 X-Mirapoint-IP-Reputation: reputation=Fail, source=NONE, refid=n/a, actions=MAILHURDLE TAG X-Mirapoint-IP-Reputation: reputation=good-1, source=Fixed, refid=n/a, actions=tag X-Junkmail-Status: score=7/90, host=mpv-out-ksl-1.case.edu X-Junkmail-PrAS-Raw: score=7/90, refid=2.7.2:2023.6.26.145126:17:7.944, ip=, rules=__RCVD_POSTFIX_UID, DKIM_SIGNATURE, __HAS_FROM, __FROM_NAME_NOT_IN_ADDR, __TO_MALFORMED_2, __TO_NO_NAME, __SUBJ_ALPHA_START, __USER_AGENT, DATE_TZ_NA, __HAS_MSGID, __SANE_MSGID, __MIME_VERSION, __CT, __CT_TEXT_PLAIN, __DKIM_ALIGNS_2, __FUR_HEADER, __BODY_NO_MAILTO, __NO_HTML_TAG_RAW, BODY_SIZE_1500_1599, BODYTEXTP_SIZE_3000_LESS, __MIME_TEXT_P1, __MIME_TEXT_ONLY, __FROM_NAME_NOT_IN_BODY, __FROM_DOMAIN_NOT_IN_BODY, HTML_00_01, HTML_00_10, BODY_SIZE_5000_LESS, BODY_SIZE_2000_LESS, __MIME_TEXT_P, NO_URI_FOUND, NO_CTA_URI_FOUND, __URI_NO_MAILTO, NO_URI_HTTPS, BODY_SIZE_7000_LESS, SENDER_NO_AUTH, NO_CTA_FOUND, so=2010-03-03 19:42:08, dmn=2016-08-03-0138 Received-SPF: pass client-ip=129.22.103.228; envelope-from=prj@case.edu; helo=mpv-out-ksl-1.case.edu 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, SPF_HELO_PASS=-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.29 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-bounces+guile-user=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.user:19631 Archived-At: Hi. I'm writing a custom module system that avoids the standard search path and list-of-symbols naming scheme. Instead of using use-modules and define-module, I have a roughly similar procedure, let's call it my-load, that creates a module with make-module and loads a file into it with primitive-load. I want to make my-load automatically available within the modules I load so that they can use it to load other modules too. So my-load adds itself to each new module using module-define! before calling primitive-load. This works when I run Guile with --no-auto-compile, but with compilation enabled, I get: ;;; Unbound variable: my-load How can I make the binding visible to the compiler? ;;main.scm (define (my-load path-to-macros) (let ((new-module (make-module 0 `(,(resolve-interface '(guile)))))) (module-define! new-module 'my-load my-load) (save-module-excursion (lambda () (set-current-module new-module) (primitive-load path-to-macros))) (let ((interface '(my-macro))) (for-each (lambda (sym) (module-define! (current-module) sym (module-ref new-module sym))) interface)))) (eval-when (compile load eval) (my-load "/path/to/macros1.scm")) (display (my-macro 5)) (newline) ;;macros1.scm (eval-when (compile load eval) (my-load "/path/to/macros2.scm")) (display (my-macro 3)) (newline) ;;macros2.scm (define-syntax my-macro (syntax-rules () ((_ x) (+ x x))))