basilisp-lang / basilisp

A Clojure-compatible(-ish) Lisp dialect targeting Python 3.8+
https://basilisp.readthedocs.io
Eclipse Public License 1.0
198 stars 4 forks source link

string double quotes representation inconsistency #891

Closed ikappaki closed 3 months ago

ikappaki commented 4 months ago

Hi,

there appears to be an issue with how double quotes " are represented in various string outputs, either in embedded double quotes or when printing out sequences.

This is I think a side effect of using the internal python to string representation, which does not escape quotes.

To reproduce,

  1. Open up the REPL and str or prn string with embedded quotes or sequences.
    
    basilisp.user=> (str "a")
    "a"

embedded quote not escaped in returned string

basilisp.user=> (str "\"a") ""a"

a not wrapped in quotes

basilisp.user=> (str ["a"]) "[a]"

basilisp.user=> (pr ["a"]) nil ["a"]

embedded quote not escaped

basilisp.user=> (pr "\"a") nil ""a"

basilisp.user=> (pr ["a"]) nil ["a"]


contrast with Clojure
``` clojure 
clojure.pprint> (str "a")
"a"
clojure.pprint> (str "\"a")
"\"a"
clojure.pprint> (str ["a"])
"[\"a\"]"

clojure.pprint> (pr "a")
"a"
nil
clojure.pprint> (pr "\"a")
"\"a"
nil
clojure.pprint> (pr ["a"])
["a"]
nil

Not sure how to fix this, would this require register a new lrepr function for python strings?

Thanks

ikappaki commented 3 months ago

I have opened a separate issue for the embedded quotes not escaped in string output #894.

This issue deals with strings not being wrapped up with double quotes in collections or seq items.