From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.devel Subject: Re: `unreadablep' Date: Wed, 15 Dec 2021 09:35:37 +0100 Message-ID: <87wnk6l0yu.fsf@gnus.org> References: <87bl1imhnd.fsf@gnus.org> <87h7bas2kb.fsf@yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12096"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Po Lu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Dec 15 09:36:55 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 1mxPmR-0002v8-2A for ged-emacs-devel@m.gmane-mx.org; Wed, 15 Dec 2021 09:36:55 +0100 Original-Received: from localhost ([::1]:35978 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxPmP-0008I0-Ea for ged-emacs-devel@m.gmane-mx.org; Wed, 15 Dec 2021 03:36:53 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:35638) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxPlR-0007Mw-MS for emacs-devel@gnu.org; Wed, 15 Dec 2021 03:35:53 -0500 Original-Received: from [2a01:4f9:2b:f0f::2] (port=40112 helo=quimby.gnus.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxPlN-00054S-LU for emacs-devel@gnu.org; Wed, 15 Dec 2021 03:35:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID :In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=mh1YSvWyLP5w4f4v1fqDk4e9miWamqbGTwmxzW1V37Y=; b=MVPb8UoQMDHIj4xA2kNL6UGJ5p c9fCGcxktFklYvyah6h4gyeFMgFh18oh1zIwTKYAEfoBXS3J08Ori5umMCyN7pRvqdgvWh9hvfuw/ iuejxddJzBIFm92Tgy6qaSU+hsONl1qOH83/+rRgjUgaaZH2Km1nMykf6SpEuPoU0HnA=; Original-Received: from [84.212.220.105] (helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mxPlG-0003Fr-Qm; Wed, 15 Dec 2021 09:35:46 +0100 Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAGFBMVEUtKjA6Qk5MWFwm HyO1l1x9jZtPcpL///9nLqjFAAAAAWJLR0QHFmGI6wAAAAd0SU1FB+UMDwgBH43OsMoAAAGxSURB VDjLZZM9bsMwDIVFCehscvAsctCcIDco2iPYcy2guv8RSuonkVLGQGx95nskJTvXAxBxc0CiwUyb rYXHzf4QDVdg77jgbL2xmofIhPXp8QgdALC02BrRX3eSL4tP4foYhs0dG/hm7OBhKahSFRxHHMXW 97XGBr4/oXloioVnvZoHNClVum/mzDSDYKCWZb01gM+M2wqAJm81EcEGHLg5vE6pg/fgbQJhAkNq lPvcFKYGSFbg2Tfg1wyQza99zKwFum1aDTdE6mTthFAm8ELwVGJRKVgtqB4TWjxUq5QhtQCg8/c8 s2W5tWD/e5zHka3cFVAqRznOkt9GAkVNLN7BXrDkYtcCdudLTFcqomwGHxuUa88VlAVEBR/Z9Fbg f1wqPuM/AGzuGeUJttF3BZIxleTsS2DmWEH0FUg6d1XNrwzRenW0jjI4lbu6x50SFhYbkgokJWPC KFcHzjtrZrSJdKVI9fOTmlHiMMmJvQGIdvR7CprWfhkIngxIS2Hdcdqz1/ugLYlqSU3RSRNpobEd GNRNyyVHvYmaoqOKo5JqnwEJiXEGJHU3dTZACAP8AcQ+cWvz2CwmAAAAJXRFWHRkYXRlOmNyZWF0 ZQAyMDIxLTEyLTE1VDA4OjAxOjMxKzAwOjAwaqGd1AAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyMS0x Mi0xNVQwODowMTozMSswMDowMBv8JWgAAAAASUVORK5CYII= X-Now-Playing: Sade's _Promise_: "Fear" In-Reply-To: <87h7bas2kb.fsf@yahoo.com> (Po Lu's message of "Wed, 15 Dec 2021 16:19:16 +0800") X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:4f9:2b:f0f::2 (failed) Received-SPF: pass client-ip=2a01:4f9:2b:f0f::2; envelope-from=larsi@gnus.org; helo=quimby.gnus.org X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RDNS_NONE=0.793, 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.29 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:281993 Archived-At: Po Lu writes: > Yes, it would be very convenient indeed. > > I think the best solution would be to allow `prin1' to optionally return > whether or not any unreadable objects were printed, instead of the > object itself. I was thinking that for efficiency (and ease of usage), nothing would be printed. That is, something like (defun unreadablep (object) (condition-case nil (prin1 object 'error-on-unprintable) (:success t) (unprintable-error nil))) and then prin1 would signal an error if it encounters an unprintable object in the structure, but otherwise print nothing. But I still haven't actually looked at the prin1 code, so I'm not sure whether that would be messy or not. =F0=9F=98=80 The advantage of using th= e prin1 code to do the checking (instead of implementing a separate function to traverse the data itself) is that we'd be pretty sure that there aren't any glitches between the prin1 implementation and the checker implementation... But having `prin1' return whether it printed something unreadable also sounds attractive. I guess it depends on the use case. If you're saying (if (unprintable o) (insert ";; " (prin1 o (current-buffer))) (prin1 o (current-buffer))) then you're traversing the data twice, which isn't efficient, so inserting it first and then checking would be nice. But if you're doing (when (unprintable o) (error "Nope")) then it'd be inconvenient for it to be printing anything. And what about `prin1-to-string'? It has to return the string... Hm... --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no