logoalt Hacker News

velcrovanyesterday at 6:22 PM3 repliesview on HN

HTML (and XMLish syntax in general) is LISP syntax (not semantics) in disguise. A tag can be viewed as function application, with the attributes as named arguments and the elements as variadic arguments.

The example from the link's main page is equivalent to:

    (button "Say something")
    (on_click
      (selection-insert-after
        (div "Hello, World ")))
[apparently HN strips all emoji but you get the idea]

Replies

dragonwriteryesterday at 6:26 PM

> HTML (and XMLish syntax in general) is LISP syntax (not semantics) in disguise

No, its not. If it was, the attribute vs. child element distinction would not exist. HTML (and HTML-inspired XML) syntax is not a trivial alternative to S-expression syntax, it is more complex with additional distinctions.

A simplified subset of (HT|X)ML that uses only elements and no attributes is pretty much directyl equivalent to S-expressions, sure.

show 1 reply
SkiFire13yesterday at 7:07 PM

I'm not sure I see your point. Yes, you can describe the same meaning/structure with S-expressions and HTML/XML syntax, but that's the complete opposite of having the same syntax, in fact syntax is the difference!

lassejansenyesterday at 6:25 PM

Exactly, code is data ;)

show 1 reply