jack icon indicating copy to clipboard operation
jack copied to clipboard

Not an issue, just a question

Open cdmojoli opened this issue 2 years ago • 2 comments

Why not use symbols instead of keywords, to reduce syntax? Hiccup and others also go with keywords. Is it performance or memory footprint?

E.g. (jack-html `(div/id1.c1 (h1 (p ,text))))

cdmojoli avatar Jan 03 '23 18:01 cdmojoli

In jack we could have use symbols instead of keywords.

There would be almost no difference in the implementation:

  • Two small changes in jack-parse-tag-kw in order not to check for keywords and a match that doesn't take into account the : starting a keyword (seen as a string),
  • use symbolp instead of keywordp in jack-html.

I chose keywords over symbols because I find it more readable since keywords are highlighted and not symbols. This gives you something similar as in html-mode where tags are highlighted. So this has nothing to do with performance neither memory footprint.

If we talk about Hiccup (Clojure), you do not have to use keywords. Symbols and strings are also accepted:

user=> (use 'hiccup.core)
nil
user=> (html ['div#id1.c1 ['h1 ['p "text"]]])
"<div class=\"c1\" id=\"id1\"><h1><p>text</p></h1></div>"
user=> (html [:div#id1.c1 [:h1 [:p "text"]]])
"<div class=\"c1\" id=\"id1\"><h1><p>text</p></h1></div>"
user=> (html ["div#id1.c1" ["h1" ["p" "text"]]])
"<div class=\"c1\" id=\"id1\"><h1><p>text</p></h1></div>"

I hope this answer your question.

tonyaldon avatar Jan 05 '23 12:01 tonyaldon

Thanks for providing the insight, I did not expect the highliting aspect (which makes a lot of sense). Neither did I know one could use symbols in Hiccup.

I have been uncommittedly fantasizing about an "any-lisp anytime" HTML generation strategy that works in elisp, Clojure, CL and Scheme. One could get immediate results within Emacs, and deploy to other lispy languages (bootstrapping and surrounding app logic would be lispy-variant-specific); at development time or runtime, server side or client side (e.g. ClojureScript).

Perhaps that may someday lead to an abstraction where a view is described by its generation template, but the time&place of generation is left as an optimization which decides which bits are SSG, SSR or CSR.

cdmojoli avatar Jan 05 '23 13:01 cdmojoli