5 ms·
I have never understood Erik's enduring appeal, particularly in light of the vehemence with which he could be technically wrong. <foo bar="zot">quux</foo>
by lisper 12y ago
I have never understood Erik's enduring appeal, particularly in light of the vehemence with which he could be technically wrong.
<foo bar="zot">quux</foo>
should be read as
(foo (bar "zot") "quux")
and most definitely _NOT_ as ((:foo :bar "zot") "quux")
Erik has this exactly backwards. His rendering is ambiguous: it does not distinguish <foo bar="zot"/> from <foo><bar>zot</bar></foo> (as he himself implicitly acknowledges later in the post). Also, rendering unqualified tags as keywords makes it easier to deal with namespaces.
IMHO the Right Way to render <foo bar="zot">quux</foo> is ((:foo :bar "zot") "quux") with the further qualification that if there are no tags then ((:foo) "quux") can be simplfied to (:foo "quux"). This preserves a 1-1 correspondence between XML and sexprs, which is IMHO a requirement (in fact, the only requirement) for a reasonable mapping. If you have a 1-1 correspondence then you can freely convert back and forth between the two. If you don't, then you can't.
- Quanttek 12y ago> IMHO the Right Way to render <foo bar="zot">quux</foo> is ((:foo :bar "zot") "quux") with the further qualification that if there are no tags then ((:foo) "quux") can be simplfied to (:foo "quux"). Alternatively you could also write (foo ((bar "zot)) quux) as it is handled in Racket's X-expressions, which has the distinct advantage that the symbol/identifier foo is not nested one level deeper, which makes reading it harder, while still preserving the 1-1 correspondence. Though in this case the meta-information is the first argument instead of being part of the identifier. It also works perfectly with stuff like <foo bar="zot" baz="zor">quux</foo>, which is read as (foo ((bar zot) (baz zor)) quux). I personally think this is way better than ((:foo :bar "zot" :baz "zor) "quux")
- lisper 12y ago> which has the distinct advantage that the symbol/identifier foo is not nested one level deeper Why is that an advantage? I actually like the aesthetics of the extra parens in the CAR. It provides a clear visual distinction between code and markup (at least in Common Lisp, where ((...) ...) is defined by the standard to be a syntax error) which I think is a feature. e.g.: ((:div :class "toplevel" :style "display:block") (:h1 "This is a heading") "This is content") I think it looks kinda nice.
- brandonbloom 12y agoYou've misunderstood his point with that example. He knows it's ambiguous, but he's telling you that it's an undesirable distinction to make.
- lisper 12y agoOK, but then he's wrong about that. <input type=button/> does not mean the same thing as <input><type>button</type></input>. No matter how you slice it, Erik is wrong here. His translation is lossy, and a lossy translation is bad because it can't be applied bidirectionally.
- evacchi 12y agoI believe his point was that what you are losing there does not really carry any extra information
- brandonbloom 12y agoAgain, you're missing the point. He's saying that those two things shouldn't be different. He's clearly well aware that they are different. His very first sentence is: As long as we think aloud in alternative syntaxes, I actually prefer to break the _incredibly_ stupid syntactic-only separation of elements and attribute values. His entire post is a hypothetical in which you 1) need a structured markup language and 2) are willing to break compatibility with XML.
- anon4 12y agoIt is absolutely not-ambiguous: Pairs in parentheses are attributes, everything after is values. He later introduces the || syntax to disambiguate: (foo (bar "zot")) vs (foo || (bar "zot")). The <|> syntax is also absolutely non-ambiguous.
- lisper 12y agoWell now, this is interesting. All of the other responses here have acknowledged that it is ambiguous (as Erik himself acknowledged) and argued that it should be ambiguous. And here you are saying the exact opposite: it is not ambiguous, the original rendering making it ambiguous is broken and needs to be fixed, and Erik fixes it by introducing new syntax (which, BTW, makes the new representation no longer an S expression). It seems to me that the fact that people can't even agree whether he actually meant P or ~P ought to call his wisdom (or at least his ability to communicate) into question.
- kmill 12y agoErik clearly states that he thinks the attribute/element distinction is "_incredibly_ stupid," and while he does give an example of an expression which combined the two, he does not neglect to call it "pathological." I'm fairly certain that the reason he handles the pathological cases is so that he may interface with other people's XML specs. One can hate the design while meaningfully working with others, right? By the way, it is an S expression. He uses the empty symbol || as a delimiter for the pathological cases. Furthermore, the Enamel syntax he describes is a reader macro; whether you think that is OK is up to your own personal aesthetics, but it is just an alternative syntax for lists (not everything has to syntactically be an S-expression, after all). You (lisper) keep mentioning that there is a distinction between metadata and data, and you mention that composibility is the big distinction. However, as far as I can tell, you can compose child elements in an ordered sequence which you can't do with attributes (though you can append sets of attributes as sets), and you can't nest attributes. It seems to me that the only reason for everything not to be elements is that they take longer to type with XML syntax. Also, child elements are in some sense just attributes with implicit numeric keys, if attributes could be data other than strings. What is an example of this distinction between attributes and elements which is not just syntax?
- lamacase 12y agoI think the confusion here (not yours specifically) is that his actual <|> syntax resolves this ambiguity and his informal CL translation does not. You are correct that: <foo bar="zot">quux</foo> => (foo (bar "zot")) <foo><bar>zot</bar></foo> => (foo (bar "zot")) Is an ambiguity. However in his <|> syntax: <foo bar="zot">quux</foo> => <foo <bar | "zot">> <foo><bar>zot</bar></foo> => <foo | <bar | "zot">> What about, say: <foo bar="zot">quux</foo> as (foo (bar "zot") (data "quux")) Or any other keyword which you could reserve as being the special "non-meta" data? (foo (bar "zot")) is then unambiguously <foo bar="zot"/> (foo (data (bar "zot"))) is then <foo><bar>zot</bar></foo> I'm not sure whose side I'm on by proposing this. I'd be interested to know.
- lisper 12y agoSure, there are lots of ways of restoring the lost information. My point is just that Erik opens by claiming emphatically (AFAICT -- people seem to disagree about this) that this information SHOULD NOT be restored, that it is WRONG to try to make a syntactic distinction between data and metadata in a markup language: "Whether something is an attribute or element is _completely_ arbitrary." THAT is the point on which he is (IMHO) clearly wrong. (He's wrong about a bunch of other things too, but that's the most serious mistake.) EDIT: Here is Erik doubling down on his position: "I have a simple way to get rid of the annoying verbosity of these stupid languages while _retaining_ that mistake [sic] between attribute values and elements"
- lamacase 12y agoI interpreted him as saying (and it sounds like you may have as well?) that this distinction SHOULD NOT be ENCODED in XML or S-Expression or whatever data serialization/markup syntax you invent. He does not appear to make an argument as to why he believes this, so I'd say his claim is at worst unsubstantiated. I find it hard to believe that there's a objectively correct decision about the number of semantic concepts that "should" be encoded in a syntax, but I can understand why lisp enthusiasts would be on the 'closer-to-none end of that spectrum. I'd be interested to hear why you think it's so essential. The only argument I'm really aware of is compatibility with existing markup languages. I would guess that a markup syntax that is as simple and regular (ie. syntactically consistent) as possible would be the easiest to operate on algorithmically. I would also guess that this would make it easier to build, on top of this language, tools which present the content in various ways that are easier to read/write/manually-manipulate if you so desired. Actually, his example syntax makes this argument implicitly. He is suggesting that his tools are significantly easier to implement by working with plain S-Expressions, and that they can easily be mapped to a 'write-friendly markup language that is isomorphic to XML anyway. I make no claims about the quality of his presentation or the clarity of his arguments.