4 ms·
Many thanks for your thoughts. > Lisp's hierarchical list notation is by far the most natural, intuitive way to represent HTML. HTML-representation is also im
by an_ko 11y ago
Many thanks for your thoughts.
> Lisp's hierarchical list notation is by far the most natural, intuitive way to represent HTML.
HTML-representation is also important to me, and it's how I got started on eslisp actually. I wrote an XML templater https://github.com/anko/whatxml https://github.com/anko/whatxml for LiveScript that abused the ".." cascaded-function-call feature to create XML hierarchies. It took me a while to realise it was basically an S-expression in disguise!
I'm working on an "eslisp-html"-macro that compiles to an HTML-templating function. Here's the gist of it so far https://gist.github.com/anko/f8ecc66a99a8ec656b49 https://gist.github.com/anko/f8ecc66a99a8ec656b49 No implementation yet, just an early-ideas readme with an example. What do you think?
> For example, one could use "define" instead of "=" to declare bindings, or "begin" instead of "block".
If you want to use different names for the built-in macros, you are welcome to. Aliasing them is just a matter of "(macro define =)", then "define" does the same as "=".
> The "this" syntax in macros is reminiscent of the arguments to ER syntax transformers which can be used to operate on elements in macros. Is it possible to simplify it further? Something like (this/evaluate) instead of (. this evaluate)?
Property access can be sugared to "this.evaluate" with the eslisp-propertify macro https://github.com/anko/eslisp-propertify https://github.com/anko/eslisp-propertify It's quite convenient if you use it as a transform macro https://github.com/anko/eslisp/blob/master/doc/how-macros-work.markdown#transform-macros https://github.com/anko/eslisp/blob/master/doc/how-macros-wo... from the command line, like this https://github.com/anko/eslisp-fancy-function/blob/master/makefile#L6 https://github.com/anko/eslisp-fancy-function/blob/master/ma... Is that what you mean?
- jrapdx3 11y ago> ...an "eslisp-html"-macro that compiles to an HTML-templating function... Here's the gist of it so far ... What do you think? Interesting! Similar to Scheme templates: (let* ((admintype (...)) ... (htm (htdoc `(html (head (meta (@ title "My site"))) (body (div (@ class "banner") (img (@ class "logo" src "logo.gif" title ,(get-curr-url))) ... Basically it just sets up variables for use in the let* scope, and calling the htdoc procedure that parses the quasiquoted list, returning the prepared html as a string (written to the client-connected socket). The htdoc proc is surprisingly simple, and I've implemented it in other Lispy languages without much trouble. I'd be real interested to try it in Eslisp once I'm familiar enough with it. > Property access can be sugared to "this.evaluate" with the eslisp-propertify macro ... Is that what you mean? Possibly. I need to learn it more thoroughly. Of course I realize the "(. id1 id2 ...)" form expands to object notation. My comment just reflected that to me the leading dot expression looks "noisy", a bit distracting. In Scheme, identifiers can contain punctuation like ".", so "this.evaluate" could name a procedure, macro, etc. To my eyes, "(this.evaluate)" is visually easier to parse. In my head, the string "this.evaluate" looks like an atom that expands to the operator this.evaluate(), which I think is what it means. I'm sure I'll get used to the notation as it is, this is just my immediate impression. However, mildly "sugaring" the representation might make it more accessible, especially to people not already enlightened by and in awe of the magic of s-expr. Edit: getting the code section to look like code...