From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Tom Tromey Newsgroups: gmane.emacs.devel Subject: Re: Proper namespaces in Elisp Date: Wed, 06 May 2020 20:23:50 -0600 Message-ID: <87pnbgzdmx.fsf@tromey.com> References: <87ftcee7td.fsf@tromey.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="5074"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Tom Tromey , emacs-devel To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu May 07 04:24:46 2020 Return-path: Envelope-to: ged-emacs-devel@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 1jWWDO-0001DA-HQ for ged-emacs-devel@m.gmane-mx.org; Thu, 07 May 2020 04:24:46 +0200 Original-Received: from localhost ([::1]:55106 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jWWDN-0001kT-IS for ged-emacs-devel@m.gmane-mx.org; Wed, 06 May 2020 22:24:45 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56546) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jWWCn-0001Fs-7m for emacs-devel@gnu.org; Wed, 06 May 2020 22:24:09 -0400 Original-Received: from gateway31.websitewelcome.com ([192.185.143.36]:42536) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jWWCk-0006OW-Qj for emacs-devel@gnu.org; Wed, 06 May 2020 22:24:08 -0400 Original-Received: from cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7]) by gateway31.websitewelcome.com (Postfix) with ESMTP id 854344BDC6 for ; Wed, 6 May 2020 21:23:51 -0500 (CDT) Original-Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id WWCVjKmHAXVkQWWCVjSoYB; Wed, 06 May 2020 21:23:51 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID: In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Cb39H7tPd7DgcjUiqKXIePHZ2q27v0OeRUfdPbrAjok=; b=yVezI3w08SSFMAeg9kSM5BXoRq 5JD9mrTXpenTujPhTrZfJdd0fyz0NU1JYd7Hw5KxvbuYGc537c7m5MaRFdrl6nosSRR9ClgP+7ers 4gfQ4fnzEy8WURsU5MgFGyVCz; Original-Received: from 174-16-104-48.hlrn.qwest.net ([174.16.104.48]:45884 helo=bapiya) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1jWWCV-002enL-5i; Wed, 06 May 2020 20:23:51 -0600 X-Attribution: Tom In-Reply-To: (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vora=22's?= message of "Tue, 5 May 2020 22:30:26 +0100") X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 174.16.104.48 X-Source-L: No X-Exim-ID: 1jWWCV-002enL-5i X-Source-Sender: 174-16-104-48.hlrn.qwest.net (bapiya) [174.16.104.48]:45884 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes Received-SPF: permerror client-ip=192.185.143.36; envelope-from=tom@tromey.com; helo=gateway31.websitewelcome.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/06 22:23:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_NEUTRAL=0.779, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:249135 Archived-At: >>>>> "Jo=C3=A3o" =3D=3D Jo=C3=A3o T=C3=A1vora write= s: >> https://github.com/tromey/emacs-module Jo=C3=A3o> So you're saying one just types "s-format", but the actual symbol Jo=C3=A3o> that elisp sees is modern-string-format? Yes. The test program there shows how it is used. >From testmodule.el: (import-module testm2 :symbols (zzzq)) (defun somefunction () [...stuff...] (zzzq)) >From testm2.el: (define-module testm2 :export zzzq) (defun zzzq () 23) Here, the actual symbol names are "testmodule-somefunction" and "testm2-zzzq". The only things that are renamed are either (1) symbols you import, and (2) things in your .el file that (after macro expansion) are a defvar, defconst, defalias, defvaralias, or fset (this handles defuns). Jo=C3=A3o> Are both symbols interned? Only for vars&functions? I could live Jo=C3=A3o> with that. Not sure I totally understand, but the renaming happens after macro expansion, so everything is interned. How exactly the symbol is used is up to you -- basically the renamer is intentionally simplistic, it just blindly renames all symbols that were imported. I guess it is a little too simplistic since looking at module--rewrite-form, it seems I didn't make it recurse into vectors. Maybe it would struggle with other things, too, like if macro expansion resulted in a string with properties applied. Jo=C3=A3o> It seems similar my "shorthand" idea Jo=C3=A3o> (https://lists.gnu.org/archive/html/emacs-devel/2020-05/msg00617= .html) Jo=C3=A3o> but that idea would fall into the pitfall of: Jo=C3=A3o> "the Emacs core sometimes requires certain symbol names in A= PIs." Jo=C3=A3o> unless, that is, you added syntax to escape renaming in _those_ Jo=C3=A3o> situations, like `::` I like the idea of doing it in the reader (it has some nice advantages), but the downside is it is then harder to special-case defining forms. Also, in my approach the issue of special symbols that are important to the elisp core doesn't really arise, because only explicit imports (and exports) are renamed. This is essentially the same problem. Probably functions taking a special symbol should be updated to also take a special keyword. That would eliminate this part of the problem entirely. Jo=C3=A3o> I think I could fix the thing-at-point thing reasonably easily. There's also whatever M-. uses under the hood when in a .el file. Maybe that's thing-at-point, I haven't looked. I'm not totally sold on my module approach, but I'm happy to assign it to the FSF if that's useful. Emacs could include it or someone could just lift whatever code they like from it. One thing I've occasionally wished for in a module system is the ability to load two different versions of a library simultaneously. That's not readily done in this system. Modules aren't really first class -- the implementation just reuses the global obarray and the full symbol names are baked into the .elc. I tend to think Emacs could do better with something in the core than what I implemented. thanks, Tom