# \#macros

**URL:** https://clojureverse.org/tag/macros/18.md

[Latest](https://clojureverse.org/latest.md) · [Categories](https://clojureverse.org/categories.md) · [Tags](https://clojureverse.org/tags.md)

---

## [Functions instead of macros](https://clojureverse.org/t/functions-instead-of-macros/10590)

<div class="topic-metadata">

**Author:** [@habruening](https://clojureverse.org/u/habruening)\
**Replies:** 5\
**Last updated:** [March 6, 2024, 7:46pm UTC](https://clojureverse.org/t/functions-instead-of-macros/10590 "2024-03-06T19:46:58Z")

</div>

I recently had to use a function for a macro transformation. That worked, and now I wonder, why not everybody writes macros like this. See this example. (defn revf \[expr\] (if (list? expr) (cons (last expr) …

---

## [Map and Nth functions](https://clojureverse.org/t/map-and-nth-functions/8553)

<div class="topic-metadata">

**Author:** [@yap0001](https://clojureverse.org/u/yap0001)\
**Replies:** 8\
**Last updated:** [January 25, 2022, 6:29pm UTC](https://clojureverse.org/t/map-and-nth-functions/8553 "2022-01-25T18:29:56Z")

</div>

Working on a homework assignment for a CS program I’m in and running into some issues (see below) (Useful: map, nth) Write a function, (column table n), where n \< (count (first table)) is a number and table is a non-em…

---

## [Doxa - simple in-memory database](https://clojureverse.org/t/doxa-simple-in-memory-database/8222)

<div class="topic-metadata">

**Author:** [@ribelo](https://clojureverse.org/u/ribelo)\
**Replies:** 0\
**Last updated:** [September 30, 2021, 8:17pm UTC](https://clojureverse.org/t/doxa-simple-in-memory-database/8222 "2021-09-30T20:17:46Z")

</div>

I can finally say that after a lot of fun moments and hacking after hours I have managed to get doxa to a point where I can say it is almost complete and not ashamed to show it to the world. In general, everything else I…

---

## [X\> & x\>\>: auto-transducifying thread macros (now with parallelizing |\>\> and =\>\>)](https://clojureverse.org/t/x-x-auto-transducifying-thread-macros-now-with-parallelizing-and/8122)

<div class="topic-metadata">

**Author:** [@John\_Newman](https://clojureverse.org/u/John_Newman)\
**Replies:** 50\
**Last updated:** [September 24, 2021, 12:14am UTC](https://clojureverse.org/t/x-x-auto-transducifying-thread-macros-now-with-parallelizing-and/8122 "2021-09-24T00:14:29Z")

</div>

Hey folks, I just whipped up a little auto-transducifying thread macro last night. It basically searches for contiguous groups of transducers and comps them together into a function that sequences the values flowing in t…

---

## [Down the rabbit hole with Clojure, defrecord, and macros](https://clojureverse.org/t/down-the-rabbit-hole-with-clojure-defrecord-and-macros/8060)

<div class="topic-metadata">

**Author:** [@hlship](https://clojureverse.org/u/hlship)\
**Replies:** 3\
**Last updated:** [August 23, 2021, 8:53pm UTC](https://clojureverse.org/t/down-the-rabbit-hole-with-clojure-defrecord-and-macros/8060 "2021-08-23T20:53:19Z")

</div>

I’ve been trying to get back in the habit of blogging about my Clojure development experience more; here’s a little article about performance optimization at scale I put together.

---

## [The C# macro system - anyone using both Clojure & C#?](https://clojureverse.org/t/the-c-macro-system-anyone-using-both-clojure-c/7815)

<div class="topic-metadata">

**Author:** [@DPiepgrass](https://clojureverse.org/u/DPiepgrass)\
**Replies:** 11\
**Last updated:** [July 3, 2021, 6:20am UTC](https://clojureverse.org/t/the-c-macro-system-anyone-using-both-clojure-c/7815 "2021-07-03T06:20:30Z")

</div>

A few years ago I developed a modified syntax for C# called Enhanced C#, along with a Lisp-style macro system. It’s a long story, but basically I reformulated the C# language in a way that makes it more friendly to macro…

---

## [Filtering out the data using filter](https://clojureverse.org/t/filtering-out-the-data-using-filter/7719)

<div class="topic-metadata">

**Author:** [@abhik](https://clojureverse.org/u/abhik)\
**Replies:** 11\
**Last updated:** [June 2, 2021, 11:20am UTC](https://clojureverse.org/t/filtering-out-the-data-using-filter/7719 "2021-06-02T11:20:46Z")

</div>

{:settings {:columns \[{:key "seqNo", :active true} {:key "title", :active true} {:key "status", :active true} {:key "dueDate", :active true} {:key "priority", :active true} {:key "parent", :active true} {:key "childCount…

---

## [One more macro?](https://clojureverse.org/t/one-more-macro/7318)

<div class="topic-metadata">

**Author:** [@pbaille](https://clojureverse.org/u/pbaille)\
**Replies:** 4\
**Last updated:** [March 11, 2021, 11:49am UTC](https://clojureverse.org/t/one-more-macro/7318 "2021-03-11T11:49:31Z")

</div>

Hello clojurians, I’ve just published a tiny library containing one macro. It aims to cover/extend the scope of macros like if, let, when, if-let, cond etc… For those who want some context and details, there is an ext…

---

## [Power-dot: enhanced Java interop that allows you to treat Clojure functions as Java lambdas](https://clojureverse.org/t/power-dot-enhanced-java-interop-that-allows-you-to-treat-clojure-functions-as-java-lambdas/7105)

<div class="topic-metadata">

**Author:** [@athos](https://clojureverse.org/u/athos)\
**Replies:** 0\
**Last updated:** [February 1, 2021, 1:51pm UTC](https://clojureverse.org/t/power-dot-enhanced-java-interop-that-allows-you-to-treat-clojure-functions-as-java-lambdas/7105 "2021-02-01T13:51:44Z")

</div>

I’ve just released a new Clojure library named power-dot. It provides an enhanced Java interop feature that allows you to treat Clojure functions as Java lambdas. Using power-dot, you can write code like: (require '\[p…

---

## [Need help with writing macros for ClojureScript](https://clojureverse.org/t/need-help-with-writing-macros-for-clojurescript/6671)

<div class="topic-metadata">

**Author:** [@u473t8](https://clojureverse.org/u/u473t8)\
**Replies:** 6\
**Last updated:** [October 12, 2020, 1:04pm UTC](https://clojureverse.org/t/need-help-with-writing-macros-for-clojurescript/6671 "2020-10-12T13:04:29Z")

</div>

For instance I have a macros in my-macros CLJ namespace (just a let macros copied from the clojure core) : (ns my-macros) (defmacro alt-let \[bindings & body\] (assert-args (vector? bindings) "a vector for its bin…

---

## [Using macroexpand inside a macro in Clojurescript doesn't work](https://clojureverse.org/t/using-macroexpand-inside-a-macro-in-clojurescript-doesnt-work/6516)

<div class="topic-metadata">

**Author:** [@jpmonettas](https://clojureverse.org/u/jpmonettas)\
**Replies:** 2\
**Last updated:** [September 9, 2020, 11:33am UTC](https://clojureverse.org/t/using-macroexpand-inside-a-macro-in-clojurescript-doesnt-work/6516 "2020-09-09T11:33:56Z")

</div>

Hi everybody!,Does anybody knows why this macro (defmacro tester \[form\] (println (macroexpand form)) nil) When used from clojure : (tester (let \[a 5\] a)) ;; prints (let\* \[a 5\] a) But when used from clojurescript : (…

---

## ['when-let'-like macro that takes custom predicate instead of truth-checking the result?](https://clojureverse.org/t/when-let-like-macro-that-takes-custom-predicate-instead-of-truth-checking-the-result/6126)

<div class="topic-metadata">

**Author:** [@klapanciusz](https://clojureverse.org/u/klapanciusz)\
**Replies:** 1\
**Last updated:** [June 18, 2020, 5:52pm UTC](https://clojureverse.org/t/when-let-like-macro-that-takes-custom-predicate-instead-of-truth-checking-the-result/6126 "2020-06-18T17:52:22Z")

</div>

Intended usage & expansion: ... (cond-let pos? \[delta (- x y)\] (swap! z + delta) -\> (let \[delta (- x y)\]) (when (pos? delta) (swap! z + delta)) (cond-let (complement nil?) ...) is functionally equivalent to (…

---

## [Explain thread first macro like i am 5?](https://clojureverse.org/t/explain-thread-first-macro-like-i-am-5/5888)

<div class="topic-metadata">

**Author:** [@babygau](https://clojureverse.org/u/babygau)\
**Replies:** 5\
**Last updated:** [May 1, 2020, 11:44am UTC](https://clojureverse.org/t/explain-thread-first-macro-like-i-am-5/5888 "2020-05-01T11:44:52Z")

</div>

hi guys, as i’m trying to understand how macro works through thread first -\> source. could you pls explain what this line does (with-meta '(~(first form) ~x ~@(next form)) (meta form)) im also curious about the use of w…

---

## [What are example use-cases for macros in front-end?](https://clojureverse.org/t/what-are-example-use-cases-for-macros-in-front-end/5343)

<div class="topic-metadata">

**Author:** [@alidlo](https://clojureverse.org/u/alidlo)\
**Replies:** 1\
**Last updated:** [January 10, 2020, 10:42am UTC](https://clojureverse.org/t/what-are-example-use-cases-for-macros-in-front-end/5343 "2020-01-10T10:42:50Z")

</div>

Aside from creating react wrappers :slight\_smile:

---

## [Evaluating functions inside macro's body](https://clojureverse.org/t/evaluating-functions-inside-macros-body/5158)

<div class="topic-metadata">

**Author:** [@juniorgarcia](https://clojureverse.org/u/juniorgarcia)\
**Replies:** 6\
**Last updated:** [December 1, 2019, 11:17pm UTC](https://clojureverse.org/t/evaluating-functions-inside-macros-body/5158 "2019-12-01T23:17:44Z")

</div>

Hello guys. I’m learning web apps with Clojure from scratch and I wanted to make a macro that would hold a common template using Hiccup for my pages, like this: (defmacro defpage \[elements\] (html (include-css "ht…

---

## [A macro between quote and syntax-quote](https://clojureverse.org/t/a-macro-between-quote-and-syntax-quote/4466)

<div class="topic-metadata">

**Author:** [@Miikka](https://clojureverse.org/u/Miikka)\
**Replies:** 15\
**Last updated:** [September 5, 2019, 5:35pm UTC](https://clojureverse.org/t/a-macro-between-quote-and-syntax-quote/4466 "2019-09-05T17:35:30Z")

</div>

I often find myself wishing for a reader macro that is between quote ' and syntax-quote \`: I want to use unquote ~ and unquote-splicing ~@ but I do not want to get fully-qualified symbols. Let’s have an example. ;; Wha…

---

## [How to define and use a macro in both CLJ and CLJS?](https://clojureverse.org/t/how-to-define-and-use-a-macro-in-both-clj-and-cljs/2896)

<div class="topic-metadata">

**Author:** [@DjebbZ](https://clojureverse.org/u/DjebbZ)\
**Replies:** 6\
**Last updated:** [July 10, 2019, 9:39pm UTC](https://clojureverse.org/t/how-to-define-and-use-a-macro-in-both-clj-and-cljs/2896 "2019-07-10T21:39:21Z")

</div>

Hello, After many (many many) trials and errors, I’ve finally managed to define a macro that I can use in a CLJC file, for both a CLJ/JVM project and a CLJS/Browser project. This post started as a question that I rewrot…

---

## [Issue creating macro that emits a let with associative destructuring for the binding form](https://clojureverse.org/t/issue-creating-macro-that-emits-a-let-with-associative-destructuring-for-the-binding-form/4483)

<div class="topic-metadata">

**Author:** [@indigo0086](https://clojureverse.org/u/indigo0086)\
**Replies:** 4\
**Last updated:** [July 1, 2019, 4:55pm UTC](https://clojureverse.org/t/issue-creating-macro-that-emits-a-let-with-associative-destructuring-for-the-binding-form/4483 "2019-07-01T16:55:04Z")

</div>

Every now and then I try to build my macro muscle and every now and then need a spotter :). In my case i’m looking to build a macro that when given a seq of args (say via a -main function) create a let form that uses th…

---

## [How to import macros from other libraries into yours in ClojureScript?](https://clojureverse.org/t/how-to-import-macros-from-other-libraries-into-yours-in-clojurescript/4366)

<div class="topic-metadata">

**Author:** [@shomiyamoto](https://clojureverse.org/u/shomiyamoto)\
**Replies:** 11\
**Last updated:** [June 12, 2019, 11:55am UTC](https://clojureverse.org/t/how-to-import-macros-from-other-libraries-into-yours-in-clojurescript/4366 "2019-06-12T11:55:36Z")

</div>

I have a library (say mylib) that I always use with core.match/match and have been writing like as follows: (ns new.work.space (:require \[clojure.core.match :refer-macros \[match\]\] \[mylib.core :as mylib\])) …

---

## [Help me with a clojurescript macro](https://clojureverse.org/t/help-me-with-a-clojurescript-macro/4249)

<div class="topic-metadata">

**Author:** [@ilemming](https://clojureverse.org/u/ilemming)\
**Replies:** 1\
**Last updated:** [May 11, 2019, 7:09am UTC](https://clojureverse.org/t/help-me-with-a-clojurescript-macro/4249 "2019-05-11T07:09:07Z")

</div>

We have some boiler-plate Cljs code that does something like this: (defn mui-\>reagent \[mui-name\] (r/adapt-react-class (gobj/get js/MaterialUI mui-name))) (def app-bar (mui-\>reagent "Button")) (def card (mui-\>reagent …

---

## [Why can't I write macros in Clojurescript?](https://clojureverse.org/t/why-cant-i-write-macros-in-clojurescript/4117)

<div class="topic-metadata">

**Author:** [@Webdev\_Tory](https://clojureverse.org/u/Webdev_Tory)\
**Replies:** 20\
**Last updated:** [April 17, 2019, 1:55am UTC](https://clojureverse.org/t/why-cant-i-write-macros-in-clojurescript/4117 "2019-04-17T01:55:06Z")

</div>

In 2019, after hearing Clojurescript touted without much complaint, I have been told that I can’t write macros in Clojurescript (which, as far as I can tell, seems to be true). Why can’t I, and why is this still the case…

---

## [How to avoid defmulti being defonce with the REPL session?](https://clojureverse.org/t/how-to-avoid-defmulti-being-defonce-with-the-repl-session/4000)

<div class="topic-metadata">

**Author:** [@Webdev\_Tory](https://clojureverse.org/u/Webdev_Tory)\
**Replies:** 7\
**Last updated:** [March 19, 2019, 2:46pm UTC](https://clojureverse.org/t/how-to-avoid-defmulti-being-defonce-with-the-repl-session/4000 "2019-03-19T14:46:36Z")

</div>

(note: using Cider) I use defmulti and defmethod in my code, eval-buffer, and test them. They have an error, so I rewrite them (change them to receive a map instead of sequential args). However, eval-buffer won’t update…

---

## [Thread-at macro](https://clojureverse.org/t/thread-at-macro/3340)

<div class="topic-metadata">

**Author:** [@Rawieo](https://clojureverse.org/u/Rawieo)\
**Replies:** 16\
**Last updated:** [January 9, 2019, 11:54pm UTC](https://clojureverse.org/t/thread-at-macro/3340 "2019-01-09T23:54:06Z")

</div>

Composing forms using -\> and -\>\> suddenly stops being fun when you encounter mismatch in “data-parameter” (?) position. So what do you think of thread-at macro? looks like this: (defmacro .\> \[x & forms\] (loop \[x x,…

---

## [A test-fixture macro](https://clojureverse.org/t/a-test-fixture-macro/2992)

<div class="topic-metadata">

**Author:** [@Webdev\_Tory](https://clojureverse.org/u/Webdev_Tory)\
**Replies:** 5\
**Last updated:** [October 10, 2018, 4:39pm UTC](https://clojureverse.org/t/a-test-fixture-macro/2992 "2018-10-10T16:39:16Z")

</div>

I’m trying to build a macro that helps with my test fixtures. In particular, it wraps tests in database transactions. Now, doing that raw works: (defmacro basic-transaction-fixtures \[& forms\] \`(clojure.test/use-fixt…
