From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Zelphir Kaltstahl Newsgroups: gmane.lisp.guile.user Subject: Handling modules with same name (from library and from current project) Date: Sun, 5 Jan 2025 14:49:11 +0000 Message-ID: <22b33143-8fc9-4aa5-b1b5-978ce7f118e6@posteo.de> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35952"; mail-complaints-to="usenet@ciao.gmane.io" To: Guile User Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sun Jan 05 15:49:57 2025 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 1tURwy-00099O-S2 for guile-user@m.gmane-mx.org; Sun, 05 Jan 2025 15:49:56 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tURwP-0006iQ-8b; Sun, 05 Jan 2025 09:49:21 -0500 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 1tURwN-0006iH-RQ for guile-user@gnu.org; Sun, 05 Jan 2025 09:49:19 -0500 Original-Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tURwK-00027f-K4 for guile-user@gnu.org; Sun, 05 Jan 2025 09:49:19 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 4D47A240101 for ; Sun, 5 Jan 2025 15:49:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1736088552; bh=kyVm4xVVVovs0cfE/bB9H8q3NsMBMme2HV8vo3OIryo=; h=Content-Type:Message-ID:Date:MIME-Version:From:To:Subject:From; b=Fq8JlChAlSPmUcD3r+MfV/R17RSN1CjjVD6y/Dk7qdivJCGkzKA6N/UeWHZEwFq47 3RaHKAYxFSHOPv3PshvLd2KEnWSnzYzCwxAF+NI6fODN5s/yCRIAMpFslRo+fP/FTa ZmmcV1YVWLgBqLMirTdTzSt6qGApExGcbAcb4+EoGa+YQVVGCjLtWl2NSZRkfxXO+U Upc63hY8VUm0BnnLMG0Ykd6o0IyOKqZtQ5BHU113H/DxB6F+skVsV0+Y/ucK3a5OTp kxvsWpQUjjRyTEzgko8E2uLzTdQJYIjS/ZmIdirM/v6IWEK5mt06RFGCkokVC1QbAH ujFtKFkY+K74A== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4YR0ZH5dCJz9rxF for ; Sun, 5 Jan 2025 15:49:11 +0100 (CET) Content-Language: en-US Received-SPF: pass client-ip=185.67.36.66; envelope-from=zelphirkaltstahl@posteo.de; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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:20038 Archived-At: Hello Guile Users! I have a question regarding an issue I run into again and again, and have not found an adequate solution for yet. I want to know how you are handling this, what your solution is. (1) recent story: I have a website, that I wrote manually in pure HTML and CSS. It does what it should and there is no actual issue with it. However, I have been thinking it would be cool to implement it in Guile and make a sort of minimal example or web "framework", of how one can make such a static website using Guile. I already have some example in my examples repository. However, that example has code in it, that is copied from my existing "guile-fslib", which is on guix already. So I have been thinking: "I should just install the package from guix and remove this code from my new website repository, having it hidden away in the guile-fslib library." It is just some code to work with file names and directories and paths, not directly web related, but important for checking, whether a request for a static resource/an asset is within the "static" directory, and not just anywhere on the server, which would be a security issue. Of course I could put everything in a docker container or something, or completely serve static assets using a HTTP server, as one should, but then the Guile thing I want to build would not work on its own. I want to at least have it implemented as a fallback, so that one could run it without an additional thing in front of it for handling static resource requests. (2) So far so good. But now comes the problem: "guile-fslib" has a module named "string-utils" and a module named "list-utils". In my guile web development example code I also have modules with those names. Guile then gets confused about which one I am referring to, when I `(use-modules ...)` them and in the code that makes use of the functions from those modules, it then claims, that no bindings with some name exist, because it has looked into the "list-utils" or "string-utils" of the guix package, instead of the one of my web project. (3) Thoughts: I don't know how to resolve this. I think it is very unreasonable to have to look out to name no module the same name as any module in any library I am using. Obviously many libraries or projects will have some list utilities or helpers for convenience. Many projects will have some special string functions. Having a name like "string-utils" or "string-helpers" should not be an impossibility. From a past/previous case of this, I remember someone saying I should get my load path in order. But what does this mean? In my projects I invoke Guile doing something like this: ~~~~ guile -L . -L libs main.scm ~~~~ I simply use the `-L` argument to pass in all the directories, in which my modules reside, for example "libs/list-utils.scm" or "libs/string-utils.scm", which I then import into various other modules and the main file, the entrypoint. (4) Solution ideas: (4.1) I already abstain from doing `(add-to-load-path ...)` manipulations in my code. As far as I know I am not doing anything dirty there. But ... Guile gets confused about which module to import and it seems to see the one from installed library first and then not consider the one of my current project. I am not even sure how Guile could possibly know which module I am referring to, because I am not telling it anything about that. So I am wondering, whether some dark magic of dynamically changing load path is perhaps a _necessary_ evil? (4.2) Or perhaps I have to give my modules multi part names like `(define-module (fslib helpers list-utils))` to scope module names? But that would be annoying when using them inside the library itself, because it is more to write and I am not sure others are doing that always. Usually I just name my modules `(list-utils)` or `(string-utils)`. Is that a bad thing, when these are modules of helper functions, which are not supposed to be exported for use in other projects? (4.3) The ugly solution I so far had to reach for, because I couldn't figure out a better way: Integrate library code directly into the source tree of a project, copying code. This cannot be the right way to do it, can it? Seems unlikely. How do you manage this? I know people have written much bigger projects than I have and surely someone has some dependency on another Guile library. How do you avoid these module name conflicts? How do you make sure that only libraries themselves use their own helper function modules? The bad thing is, that I always run into this, when I actually want to do something else. In this case build a website thing in Guile. But now I am side tracked again by this issue, because I don't know how to do this properly. Best regards, Zelphir -- repositories:https://notabug.org/ZelphirKaltstahl,https://codeberg.org/ZelphirKaltstahl