Fork me on GitHub
#clojure-austin
<
2024-02-15
>
camdez04:02:19

Well, this definitely falls into the “thanks, I hate it” category for me but, uhhh, enjoy…

(defmacro infix-children [form]
  (for [f form]
    (if (list? f)
      `(infix ~f)
      f)))

(defmacro infix [form]
  (if (list? form)
    `(infix-children
      ~(if (= (count form) 3)
         `(~(second form)
           ~(first form)
           ~@(drop 2 form))
         form))
    ~form))

(infix (1 + ((5 - 2) + ((- 10) + 10))))
(infix ((1 / 2) + 2))
(infix (println (1 + (5 - 2))))

camdez05:02:39

Ah, I forgot I changed it to only affect lists with exactly 3 elements… obviously the drop 2 business could just be (nth form 2) now. It gets weird fast. Like, if there’s a hash map, should we walk the whole thing to find things to infix? I think I’ll just stick with my prefix notation. 😉

camdez16:02:45

Fun meetup last night! I enjoyed the show-and-tell format and always love seeing other people’s tools! I’m glad we all gave our hearts to Clojure and could make it out for a special V-Day meetup, haha. Here are some resources for stuff I mentioned last night: • clojure.core/iteration (since 1.11) https://clojuredocs.org/clojure.core/iterationclojure.core/requiring-resolve (since 1.10) https://clojuredocs.org/clojure.core/requiring-resolve • Mark joked about a generalized version of (Common Lisp’s) prog1 (which I called returning in Clojure) ◦ I did this once, just for kicks: https://camdez.com/blog/2011/01/09/ruby-implementing-progn-from-lisp/#and-beyond • Reitit (esp. middleware compilation: https://cljdoc.org/d/metosin/reitit/0.7.0-alpha7/doc/ring/compiling-middleware) • Portal https://github.com/djblue/portal • better-cond https://github.com/Engelberg/better-cond • Binding conveyance https://clojure.org/reference/vars#conveyance • Hiccup compilation https://tonsky.me/blog/hiccup/#how-hiccup-works • ClojureScript macros (written in Clojure!) https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.htmlmap-of macro https://github.com/metosin/potpuri/blob/d5294910d33147279b94152f1b4a5df907d75c6f/src/potpuri/core.cljc#L72-L77 • We collectively touched on... ◦ Rama https://blog.redplanetlabs.com/2023/10/11/introducing-ramas-clojure-api/ ◦ Apache Samza https://samza.apache.org/ ◦ Also possibly interesting ▪︎ Apache Flink https://flink.apache.org/ ▪︎ Materialize https://github.com/MaterializeInc/materialize • Instaparse https://github.com/Engelberg/instaparse

clojure 1
mlimotte16:02:59

Very romantic. But I agree-- this format was a good way to fill a Meetup when we didn’t have a pre-arranged topic/speaker.

camdez16:02:22

We could also do a collective try out some new tool meetup. Live coding isn’t so bad among friends.

🤍 1
dpsutton16:02:03

i’m so bummed to have missed this. very much like this style

mlimotte16:02:37

Best. Clojure. Event. Ever. And, no, there is no video. You should have been there.

dpsutton16:02:06

had to be there are the best meetups

dpsutton17:02:50

our prog1 with an anaphor of <> from metabase.util

camdez17:02:50

Ah, that is nice. Mine is simple:

(defmacro returning
  "Evaluate `body`, presumably for side effects, and return `v`.  Like
  Common Lisp's `prog1`."
  {:style/indent 1}
  [v & body]
  `(let [v# ~v]
     ~@body
     v#))
Nice to be able to not name the value through the magic of anaphor.

camdez17:02:38

I really wish we had a quasi-quote that didn’t resolve all symbols. Odd to me that there isn’t one.

dpsutton17:02:58

remember desperately wanting that when we worked with datomic at a past job

dpsutton17:02:12

i think there’s a brandombloom library to help with that?

camdez17:02:57

That’s where I want it right now. 🙂 Yes, I think I’ve seen that. Didn’t really want to pull in something just for this.

dpsutton17:02:50

i think that’s what we did as well. Each instance we thought “no need for a library for just a single query” but we said it 35 times … so not sure it is valid in the aggregate

😂 1
mlimotte18:02:50

Not being able to easily mix in evaluatable symbols in my quoted Datomic queries is definitely a hassle. The :in syntax is sometimes funky and feel verbose. I always wished I could do something like this: '[:find ?foo :where [?foo :my/attr ~x]] But you can only inline with the syntax-quote (“`”), which would break the rest of datomic query.

camdez02:02:09

Yeah, I think they’re weird about it becomes they cache on the query (including the :in list), so they want it to be parametrizable and still cached but I totally agree that it feels verbose and funky. The positional name of the input collection gets annoying sometimes too.