From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Felix Thibault Newsgroups: gmane.lisp.guile.user Subject: Re: Namespace confusion/pollution in languages implemented via Guile's compile-tower Date: Mon, 9 Nov 2020 07:30:50 -0500 Message-ID: References: <31461d07-0fe6-43e1-bec7-77bb3399eace@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="blaine.gmane.org:116.202.254.214"; logging-data="32635"; mail-complaints-to="usenet@ciao.gmane.io" Cc: guile-user@gnu.org To: =?UTF-8?Q?Linus_Bj=C3=B6rnstam?= Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Mon Nov 09 13:31:23 2020 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 1kc6KR-0008ND-6K for guile-user@m.gmane-mx.org; Mon, 09 Nov 2020 13:31:23 +0100 Original-Received: from localhost ([::1]:40828 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kc6KQ-0000YR-7q for guile-user@m.gmane-mx.org; Mon, 09 Nov 2020 07:31:22 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40620) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kc6KD-0000Y7-5i for guile-user@gnu.org; Mon, 09 Nov 2020 07:31:09 -0500 Original-Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]:34784) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kc6KB-0001yp-5v for guile-user@gnu.org; Mon, 09 Nov 2020 07:31:08 -0500 Original-Received: by mail-lf1-x135.google.com with SMTP id i6so12166475lfd.1 for ; Mon, 09 Nov 2020 04:31:03 -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=IWxQ4cmyY9xg6mRa4srrYnIY0Qd6+Quqi2Ip8cS3J8A=; b=s5DAh9eBPbLYLGpXDqjlC98HWVxs+WEHFlkoRnaCXkVK6EA94c11ZroRHuGuI0ksSy F1I3dya+mjsLB1YMuFI+PHLnPVYyXK9OqrhDO29SUqh3ed0vzoBvDSBpOeU2/E6TGtls Q2woFc/zd6jpq03Fjd44ZJfkqF9ba92sbhKlNga0psIR+vWTRpSaSyJvk8AHBpksob4F sxzAL/cyaAZkAu5esL2/3MWAEpBfGAjrwc0JteS1OJcW9E3xHQIlzT4zxbPj8WFgs14X ry16SKNjGA5Bcxmy4fbF6SjjSZIvsozoi0R8rcjQ/fmHfGEzI5OBT1NZV2ooAmhd9LPG OA7A== 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=IWxQ4cmyY9xg6mRa4srrYnIY0Qd6+Quqi2Ip8cS3J8A=; b=JuIUcLxzDjt+79uPJ3q/JXlHDvZvl9J0sg8i6DX3Cb7hgYmsyUq0Wzjo2ex71I63hG elxRT2OTXcrRnSlSHNSzfvYyqbqz9zwggqyCdsDS0Az6aUmU8t/keLcMhoPIiI+H6z6l alBbQ3Wq+P0f5QaG8oTLmi9+0vJrns/HQp8UXag3A/09zefsuVK9nPVQ8D87YlwQV/h2 UlWqgBZpfkqRF1LhRpRLvA5LuuBIEdPdSDa3PwxTyIHBvrgEBW4X+HLkxDb7wVEQEook +oGETXio1BkmxjOZU1P9/YiLnRbsNGUa06hJpwSF0/4TRvr8wGSkT+Vghn6RaG44G8Eh lw8A== X-Gm-Message-State: AOAM530smcPNzzoIAAZ49HRBvf3yvQf9D499XrtM5XrqgD85sCVtb1sD OW7HmUT3eFEM/p0a59Ri/aU9K9cQ/IS7kQsUULM= X-Google-Smtp-Source: ABdhPJyeI30KJFNds3D58dNsHHQxRfxfGpTpcNAIs3oN8LViLnrR80Eod2T/rkj7AJnOtrRxqWPa5/1Uwq4W+449kG0= X-Received: by 2002:a19:24c6:: with SMTP id k189mr5174927lfk.525.1604925061254; Mon, 09 Nov 2020 04:31:01 -0800 (PST) In-Reply-To: <31461d07-0fe6-43e1-bec7-77bb3399eace@www.fastmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::135; envelope-from=fthibault1969@gmail.com; helo=mail-lf1-x135.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, 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:17013 Archived-At: Is this supposed to work for r7rs ? I get: scheme@(guile-user)> (import (scheme base)) scheme@(guile-user)> ,m (scheme base) scheme@(scheme base)> Display all 2081 possibilities? (y or n) On Mon, Nov 9, 2020 at 2:49 AM Linus Bj=C3=B6rnstam wrote: > > The guile module used at the repl is indeed the guile-user module. I woul= d look at how the elisp language is implemented. It switches the repl to th= e elisp module where no guile bindings are present. > > This is the same as doing ,m (module name) at the repl. > > -- > Linus Bj=C3=B6rnstam > > On Sat, 7 Nov 2020, at 12:54, holger.peters@posteo.de wrote: > > First of all let me begin by saying I am not quite sure whether this > > is a `works as intended' or whether this constitutes a bug, I tend to > > think its the latter, but wouldn't right away rule out the former, as > > if it were to be considered a `bug' it probably would have surfaced > > long before, but I disgress. let's get to my problem. > > > > * Problem statement > > > > I implemented my own language using the guile compile-tower. For the > > sake of you not having to read through all of my code I provide a > > snippet for reproducing the test case. But first, let's start by lookin= g > > at > > the fact what I describe is present in the ecmascript iplementation > > bundled with guile. > > > > If you run Guile's ECMAscript REPL using `guile > > --language=3Decmascript`, something like this works: > > > > > > write("test"); > > display(3); > > newline(); > > > > > > Haven't looked into the ECMAscript standard but I don't think Scheme's > > `write', `display' and `newline' are whats being demonstrated there. > > > > * Reproducing Example > > > > This creates a lang `fakescheme', that is actually identical to > > `(language scheme spec)' for all items except, that there are far > > fewer builtins (just `print' instead of `write'). > > > > > > (define-module (language fakescheme spec) > > #:use-module (system base compile) > > #:use-module (system base language) > > #:use-module (language scheme compile-tree-il) > > #:use-module (language scheme decompile-tree-il) > > #:export (fakescheme)) > > > > (define (make-fresh-module) > > (let ((m (make-module))) > > (module-define! m 'current-reader (make-fluid)) > > (module-set! m 'format simple-format) > > (module-define! m 'newline newline) > > (module-define! m 'print write) > > (module-define! m 'current-module current-module) > > m)) > > > > (define-language fakescheme > > #:title "fakescheme" > > #:reader (lambda (port env) > > ((or (and=3D> (and=3D> (module-variable env > > 'current-reader) > > variable-ref) > > fluid-ref) > > read) > > port)) > > #:compilers `((tree-il . ,compile-tree-il)) > > #:decompilers `((tree-il . ,decompile-tree-il)) > > #:evaluator (lambda (x module) (primitive-eval x)) > > #:printer write > > #:make-default-environment make-fresh-module) > > > > > > The general observation is: If I run a some script using this language > > using `guile --language=3Dfakescheme -s myscript.scm', it works as > > expected, i.e. the following works > > > > > > (print "foo") ; works in script > > (write "foo") ; fails in script > > > > However, if I run the same code from within a repl via `guile > > --language=3Dfakescheme', > > > > > > (print "foo") ; fails in repl > > (write "foo") ; works in repl > > > > > > * Whats going on here? > > > > It seems that in the REPL, Guile injects the `guile-user' module > > directly whereas when called with `-s` and a script guile uses the > > module provided with `#:make-default-environment'. That seems strange > > because overall I would expect REPL environments and non-REPL > > environments to be roughly the same. > > > > So, is this a bug? Works as intended? And if this is intended in this > > way is there a workaround to make REPL and script exeution to behave > > the same (preferably without namespace `pollution'). > > > > >