From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Pascal J. Bourguignon" Newsgroups: gmane.emacs.help Subject: Re: plists, alists, and hashtables Date: Thu, 06 Aug 2015 22:00:34 +0200 Organization: Informatimago Message-ID: <87lhdombkt.fsf@kuiper.lan.informatimago.com> References: <876150vwaa.fsf@mbork.pl> <873803x5q4.fsf@kuiper.lan.informatimago.com> <87a8u7we9s.fsf_-_@lifelogs.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1438891536 22825 80.91.229.3 (6 Aug 2015 20:05:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 6 Aug 2015 20:05:36 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Aug 06 22:05:28 2015 Return-path: Envelope-to: geh-help-gnu-emacs@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 1ZNRPr-0005cx-1r for geh-help-gnu-emacs@m.gmane.org; Thu, 06 Aug 2015 22:05:27 +0200 Original-Received: from localhost ([::1]:46500 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNRPp-0001jL-LY for geh-help-gnu-emacs@m.gmane.org; Thu, 06 Aug 2015 16:05:25 -0400 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 51 Original-X-Trace: individual.net 7n5S0Z46Z9aUJ1G6rbDuDw5+t1ewfXhcsAhzTNDaHlfS0YX1HJ Cancel-Lock: sha1:YzU1ZGU0Nzc4MzI4MThjZWE1MjE5YTU0Y2E4MDFiNWQ5MjBjMTMwMQ== sha1:OxUDnn+t8rxDp4RnBIoEvUydHso= Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Original-Xref: usenet.stanford.edu gnu.emacs.help:214014 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:106298 Archived-At: Stefan Monnier writes: > More specifically, I highly doubt that a special «k1 v1 k2 v2 ...» > syntax for hash-tables would make much difference compared to > (hash-table k1 v1 k2 v2 ...) which you can get today with a very simple > `hash-table' macro. I mean, you'd still have to say (gethash k m), > whereas you'd probably want something like m.k, etc... > For better or for worse, Elisp is not Python. I would like that while elisp lacks reader macros, you can still do a lot of things (with a pinch of kludgery) with macros. For example, you could write something like: (with-my-syntax (let ((h «k1 v1 k2 v2 k3 v3»)) h.k4:=44 print (list h.k1 h.k2))) Notice that the lisp reader will read as symbols things that you'd wish to be separate tokens: (flatten '(with-my-syntax (let ((h «k1 v1 k2 v2 k3 v3»)) h.k4:=44 print (list h.k1 h.k2)))) --> (with-my-syntax let h «k1 v1 k2 v2 k3 v3» h\.k4:=44 print list h\.k1 h\.k2) Nonethelss, your with-my-syntax macro can parse those symbols, and reconstitute a normal sexp: (macroexpand ' (with-my-syntax (let ((h «k1 v1 k2 v2 k3 v3»)) h.k4:=44 print (list h.k1 h.k2)))) --> (let ((h (hash-table 'k1 'v1 'k2 'v2 'k3 'v3))) (setf (gethash 'k4 h) 44) (print (list (gethash 'k1 h) (gethash 'k2 h)))) So you can still be happy. The only constraint is that you cannot have an unbalanced sexp in the body of your macro (parentheses, double-quote strings, vector brackets, etc). -- __Pascal Bourguignon__ http://www.informatimago.com/ “The factory of the future will have only two employees, a man and a dog. The man will be there to feed the dog. The dog will be there to keep the man from touching the equipment.” -- Carl Bass CEO Autodesk