________________________________________________________________________________
Here is what the SDLang example would look like in EDN (Extensible Data Notation), a subset of Clojure:
; Maps are denoted as key-value pairs inside curly brackets: {:title "Hello, World"} ; Vectors are denoted by square brackets: [:bookmarks 12 15 188 1234] ; Or you can use a map with a keyword that maps to a vector: {:bookmarks [12 15 188 1234]} ; Maps are collections of key-value pairs: {:author "Peter Parker" :email "peter@example.org" :active? true} ; Data structures are heterogeneous and nest: [:contents [:section "First section" [:p "This is the first paragraph"] [:p "This is the second paragraph"]]] ; ^ Hiccup actually renders these to HTML. ; Everything is an expression, so strings just work: "This text is the value of an anonymous node!" ; A matrix is just a vector: [1 0 0 0 1 0 0 0 1] ; Or you could partition it into rows: [[1 0 0] [0 1 0] [0 0 1]]
https://github.com/edn-format/edn
I feel like the number one reason to use XML is the mixed content. This is also why XML and derived formats (the xml-y parts of HTML) are so good as markup languages.
So this:
p { "mixed" img href="test.png" "content" }
is worse than:
<p>mixed<img href="test" />content</p>
... at least as markup, since having to wrap all text in quotes is tedious.
The other language I know of that provides "natural" mixed content is scribble [1], but I think the only implementation that I know of is the racket one, since it is so tied to racket semantics.
If you take mixed content away from XML, then you may as well use one of the myriad of existing IDL languages, no?
1:
https://docs.racket-lang.org/scribble/getting-started.html
I first saw .sdl used by a D package. I liked it as an alternative to XML where there is a hierarchy, beginning and end tags (sdl uses {}) and multiple children at the same level, but at this point, the only reason why I decided to use it in my D projects was because the API to parse it is more convenient than using dxml imo.
It looks nice! But it's still missing a semantics. When are two values equal? When are they distinct? JSON and most other formats also have no real semantics. XML is a notable exception, with XML infoset defining a semantics for the syntax. See also
https://preserves.gitlab.io/preserves/why-not-json.html
The funny thing is that all of these examples are valid Oil syntax [1], since I added Ruby-like blocks with { } to shell. A block can be evaluated to a JSON-like data structure, e.g. this:
server foo { port = 80 root = '/' section bar { ... } }
could become:
{name: "foo", port: 80, root: "/", "bar": { ... } }
And you can use if statements and loops to generate repetitive structures! Rather than using textual templating.
(The syntax is all there, but the evaluation is incomplete -- contact me if you want to help, and influence the API/language design)
-----
The shell is a logical place for configuration, because shells start processes that need configuration. Configs are often passed in as environment variables or flags.
The syntax can support:
title "Hello World" # like SDLang
in addition to
title = "Hello World"
although I'm still wondering if we should enforce one or the other for consistency. The latter is more flexible in Oil because you have arbitrary expressions on the RHS.
[1]
http://www.oilshell.org/release/latest/doc/idioms.html
https://lobste.rs/s/6oxpe3/s_lot_yaml#c_mje209
Awesome, maybe the best thing I’ve seen since EDN. I might have to adopt this if EDN is too hard for my audience. Looks like converting to native Clojure data right after reading and back before display/storage should be easy enough.
Any concept of namespaces? I read the page, saw none. I have this mapping of XML to EDN that I want to apply, maybe port the stock XMPP transport. (I’ve a Patreon if this sounds good, same handle).
It mentions namespaces in the last code block on the page.
// Namespaces are supported renderer:options "invisible" physics:options "nocollide"