From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Q: BLV for function slots + BL obarray/hmap for symbol lookup? Date: Sat, 29 May 2021 09:56:27 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27919"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Arthur Miller Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat May 29 15:57:20 2021 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 1lmzSq-00075c-HY for ged-emacs-devel@m.gmane-mx.org; Sat, 29 May 2021 15:57:20 +0200 Original-Received: from localhost ([::1]:52582 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lmzSp-0005Md-FW for ged-emacs-devel@m.gmane-mx.org; Sat, 29 May 2021 09:57:19 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44058) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lmzS6-0004aN-7s for emacs-devel@gnu.org; Sat, 29 May 2021 09:56:34 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:31611) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lmzS3-0008AF-4i for emacs-devel@gnu.org; Sat, 29 May 2021 09:56:33 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id A20D5440CE7; Sat, 29 May 2021 09:56:29 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 55AF444083B; Sat, 29 May 2021 09:56:28 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1622296588; bh=PkQRKH+86dTr83BlNaaoCCIsfKv/u3P5kprG4T6OG+0=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=k4uLoT+ukl/p7rMV00ER1aRTeC1UOZXOAasRzUIAYMIQSW4gUJdJixYhvdvrKAqI7 huM8q801JCAU3h48M9fiUfSzKDQ35B+cOFgGOkZSYkMfaRibailcJ5E0CIPPNYGQg0 lWm515eB8p0wJ387lIjWMZhl184OvFuSodtzuxQmQwsT20Vvmem7Ow9GVH7KJQCO01 QpR66tM3mM0Z7h/MlheKzeor1s5uqMGagbvBkP9ny4l3cddhGXXSzyJR/n8yXWkX1V oNgHpekcxAtrvIaU7qTaaY4FSMVA6xCfhXph0sfh71q8tyb6qDjJdFna5jxDcuArXU fYeCTDzab1Ufw== Original-Received: from alfajor (69-196-163-239.dsl.teksavvy.com [69.196.163.239]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 284F6120EFC; Sat, 29 May 2021 09:56:28 -0400 (EDT) In-Reply-To: (Arthur Miller's message of "Sat, 29 May 2021 09:31:43 +0200") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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:270061 Archived-At: > Just as curiosa to confirm, yes that worked, rather well :-). That was actually > what I asked for if you think, I just didn't thought of copying over the > obarray. > > (setq-local obarray (copy-sequence obarray)) > (defvar mysymbol "A SYMBOL") > (defun myfunc () "HELLO") > > nysymbol and myfunc were avialable only in that buffer. > > Don't know how efficient it is to copy entire obarray, in possibly > serveral buffers, but for the intended purpose, as a buffer-local > namespace works well. Thanks. In terms of efficiency: the global obarray holds about 50k-100k symbols, every symbols occupies 6 words (i.e. 48 bytes on a 64bit system), so the copy should allocate about 3-5MB of memory. That's not very large if you only expect to make a couple of such obarrays in any Emacs session. In any case, you may encounter more serious difficulties along the way, such as the fact that reading `nil` will not return the same symbol as when you read `()`. It *can* be a solution for a situation like a DSL, but in any case it needs to be used with a lot of care (e.g. you don't want to end up `require`ing (or more generally `load`ing) a normal ELisp package in a context where `obarray` refers to such a copy). Stefan