Arc Forumnew | comments | leaders | submitlogin
Bug?: (pr '("a string")) omits the quotes
1 point by rntz 5608 days ago | 2 comments

  arc> ([idfn nil] (prn '(foo bar baz)))
  (foo bar baz)
  nil
  arc> ([idfn nil] (prn '(foo "bar baz"))
  (foo bar baz) ; expected behavior: (foo "bar baz")
  nil
Is this a bug? Arguably I should be using 'write here, but I'm unsure of the usefulness of having 'pr and 'prn have this behavior instead of imitating 'write in the case that their arguments are not strings.


2 points by fallintothis 5607 days ago | link

As you say, using write may be the thing to do. It's good to raise these questions, though, as there's no particularly "right" answer. write and disp compile to Scheme's write and display, for which R5RS gives the rationale (http://schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-9...):

  Write is intended for producing machine-readable output and display is for
  producing human-readable output. Implementations that allow "slashification"
  within symbols will probably want write but not display to slashify funny
  characters in symbols.
Where "slashification" looks like

  arc> (do (write 'a\ b) (prn))
  |a b|
  nil
  arc> (do (disp 'a\ b) (prn))
  a b
  nil
The quote issue raises consistency questions:

  arc> (prn "quotes don't show here")
  quotes don't show here
  "quotes don't show here"
  arc> (prn (list "so should they really show here...?"))
  (so should they really show here...?)
  ("so should they really show here...?")
It makes sense that disp doesn't print the quotes in the second example: it doesn't in the first, and the output isn't meant to be read back in by the machine, unlike write's output. But there's nothing obviously wrong with it printing the quotes, either.

-----

0 points by scs 5570 days ago | link

ss

-----