From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Linus_Bj=C3=B6rnstam?= Newsgroups: gmane.lisp.guile.user Subject: =?UTF-8?Q?Re:_Namespace_confusion/pollution_in_languages_implemented_via?= =?UTF-8?Q?_Guile's_compile-tower?= Date: Mon, 09 Nov 2020 08:48:34 +0100 Message-ID: <31461d07-0fe6-43e1-bec7-77bb3399eace@www.fastmail.com> References: 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="2778"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Cyrus-JMAP/3.3.0-570-gba0a262-fm-20201106.001-gba0a2623 To: holger.peters@posteo.de, guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Mon Nov 09 08:49:28 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 1kc1vc-0000by-6I for guile-user@m.gmane-mx.org; Mon, 09 Nov 2020 08:49:28 +0100 Original-Received: from localhost ([::1]:54868 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kc1vb-0003Gg-9P for guile-user@m.gmane-mx.org; Mon, 09 Nov 2020 02:49:27 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55344) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kc1vG-0003GX-L8 for guile-user@gnu.org; Mon, 09 Nov 2020 02:49:06 -0500 Original-Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:44787) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kc1vE-0001UZ-Go for guile-user@gnu.org; Mon, 09 Nov 2020 02:49:06 -0500 Original-Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 9DD9711FA; Mon, 9 Nov 2020 02:49:01 -0500 (EST) Original-Received: from imap1 ([10.202.2.51]) by compute6.internal (MEProxy); Mon, 09 Nov 2020 02:49:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.se; h= mime-version:message-id:in-reply-to:references:date:from:to :subject:content-type:content-transfer-encoding; s=fm1; bh=3I/ih y3BmU8Y3ogH3K3p/OiWlHDEGagPtpIUQgLjhn4=; b=KxFmHm8ZdpReN/QkMSvm7 iB5dKOk4WGW84thEGDDC9zwOC2dRWVZcS9plHIDdkp9lIJRrM98UwMQgMgIRQlyD VhIwBs6l5k3HA2RqksnrUz+2H2oMvekiPVVlEquxCejAdEr6R62rb5git5K+koWo RT5Ycr2/wQyyEexKXwFlD45qrBLd8vEZxLc+ZQwtQUjDgu33TB8m0UbjPPsTE5r5 0w47Ofc0yFFqdaUSNoIpwanpwxf7QBnJpH01szg5duyHKHJ+ApuctbeB5opNgKV7 08+1NV225WmtlqFPROmhlQev+QiTFm6NVVF8rnB6aKhWuFkGTh1HpLaOfKxZPwAi A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=3I/ihy3BmU8Y3ogH3K3p/OiWlHDEGagPtpIUQgLjh n4=; b=BoIEGEFDvcgdLc4QhWGTHfy1h8kA/5CbIeG28ft1QLZjAX4VqnREzTxHp lrbcRzu3zeKPnHVDIIp9LCpH3jfkbF1XMupHXocdfQbKq24tP/D6Bi/Jkhwyf+f3 6J5EzTs1vnzURI0k572Rv4aM01yUVH+Hjjryri93BIhk1jAS234RIlfTrCSwba9i QDBlOs2X+S6zx79aHstlCBgaKKc429vGVlx+PmBq7GWHxG5OQp3bnx6resHTw3PJ rmzGayYBi5fC/ax32m7/5+erMrWD5Zsdh2cOqmC3ktxHeNgVJym+PmvIZO+QMypT 2YEBESkr8gYIIrnLzhiHD2ZDfe4Bw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedruddugedgudduhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepofgfggfkjghffffhvffutgfgse htqhertderreejnecuhfhrohhmpefnihhnuhhspgeujhpnrhhnshhtrghmuceolhhinhhu shdrihhnthgvrhhnvghtsehfrghsthhmrghilhdrshgvqeenucggtffrrghtthgvrhhnpe ekleevieevleejffetieeltdelkeevteduheefheduieffffdttdegjeeihedtjeenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlihhnuhhsrd hinhhtvghrnhgvthesfhgrshhtmhgrihhlrdhsvg X-ME-Proxy: Original-Received: by mailuser.nyi.internal (Postfix, from userid 501) id A2247C200A5; Mon, 9 Nov 2020 02:49:00 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface In-Reply-To: Received-SPF: pass client-ip=64.147.123.25; envelope-from=linus.internet@fastmail.se; helo=wout2-smtp.messagingengine.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/09 02:49:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.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_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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.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:17012 Archived-At: The guile module used at the repl is indeed the guile-user module. I wou= ld look at how the elisp language is implemented. It switches the repl t= o the elisp module where no guile bindings are present. This is the same as doing ,m (module name) at the repl.=20 --=20 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. >=20 > * Problem statement >=20 > 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 looki= ng=20 > at > the fact what I describe is present in the ecmascript iplementation > bundled with guile. >=20 > If you run Guile's ECMAscript REPL using `guile > --language=3Decmascript`, something like this works: >=20 >=20 > write("test"); > display(3); > newline(); >=20 >=20 > Haven't looked into the ECMAscript standard but I don't think Scheme's= > `write', `display' and `newline' are whats being demonstrated there. >=20 > * Reproducing Example >=20 > 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'). >=20 >=20 > (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)) >=20 > (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)) >=20 > (define-language fakescheme > #:title "fakescheme" > #:reader (lambda (port env) > ((or (and=3D> (and=3D> (module-variable env=20 > '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) >=20 >=20 > 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 >=20 >=20 > (print "foo") ; works in script > (write "foo") ; fails in script >=20 > However, if I run the same code from within a repl via `guile > --language=3Dfakescheme', >=20 >=20 > (print "foo") ; fails in repl > (write "foo") ; works in repl >=20 >=20 > * Whats going on here? >=20 > 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. >=20 > 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'). >=20 >