3 ms·
> :class="alert" is strictly worse than ((class . "alert")) or any other variation that actually leverages s-expressions instead of merging key and value into t
by lelanthran 3y ago
> :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 evaluated by a Lisp.
I traded off ergonomics against "Evaluation by a Lisp processor".Instead of
(div "My first " (b "hello") (em " world"))
I'd rather do
(div My first (b hello) (em world))
Thank you for your input.
- kazinator 3y agoIf My and first just stand for themselves, you're not interpolating variables; where is the templating? Also, what if you don't want a space between the bold hello and emphasized world? Or between first and <b>hello</b>?
- lelanthran 3y ago> If My and first just stand for themselves, you're not interpolating variables; where is the templating? Templating wasn't mentioned (yet. looking at the feedback I got, some avenues are open for some sort of templating). > Also, what if you don't want a space between the bold hello and emphasized world? Then you don't put one in? $ echo "(div My first (b hello)(em world)) " | ./l2h -s <div>My first <b>hello</b><em>world</em></div> > Or between first and <b>hello</b>? Again, don't put one in: echo "(div My first(b hello) (em world))" | ./l2h -s <div>My first<b>hello</b> <em>world</em></div> I think that that is is intuitive as it can get for people who know HTML: space-emission matches what you would expect for HTML. If you look at the git history, I spent a lot of time making sure that the parsing of whitespace and newlines made sense from an HTML perspective, not from a Lisp perspective.
- kazinator 3y agoThat's not S-exprs then because there is no symbolic difference between )( and ) ( or between foo( and foo (. But it's a better representation for HTML, that we would have had if Berners-Lee hadn't been a supreme goofball.
- lelanthran 3y ago> That's not S-exprs then because there is no symbolic difference between )( and ) ( or between foo( and foo (. You (and everyone else) who points this out is quite correct. I could have chosen a proper name, but when I started project (and created the name for it) I did not realise that I would have to make whitespace and newlines significant in order for it to make sense from an HTML perspective. It was only when doing testing and trying to bold the middle two letters of "hello" that I knew I had to make whitespace significant. So .. uh, sorry about the name :-(
- 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.
- fouc 3y agoThis might be okay too? (div (class "alert") So long, and (b thanks) for all the (em fish)) or (div {class "alert"} So long, and (b thanks) for all the (em fish))
- chii 3y agoPersonally, i'd go with (div (class [alert someothercss]) [so long and (b [thanks]) for all the (em [fish and chips])])
- captainbland 3y agoYeah I think you want some way to clearly differentiate between tags and attributes as there are some cases where there are attribute and tags with the same name. E.g. does (body (style "styleinfo")) mean <body style="styleinfo"></body> Or <body><style>styleinfo</style></body>?
- fouc 3y agosecond example using { } could imply the attribute and ( ) could imply the tag
- lelanthran 3y ago> second example using { } could imply the attribute and ( ) could imply the tag Right now the only reserved tokens are '(', ')' and ':'. Everything else is emitted as HTML content. Reserving '{' and '}' for use by the program means that users would have to escape '{' and '}' wherever it occurs in their content.