Error formatting macro: pagetree: java.lang.NullPointerException
Skip to end of metadata
Go to start of metadata
You are viewing an old version of this page. View the current version. Compare with Current  |   View Page History

Alternate string quote syntaxes

Motivation

  • doc strings with examples could be more human readable
  • XML, JSON or SQL generation tests become filled with escaped quotes

Possible Solutions

Python-like triple quoted strings

Pros:

  • relatively simple syntax, for humans and parsers

Cons:

  • minor breaking change - """""" which is  3 empty strings would now be interpreted as only one empty string
  • have to add reader macro
  • breaking change to every other tool that reads Clojure syntax
    • including regexp-based syntax colorers, etc.
Heredocs

Pros: slightly more flexible than trple-quotes

Cons: more complex syntax

String Interpolation / Templating

Pros:

Cons:

Puzzles:

  • is the built-in format function enough?
Resource files

Pros:

  • Already exists

Cons:

  • Separate file for each string
  • Can't use for macro-interpreted things like doc strings
  • In tests, having the test data separate from the test itself is hard to read
Labels: