I am new so forgive me for the blunt question. Where are string literals at?
I assume you mean something other than
user> "foo"
"foo"
?Yup.
JS has a pretty thourough one that includes passing values like a java format call https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals
But as simple as a string that doesn't need every " escaped would be amazing. If I get a json literal string right now, I have to stick it in a file and slurp or escape every dern " in a different editor.
For example from our logs. The json is literal and not escaped.
And to clarify literal looks like {"someKey": 1} and not like {\"someKey\": 1}
https://ask.clojure.org/index.php/8520/text-block-literal-string-literal-unsescaped-string-literal
Looks like its mostly denied as a replacement for JS, not just the simple version of being able to grab a string and use it in the repl.
I don't care about the JS replacement. It would save me hours a week not having to create a file to slurp in json or edn that isn't escaped.
Not exaggerating on the hours number.
user=> (def x (read-line))
{"someKey": 1}
#'user/x
user=> x
" {\"someKey\": 1}"
user=>Hmm. Ok, this is new to me.
Work smarter not harder.
A lot of people don't think about hijacking the repls in/out streams like that, but it is great
Nrepl might not like it, but if you are using the built in clojure repl or some variant of it it works great
Different backgrounds, the stdin / stdout stuff isn't as obvious until its said.
Not immediately working with Calva / VSCode but I will look deeper
Thank for the tip.
Well, that is the other thing, tooling authors don't think about it either and make assumptions that break it
Fair
Not working with my lein repl either
Looks like it does with cli clj
ohhh calva works, just not babashka. Randomly that was my only open repl.
This covers most of my daily time waste. I would still like to be able to write unit tests without having to escape every dern " but that's less of an issue.
Feel free to file a bug report for bb if there is one
> Nrepl might not like it that works fine in Cider (nrepl)
So good chat above. string literals might have a connotation with JS, and don't ever expect that duplication. What about the phrase "unescaped string notation"? Unit tests with large payloads (json or edn) will be so much easier to write if we don't have to go escape every "
I’ve never had a use case where I’ve needed super large string payloads in test source code that couldn’t live in resource files on the classpath. Can you put the payloads in resource files instead? Could you just use maps and serialize into the string format before testing?
Medium. Just big enough for the escaping to be annoying, but not big enough for a file.
Its more like 20-40 responses that are not that large but would need to be escaped.
Gotcha, the anti-goldilocks zone. Just right in all the wrong ways
Maybe you can use a tool like http://cljson.com/ and convert your jsons to edn, and then have those payloads as edn in your tests wrapped with (json/write-str edn-payload)
Funny. This whole problem was somewhat confusing to me because Cursive automatically escapes " as you type them. I kind of assumed all paredits did the same.
yeah, same thing happens in emacs with clojure-mode
also if you wrap a json in quotes it will escape them automatically
(It also works when pasting into a string.)