From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: New pp (was: bug#25295: 26.0.50; Represent eieio objects using object-print in backtraces and edebug) Date: Sat, 11 Mar 2017 10:38:47 -0500 Message-ID: References: <87pokampa4.fsf@ericabrahamsen.net> <87innrc03h.fsf@users.sourceforge.net> <87k27w8j2l.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1489246770 27215 195.159.176.226 (11 Mar 2017 15:39:30 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 11 Mar 2017 15:39:30 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: npostavs@users.sourceforge.net Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Mar 11 16:39:25 2017 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 1cmj76-00060X-DA for ged-emacs-devel@m.gmane.org; Sat, 11 Mar 2017 16:39:24 +0100 Original-Received: from localhost ([::1]:43800 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cmj79-0002qc-4R for ged-emacs-devel@m.gmane.org; Sat, 11 Mar 2017 10:39:27 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35851) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cmj6b-0002qX-8g for emacs-devel@gnu.org; Sat, 11 Mar 2017 10:38:54 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cmj6X-0005l1-Co for emacs-devel@gnu.org; Sat, 11 Mar 2017 10:38:53 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:62792) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cmj6X-0005kD-85 for emacs-devel@gnu.org; Sat, 11 Mar 2017 10:38:49 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0CwBAC4GcRY/3OXCkxdGgEBAQECAQEBAQgBAQEBg1FBIIEKjmGQXikBlx8qhXIEAgKCQEQUAQIBAQEBAQEBayiFFgEEAVYjBQs/BwsUGA2KLwgOtA+KXwEBAQEBBQEBAQEfBYs9gxeCCYUZBZBai2eBUoUklgaGYpF/gUQ2IYEEIxYILIVOgWgiNQGJeAEBAQ X-IPAS-Result: A0CwBAC4GcRY/3OXCkxdGgEBAQECAQEBAQgBAQEBg1FBIIEKjmGQXikBlx8qhXIEAgKCQEQUAQIBAQEBAQEBayiFFgEEAVYjBQs/BwsUGA2KLwgOtA+KXwEBAQEBBQEBAQEfBYs9gxeCCYUZBZBai2eBUoUklgaGYpF/gUQ2IYEEIxYILIVOgWgiNQGJeAEBAQ X-IronPort-AV: E=Sophos;i="5.36,147,1486443600"; d="scan'208";a="295032758" Original-Received: from 76-10-151-115.dsl.teksavvy.com (HELO pastel.home) ([76.10.151.115]) by smtp.teksavvy.com with ESMTP; 11 Mar 2017 10:38:47 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 380B46184D; Sat, 11 Mar 2017 10:38:47 -0500 (EST) In-Reply-To: <87k27w8j2l.fsf@users.sourceforge.net> (npostavs's message of "Sat, 11 Mar 2017 00:43:14 -0500") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 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:212906 Archived-At: > I posted an initial draft at > https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25122#21, I'm not seeing > as much speedup as I'd hoped, though I haven't tried optimizing it yet. Thanks. I answered there about the performance aspect. > +(defun pp-prin1 (object &optional stream) > + (let ((cl-print-readably nil) > + (stream (make-pp-state (or stream standard-output)))) > + (pp--scan :open-block stream) > + (prog1 (cl-prin1 object (cons :pprint stream)) ^^^^^^^^^^^^^^^^^^^^^ Why not just pass `stream' since it's a struct and we can hence dispatch based on its type? > +;; fallback to standard `cl-print-object'. > +(cl-defmethod cl-print-object (object (stream (head :pprint))) > + (pp--scan (cl-prin1-to-string object) (cdr stream)) > + object) Hmm... but if we use such a pseudo-stream here, doesn't it break all calls to `princ' within other cl-print-object methods (i.e. forcing us the override pretty much all existing cl-print-object methods with a pprint-specific one)? Stefan