On Tuesday, May 2, 2017 at 7:34:21 PM UTC-7, Alex Miller wrote:
>
>
> On Tuesday, May 2, 2017 at 6:00:52 PM UTC-5, Jenny Finkel wrote:
>>
>> Thanks for the reply. Your explanation for why it should be expected
>> sounds like implementation details though (why it is that way, but not why
>> it should be that way).
>>
>
> I'll grant you that, and I could certainly be wrong in my interpretation.
> In large part, the Clojure print system is based on the Common Lisp print
> system and its in many cases it's more complicated than I wish it was.
>
>
>> The docstring for 'pr' admittedly makes a reference to "by default"
>> ("Prints the object(s) to the output stream that is the current value of
>> *out*. Prints the object(s), separated by spaces if there is more than one.
>> By default, pr and prn print in a way that objects can be read by the
>> reader") but I don't understand why calling 'pr-str' inside of 'print'
>> should be considered non-default. Nothing in either of their docstrings
>> references the other, or mentions *print-readably*, you have to look at the
>> code directly to be aware of the relationship.
>>
>
> Generally, I find in most contexts Clojure code is using one or the other
> (print* for printing to console or repl for human consumption and pr* for
> intended later consumption as data via the reader). I cannot recall running
> into a combination like this in the past where print is being used with
> pr-str. Not saying it's wrong, just that it's not common in my experience.
>
>
>> I have a branch where pr-str binds *print-readably* to true and it seems
>> to work fine. Without re-implementing all of them together though I guess
>> that it's impossible to get a 'pr' inside of a 'print' to actually print
>> something that's readable, so it would only fix it for 'pr-str' and not for
>> 'pr'.
>>
>
> It's difficult for me to comment on the impact or extent of a change like
> this without substantial effort / archaeology. Certainly it seems
> problematic if this affects only some of the pr functions but not all of
> them.
>
> Can you explain more about how you are experiencing this problem in the
> first place?
>
It came up in the context of debugging (I agree that it's hard to imagine a
real "use case" for it). One of my colleagues was map'ing over some data to
pr-str it, and then println'ing that map to check what it was saving, and
then saved the result of the mapping, and then tried to read it back in
with read-string, and read-string was erroring. It took us a good several
hours of sleuthing to figure out what was going on. So my intent is just to
save other people that pain in the future. I wanted to submit a patch to
fix it, but saw in the instructions that the first step is to write to the
list to see if it's actually a bug, and I figured if it was I would take a
stab at fixing it. I hadn't realized the
pr-str-is-easy-but-pr-is-more-challenging aspect when I first wrote in, but
I think I see a path to a solution that would work for the whole 'pr'
family and not be a very large change.
-Jenny
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.