From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tom Tromey Newsgroups: gmane.emacs.devel Subject: Re: Emacs Lisp's future Date: Thu, 13 Oct 2016 15:35:17 -0600 Message-ID: <87zim8kk4q.fsf@tromey.com> References: <87wq97i78i.fsf@earlgrey.lan> <86k2dk77w6.fsf@molnjunk.nocrew.org> <642fd4b4-8b1c-a537-5a5f-6940691ec4b9@gmail.com> <8760oyntm5.fsf@tromey.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1476395014 31430 195.159.176.226 (13 Oct 2016 21:43:34 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 13 Oct 2016 21:43:34 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) Cc: Tom Tromey , eller.helmut@gmail.com, emacs-devel@gnu.org To: Richard Stallman Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 13 23:43:29 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bunmJ-000490-6G for ged-emacs-devel@m.gmane.org; Thu, 13 Oct 2016 23:43:03 +0200 Original-Received: from localhost ([::1]:43166 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bunmH-0001io-Tm for ged-emacs-devel@m.gmane.org; Thu, 13 Oct 2016 17:43:01 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38740) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bunlg-0001ig-Iz for emacs-devel@gnu.org; Thu, 13 Oct 2016 17:42:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bunlc-0008Eu-CB for emacs-devel@gnu.org; Thu, 13 Oct 2016 17:42:23 -0400 Original-Received: from gproxy1-pub.mail.unifiedlayer.com ([69.89.25.95]:42465 helo=gproxy1.mail.unifiedlayer.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bunlc-0008Em-3G for emacs-devel@gnu.org; Thu, 13 Oct 2016 17:42:20 -0400 Original-Received: from cmgw4 (cmgw5 [10.0.90.85]) by gproxy1.mail.unifiedlayer.com (Postfix) with ESMTP id 42B1E178E8D for ; Thu, 13 Oct 2016 15:35:29 -0600 (MDT) Original-Received: from box522.bluehost.com ([74.220.219.122]) by cmgw4 with id v9bN1t00R2f2jeq019bRag; Thu, 13 Oct 2016 15:35:29 -0600 X-Authority-Analysis: v=2.1 cv=IecUBwaa c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=CH0kA5CcgfcA:10 a=mDV3o1hIAAAA:8 a=XUYESbKRhn20NqpE32MA:9 a=b3VjvGBnL5UA:10 a=_FVE-zBwftR9WsbkzFJk:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From; bh=P9RcdVgj6nMxk4lbqyF85i16TcjxPc3ZUOwzxrF47/k=; b=x9/xn2N8LP1TfUnvD+rbWRitng tmKtv+3oAwWbzfwDSTXDjqQ/EUUOyNlxEpN7crG+/1T41VmgWf1PVe3/R0TYUn/4NqlAogV6zymRw ZjA5JR4Pc2OBY6iz3AjnJSPKG; Original-Received: from 174-16-143-211.hlrn.qwest.net ([174.16.143.211]:34730 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_1) (envelope-from ) id 1bunes-00060Q-0x; Thu, 13 Oct 2016 15:35:22 -0600 X-Attribution: Tom In-Reply-To: (Richard Stallman's message of "Thu, 13 Oct 2016 17:23:46 -0400") X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box522.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.143.211 X-Exim-ID: 1bunes-00060Q-0x X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 174-16-143-211.hlrn.qwest.net (bapiya) [174.16.143.211]:34730 X-Source-Auth: tom+tromey.com X-Email-Count: 21 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 69.89.25.95 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:208219 Archived-At: RMS> It would take a lot of work for me to try to find the code RMS> by looking at that directory, and then a lot more work for me RMS> to figure out what the package does by reading the code. RMS> Would you please post the documentation here? I've appended it. I can send the source if you want as well. It's short (388 LOC including comments). The essence of it is hooking internal-macroexpand-for-load to rewrite forms. Tom This is a simple module system for Emacs Lisp, inspired by [Nic Ferrier's proposal](https://lists.gnu.org/archive/html/emacs-devel/2013-07/msg00738.html). It allows short symbol names in the source code but exports the names using the standard elisp-style module prefixes. To define a module, see `define-module`. After a `define-module`, some symbols in the current load file will be renamed. In particular, symbols coming from `defvar`, `defconst`, `defun` and the like will be renamed -- but other symbols will not be. This feature is critical to keeping normal Elisp working, as the Emacs core sometimes requires certain symbol names in APIs. Note that a private symbol must be seen -- declared with `defvar` or the like -- before any uses. Otherwise the renamer will not know to rename the use. Normally this is not a problem but you must take care to declare internal functions when you need mutual recursion. You can do this like so: ```elisp (declare-internal-function private-function) ``` When renaming, exported symbols will be given the package prefix, and internal symbols will use the "--" convention. E.g., consider: ```elisp (define-module testmodule :export (somevar)) (defvar somevar nil) (defvar private nil) (provide 'testmodule) ``` This defines a module named `testmodule` and two variables, an "exported" one named `testmodule-somevar`, and a "private" one named `testmodule--private`. Symbols from other modules can be imported using `import-module`. Because module boundaries are purely based on symbol naming conventions, you can also "import" from modules that do not use module.el. These modules are called "implicit" modules. Importing a module also `require`s the feature. ```elisp (define-module testmodule) ;; Import some symbols from M. (import-module M :symbols (a b c)) ``` Sometimes, for an implicit module, the name of the feature and the name of the module prefix differ. In this case you can use the `:prefix` keyword: ```elisp (import-module cl-macs :prefix cl) ``` A module is closed by calling `provide`. This module system doesn't have an explicit notion of submodules. Rather, it piggy-backs on the existing feature of `require`, that lets a directory separator in the symbol name load a file from a subdirectory: ```elisp (require 'feature/subfeature) ``` ### Caveats The renaming is not perfect. If your code uses `intern` or otherwise reflects on symbols then you have to be aware of the transforms done by module.el. Another issue is that autoload cookies aren't rewritten. This seems reasonably hard to fix, since they can refer to any symbol and so the cookie extraction code would have to duplicate the importing logic.