Shared publicly  - 
 
syntax design. random thoughts.

in xml, it's nested syntax. there's a competing syntax from lisp.

the lispers claim their syntax is simpler and superior. I kinda went alone (i guess because Mathematica is like that too), but haven't really put thought on it. (it's subconscious doing!)

there's one major problem with the lisp way. If there's a missing closing bracket, it's impossible to fix, because the closing bracket contains on info whatsoever on which opening bracket it is paired with. With xml, it does, usually (unless all your elements are the same elements. ⁖ <p><p><p></p></p></p>)

so, this is actually a problem. In practice, missing a bracket do happen. Even if you are always careful.

so, sad, i think i'll have to admit the lisp way isn't superior.

but can we fix it? and still keep simple?

one way, is to allow multiple type of brackets. ⁖
〔〕【】〖〗「」『』〈〉《》
 and there's more.
this way, things are still simple, and do fix the flaw above.
Also, user can simply use one type of bracket, and press a button, and the editor will change them to cycle among different type of brackets. So, this way, as far as fix missing bracket goes, it's even more robust than xml.

humm… so far i think this is a solution.


〈HTML6: Your JSON and SXML Simplified〉
http://xahlee.info/comp/html6.html


am thinking this because am curring writing a delete-tag command
https://code.google.com/p/ergoemacs/source/browse/packages/xah-html-mode.el
HTML6: Your JSON and SXML Simplified. Programer for Hire. Xah Lee, 2010-09-21 , …, 2011-11-02. Tired of the standard bodies telling us what to do and change their altitude? Tired of the SGML/HTML/XML/...
2
François-René Rideau's profile photoFabrice Popineau's profile photoNick Alcock's profile photoXah Lee's profile photo
12 comments
 
Racket lets you use ( [ { — I don't know about the unicode variants, but if it doesn't support them yet, that would be easy to add.
 
As long as closing brackets are matched to the opening bracket, it accepts whatever you want. Note that in the default Racket syntax, all brackets have the same semantics; the only difference is in the syntactic matching of the closing parenthesis.
Xah Lee
 
wow. that's pretty cool.
 
Could you elaborate on why you said "If there's a missing closing bracket (in Lisp I guess), it's impossible to fix"? I don't see what xml brings on top of lisp syntax, from this point of view :
<foo> ... </foo>
(foo                )
should be equivalent?
Xah Lee
 
+Fabrice Popineau 
suppose i have
(a (b (d) (c))
it's missing a ending bracket, say a cat jumped to my keyboard and i didn't notice.

it could be this:
(a (b (d)) (c))
or
(a ((b) (d) (c))
Xah Lee
 
+François-René Rideau i suppose that involves modifying the lisp reader, which is C code. I don't know C, but i suppose this is not too hard, within my reach... maybe someday.
 
+Xah Lee Well ok, I see the point. But this point is only about wrong expressions. Use paredit :-)
Thanks. 
 
Both cases are just as problematic.

In Lisp, (... (let ((foo bar))) baz) oops I missed a bracket and foo is not bound while bar is executed. In XML, <a><b></a></b>, oops, now we have a redundancy which has caused an entirely useless error, as witness the fact that virtually all HTML parsers had a mode which treated </foo> like </>.

So you have a choice -- diagnose all nesting errors, or introduce errors because people got their nesting terminator wrong. Both are bad, but I happen to think that the XML way is worse, because the Lisp way almost always leads to a misnested bracket elsewhere, and thus a syntax error anyway. So the XML way is adding enormous verbosity and a new class of easy-to-trigger error for the sake of fixing an error class that is almost always diagnosed anyway.
Xah Lee
 
great point about the  <a><b></a></b> case.
Add a comment...