3 ms·
> 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
by sph 3y ago
> 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 the goal is using s-exps, why not use s-exps for everything?
- lelanthran 3y ago> 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.
- vermilingua 3y agoIf your goal wasn't "use s-expr" and it isn't a lisp interpreter, the tagline probably shouldn't be "Produce HTML from S-Expressions" and the project shouldn't be named "lisp-to-html"; it should be "Write HTML with parentheses".
- lelanthran 3y ago> If your goal wasn't "use s-expr" and it isn't a lisp interpreter, the tagline probably shouldn't be "Produce HTML from S-Expressions" and the project shouldn't be named "lisp-to-html"; it should be "Write HTML with parentheses". You're right maybe it shouldn't be called "Lisp-ish". But, the sources really are s-expressions with an additional ':' marker for attributes, just not Lisp s-expressions with the ':' marker. So "Write HTML with parenthesis" would be less accurate than "Emit HTML from S-expressions".
- zarzavat 3y agoWho is your target audience? If it’s Lispers then you need to make the format macro-friendly, if it’s not Lispers then you need to figure out who else likes sexprs but not Lisp? You could replace the = sign with a space, then you can have (a :href “/news”). Perhaps ::required for an empty attribute. This makes it better for macros.
- lelanthran 3y ago> Who is your target audience? It's not Lispers. > If it’s Lispers then you need to make the format macro-friendly, if it’s not Lispers then you need to figure out who else likes sexprs but not Lisp? Well, it depends. I like Lisp just fine, but all the Lisp ways of producing HTML are extremely unergonomic for those not already in the Lisp ecosystem. Someone below posted a link to the clwiki page (I think, not sure) for a list of HTML-generation libraries. I've used some of these before, and they require the user to actually know Lisp well enough to program in Lisp. I wanted something I can hand off to a junior who doesn't know any Lisp (and doesn't really want to), while still having something that makes it easier to type out HTML. The `l2h` program is a compromise of sorts between ergonomics and flexibility. It's more effort to use actual Lisp, but you get more in return when you do. It's less effort to use `l2h`, but there are more limits when you do. > You could replace the = sign with a space, then you can have (a :href “/news”). Perhaps ::required for an empty attribute. This makes it better for macros. I made a note of this. You're correct about it being better for Lispy macros. Another responder elsethread pointed out a few things that could benefit the usage (imports, macros) while maybe not adding too much "cognitive overload" (AKA Too Much Lisp). This project has only had about 6hrs thrown at it so far, so it is still early days. I do appreciate your feedback. Thank you.
- kazinator 3y ago> Lisp ways of producing HTML are extremely unergonomic for those not already in the Lisp ecosystem. Sure; pedaling a road bike is very unergonomic for someone who is jogging next to it. Makes sense.