emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: `unreadablep'


From: Lars Ingebrigtsen
Subject: Re: `unreadablep'
Date: Wed, 15 Dec 2021 12:16:17 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Po Lu <luangruo@yahoo.com> writes:

>> 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.
>
> Yes, my thoughts exactly.

And we could implement `readablep' (probably better without "un") as

(defun readablep (object)
  (prin1 object #'ignore 'return-readablep))

and not actually print anything (for the cases where it's more
convenient to call a predicate).

There's perhaps a slight performance issue -- if the unreadable object
is the first in a long list, we could have exited a lot sooner, but I'm
not sure that's really much of an issue in practice.  If it is, we could
perhaps change PRINTCHARFUN to take two arguments in this case, where
the second is EVERYTHING-IS-READABLE-SO-FAR, and then PRINTCHARFUN could
throw an error if it wishes...

Or, as has been suggested, add a new print-* variable to have the same
effect -- it'd fit in with the current design (of having a bunch of
print-* variables).

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



reply via email to

[Prev in Thread] Current Thread [Next in Thread]