From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Helmut Eller Newsgroups: gmane.emacs.devel Subject: Re: Enhancement suggestion: prin1 extension mechanism Date: Mon, 15 Sep 2008 00:09:21 +0200 Message-ID: References: <200809110325.m8B3PYFE031034@projectile.siege-engine.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1221430240 25263 80.91.229.12 (14 Sep 2008 22:10:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 14 Sep 2008 22:10:40 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Sep 15 00:11:37 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Kezmv-0003FF-Pp for ged-emacs-devel@m.gmane.org; Mon, 15 Sep 2008 00:09:50 +0200 Original-Received: from localhost ([127.0.0.1]:51424 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kezlu-0005oA-UG for ged-emacs-devel@m.gmane.org; Sun, 14 Sep 2008 18:08:46 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kezks-0005Ns-E0 for emacs-devel@gnu.org; Sun, 14 Sep 2008 18:07:42 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kezkq-0005NZ-Ty for emacs-devel@gnu.org; Sun, 14 Sep 2008 18:07:42 -0400 Original-Received: from [199.232.76.173] (port=41682 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kezkq-0005NW-QW for emacs-devel@gnu.org; Sun, 14 Sep 2008 18:07:40 -0400 Original-Received: from main.gmane.org ([80.91.229.2]:45431 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Kezkq-0007Fg-LW for emacs-devel@gnu.org; Sun, 14 Sep 2008 18:07:40 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1Kezkh-0001vC-IE for emacs-devel@gnu.org; Sun, 14 Sep 2008 22:07:31 +0000 Original-Received: from dialin-226118.rol.raiffeisen.net ([195.254.226.118]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 14 Sep 2008 22:07:31 +0000 Original-Received: from eller.helmut by dialin-226118.rol.raiffeisen.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 14 Sep 2008 22:07:31 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 51 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: dialin-226118.rol.raiffeisen.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:bO7qwlT78nZlxwUtV/gxlbD3cIQ= X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:103885 Archived-At: * Stefan Monnier [2008-09-14 21:35+0200] writes: >>> I fear it'd be difficult to make it work without incurring a significant >>> performance overhead. > >> If the table is nil you could use the default hardcoded printer without >> lookups. > > In many important cases (e.g. CL has been loaded), the table wouldn't be > nil, and performance should still be good. Why? It could be nil by default, just like print-circle is nil by default. >> If the entries in the table can be accessed from Lisp code, we could >> remember the default print function for a type before installing a >> custom printer. E.g. if a vector doesn't have the special symbol in the >> first entry, we could call the previously remembered default printer >> instead of iterating manually over the vector. Recursive calls to print >> would again use the custom print function. > > I don't know what you're talking about. I'd probably understand better > with a piece of code. (defvar my-printer-table (let* ((table (make-pprint-dispatch-table)) (default (get-pprint-dispatch table 'vector))) (set-pprint-dispatch table 'vector (lambda (obj stream) (if (eq (aref obj 0) 'my-type) (princ "#" stream) (funcall default obj stream)))) table)) (defun my-prin1 (obj stream) (let ((pprint-dispatch-table my-printer-table)) (prin1 obj stream))) The interface functions would be make-pprint-dispatch-table, get-pprint-dispatch, and set-pprint-dispatch. pprint-dispatch-table contains the current table in use. >> And if someone produces so much output the that it takes to long to >> print, he probably doesn't want to read it anyway :-) > > But it's difficult for Emacs to find ou before it's too late. The user can press C-g if it takes to long. Oh wait, print isn't interruptible. To bad. Helmut.