Comments (7)
Further inspiration: Chicken Scheme multiline strings https://wiki.call-cc.org/man/4/Non-standard%20read%20syntax#multiline-string-constant
from edn.
Eg. of the Chicken Scheme syntax:
(define msg #<<END
"Hello, world!", she said.
END
)
Personally I've never liked how the closer for heredocs have to span the whole line, You end up having to push any closing brackets or other constructs to the line after and it always looks unnatural to me 😞.
from edn.
True. And I guess in a way, XML's CDATA tag takes this even one step further, at the cost of not letting you customize the closer, opening with <[CDATA[
and closing with ]]>
, no matter where on a line it is, and how much other stuff there is on that line.
from edn.
I mean, you could theoretically specify that the closer does not have to span the whole line, of course. "The closer is everything up to the first closing parenthesis" or something.
from edn.
@zilti You're correct. Strangely enough I've never encountered a language that allowed that. Both bash and ruby don't seem to allow it. However php does. I see no issue with heredocs if we're going down that route.
from edn.
After spending considerable time comparing string literal syntaxes across languages, here are my assessments:
-
Rust's string literals strike a nice balance between (a) ease-of-mechanical-parsing and (b) human-readability.
-
YAML's many kinds of string literals result in a format that is (a) difficult for machine parsing and (b) painfully complex for humans to use much less remember. As a result, the YAML spec is unnecessarily complicated, resulting in implementations of varying quality. Please, learn from YAML's choices here -- they are a cautionary tale.
Note: I could have phrased my comment more neutrally, but that would be hiding my bias. (My bias may or not be useful to you, so interpret it accordingly.) My assessment is informed by wrestling with tradeoffs in this space while designing a new human-readable interchange format.
from edn.
I would like to chime in with an idea I have recently had.
A multiline string might begin with a backslash character, followed by blank space and then a line limiter. Subsequent lines would have some blank space at the beginning, then a backslash character. The rest of the line including the new line would be part of the multi-line string. The first line that doesn't start with a pipe character is not included and parsing continues as normal. The first and the last new line characters in the multi-line string are always removed.
Examples:
{
:foo \
\Bar
\Baz
\
:Quxx "hi
}
Becomes
{
:foo "Bar\nBaz\n"
:Quxx "hi"
}
If alternative interpretations of the multiline string are needed, they can simply be dispatches. For example, #prose
before a multi-line string might result in a multi-line strain with all of the new lines truncated into spaces, like YAML's >
.
This makes several different types of multiline strings possible with a simple syntax that is easy to understand and remember.
It also allows you to embed one document inside another without escaping anything inside that document. All you have to do is prefix all the lines in the document with some space and a pipe. The ability to embed documents inside other documents is a killer feature for configuration languages. Being able to add it simply to edn like this would be amazing.
from edn.
Related Issues (20)
- The edn spec inaccurately describes what characters are allowed in symbols. HOT 3
- json-ld, #iri HOT 1
- Ratio datatype is not part of the spec even though clojure.edn supports it. HOT 6
- Support for not-a-number or non-finite floating point values HOT 1
- Single-quote is not mentioned as a valid symbol character HOT 5
- Spec allows consecutive colons in symbols and keywords HOT 3
- Can Keywords contain escape characters? HOT 1
- Support for cyclic data HOT 2
- Tagged Elements Issue? HOT 3
- Make the spec concrete already HOT 5
- edn spec does not yet include namespace map syntax
- How are consumers supposed to handle values with unrecognized tags? HOT 1
- Reader flag to support unicode escapes in string literals HOT 2
- ns alias HOT 2
- Issue in the spec for keywords
- An example of edn file HOT 1
- BNF is absent
- Provide a testsuite for EDN format
- JSON query results output option HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from edn.