From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: adding namespaces to emacs-lisp (better elisp?) Date: Fri, 26 Jul 2013 14:18:48 -0400 Message-ID: References: <874nbh2z3y.fsf@ferrier.me.uk> <871u6l2ral.fsf@ferrier.me.uk> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1374862735 14488 80.91.229.3 (26 Jul 2013 18:18:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 26 Jul 2013 18:18:55 +0000 (UTC) Cc: emacs-devel@gnu.org To: Nic Ferrier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jul 26 20:18:56 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1V2mbQ-0006DV-JO for ged-emacs-devel@m.gmane.org; Fri, 26 Jul 2013 20:18:56 +0200 Original-Received: from localhost ([::1]:54577 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2mbP-0001zM-QT for ged-emacs-devel@m.gmane.org; Fri, 26 Jul 2013 14:18:55 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47334) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2mbM-0001zC-Pi for emacs-devel@gnu.org; Fri, 26 Jul 2013 14:18:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V2mbK-0005YS-3L for emacs-devel@gnu.org; Fri, 26 Jul 2013 14:18:52 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:43103) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2mbJ-0005YN-VL for emacs-devel@gnu.org; Fri, 26 Jul 2013 14:18:50 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av4EABK/CFFFpZPn/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLDiYSFBgNJIgeBsEtkQoDpHqBXoMT X-IPAS-Result: Av4EABK/CFFFpZPn/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLDiYSFBgNJIgeBsEtkQoDpHqBXoMT X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="19923999" Original-Received: from 69-165-147-231.dsl.teksavvy.com (HELO pastel.home) ([69.165.147.231]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 26 Jul 2013 14:18:42 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 9EF3562D9D; Fri, 26 Jul 2013 14:18:48 -0400 (EDT) In-Reply-To: <871u6l2ral.fsf@ferrier.me.uk> (Nic Ferrier's message of "Fri, 26 Jul 2013 17:56:50 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.182 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:162158 Archived-At: >> - I'm not sure how well it will cope with shadowing and non-namespaced >> symbols (e.g. symbols like `face' that aren't used as variables). >> The rule "global obarray is inspected first and if a symbol is found >> there that's what is used" means that we have to be vary careful about >> interning things in the global obarray since it can affect the way >> other code is handled. > Give an example of a potential problem? > I *think* you mean that adding new global symbols could affect > namespaced code. But I don't think that's any different than right now. Here's a scenario: - namespaced packages A and B both locally define a function `toto'. - non-namespaced package C comes along with a symbol `toto' somewhere in its code, suddenly causing A and B's `toto' to be global rather than local. Note that instead of "non-namespaced package C", we could have some package which uses symbols as "uniquified strings" and which uses the global obarray for it and might occasionally intern `toto' in the course of its normal execution. IOW I think we should instead first look in the local obarray (over which the coder does have control) and if that fails then look in the global obarray. > I disagree that's a reason not to try it. Yes, it could be a > problem... but the presumption has to be that new code would use this > way to namespace itself and that global pollution would therefore slow > down. Old non-namespaced, hideous, dynamically scoped is Emacs's bread and butter and we can't hope for it to disappear soon. > Ideally that should work with some simple statement: > ;; Package: stefan > (import 'nic) > (foo) > in this example nic::foo and nic::bar would both be imported directly > into "stefan" and after that was done the following would be true: > (eq (symbol-function 'nic::foo) > (symbol-function 'stefan::foo)) Should this equality still stand if I (fset 'nic::foo 'blabla)? I.e. is it one and the same symbol? > or: > (import 'nic :as 'blah) > (blah::foo) > in this example nic::foo and nic::bar would be imported under the > namespace 'blah in the package "stefan". > I guess this could then be a use case for trees of namespaces, so that: > (stefan::blah::foo) > was possible. Indeed, my impression is that you inevitably get to this kind of situation, which you seemed to dislike. I personally don't find it problematic, not even if we generalize it to some arbitrary graph, with cycles and all. Stefan