Live data from Hacker News

Produce HTML from S-Expressions

github.com

11–20 of 63 posts

Re: Produce HTML from S-Expressions

#11

Basically Haml then.

Haml is not homoiconic. It's like saying "the flask is basically a teapot". Sure, they both can serve similar purposes, but categorically they are very different things. They look different, they are usually made of different materials, and they are used very differently. So, no, it's not "Basically Haml"

Re: Produce HTML from S-Expressions

#12
post #7
post #2

(h1 :disabled Hello world!) (div :class="alert" So long, and (b thanks) for all the (em fish)) I hate that syntax for attributes. :class="alert" is strictly worse than ((class . "alert")) or any other variation that actually leverages s-expressions instead of merging key and value into the same symbol. Ew. Not a fan of the bare words instead of strings either, which means this cannot be naively evaluated by a Lisp. I…

> Not a fan of the bare words instead of strings either, which means this cannot be naively evaluated by a Lisp. Most Lisps (all that I know of) have a way to convert symbols to strings. The hard part is resolving the ambiguity between what should be text, and what should be treated as an HTML node. Like, what if I wanted to actually write the string "(b thanks)" on a page? R7RS could probably do this with the pipe i…

Bare words are fine until you have a variable with the same name as your bare word, so you need additional syntax to determine if you're referencing a variable, or it is just text.

Re: Produce HTML from S-Expressions

#13
post #10

Earlier quoted context omitted.

> :class="alert" is strictly worse than ((class . "alert")) or any other variation that actually leverages s-expressions instead of merging key and value into the same symbol. Ew. I hear you, but I wasn't aiming for leveraging the power of macros. Using `((class . "alert"))` does not provide any benefits over :class="alert". > Not a fan of the bare words instead of strings either, which means this cannot be naively e…

> Using `((class . "alert"))` does not provide any benefits over :class="alert". Of course it does. It is a s-exp, like everything else in this language, so it's just another list you can map, apply or otherwise transform. The keyword approach instead requires a weird incantation of (string-trim (cadr (string-split (keyword->string :class="alert") ?=)) ?") to extract the value from the attribute. For what benefit? If…

> If the goal is using s-exps, why not use s-exps for everything?

My goal wasn't "Use s-expressions", it's "More readable and writable HTML trees."

This isn't a Lisp interpreter either, TBH. There's plenty of those around and they require the user to use a Lisp implementation, and write Lisp code.

map, string-trim, car, cadr etc are not required for s-expressions, they're required for Lisp.

Re: Produce HTML from S-Expressions

#14
post #12
post #7

Earlier quoted context omitted.

> Not a fan of the bare words instead of strings either, which means this cannot be naively evaluated by a Lisp. Most Lisps (all that I know of) have a way to convert symbols to strings. The hard part is resolving the ambiguity between what should be text, and what should be treated as an HTML node. Like, what if I wanted to actually write the string "(b thanks)" on a page? R7RS could probably do this with the pipe i…

Bare words are fine until you have a variable with the same name as your bare word, so you need additional syntax to determine if you're referencing a variable, or it is just text.

> Bare words are fine until you have a variable with the same name as your bare word, so you need additional syntax to determine if you're referencing a variable, or it is just text.

This doesn't have variables. Or functions.

Re: Produce HTML from S-Expressions

#16
post #2

(h1 :disabled Hello world!) (div :class="alert" So long, and (b thanks) for all the (em fish)) I hate that syntax for attributes. :class="alert" is strictly worse than ((class . "alert")) or any other variation that actually leverages s-expressions instead of merging key and value into the same symbol. Ew. Not a fan of the bare words instead of strings either, which means this cannot be naively evaluated by a Lisp. I…

Like this amirite https://github.com/weavejester/hiccup

The thi.ng umbrella has a hiccup variant for JS that looks pretty neat too: https://thi.ng/hiccup

Re: Produce HTML from S-Expressions

#19
Nice, thanks for sharing. Curious what your motivation was for making it. Perhaps include a "why" at the start of the repo. As evidenced by some comments, depending on whether the goal was to write HTML with a lisp compatible syntax, vs, a more concise but simple xml alternative, it creates different expectations. Personally I'm just interested from a parser/ compiler perspective.
Post reply on HN