Used in a Sentence

defmacro

How to use defmacro in a sentence. Live example sentences for defmacro pulled from indexed public discussions.

Editorial note

The last obstacle is learning about defmacro and quasiquote/unquote, but that's easy once you're comfortable with lists and iteration.

Examples15
Definitions0
Parts of speech1

Quick take

The last obstacle is learning about defmacro and quasiquote/unquote, but that's easy once you're comfortable with lists and iteration.

Example sentences

1

The last obstacle is learning about defmacro and quasiquote/unquote, but that's easy once you're comfortable with lists and iteration.

2

Check out this recursive implementation of shift, which is like Common Lisp's shiftf: (defmacro shift (:env env.

3

The simplest mechanism is just to pass the macro on to another macro: (defmacro if-match [pat expr then else] (if (list?

4

TXR Lisp: @(do (macro-time (defun abc-proc (n) ^(defun,n () (pprinl ',n)))) (defmacro abc-procs (.

5

However, most schemes have a library that adds your traditional defmacro style macros, CL users are likely to want, but there use is almost always discouraged.

6

This is also why you don't simply use something like `defmacro` that will not let you supply syntactic information (syntax objects) with location and context information.

7

But I can also define: (defmacro foo [x]:foo) which always returns a keyword.

8

That's definitely true in terms of defmacro and syntax-case.

9

YC + all of YC's internal applications, there are 738 calls to def (= CL defun) and 187 calls to mac (= CL defmacro).

10

Years ago at a standards meeting (well, having drinks, not during the meeting itself) he and I were talking about C++ and Lisp and I said how much I missed defmacro.

11

Trivial test: macro-error-test.tl: 1: (defmacro mac (expr) 2: expr) 3: (mac (/ 1 0)) $ txr macro-error-test.tl txr: unhandled exception of type numeric-error: txr: possibly triggered at macro-error-test.tl:3 by form (/ 1 0) txr: message: /: division by zero If we change the example to this: 1: (defmacro mac (expr) 2: (copy expr)) 3: (mac (/ 1 0)) the error is exactly the same.

Quote examples

1

For example, this 3-liner would get you the "multiple array unpacking" in clojure: (defmacro pep448 [f & args] (let [unpack?

2

This is how Clojure actually implements "or": (defmacro or "Evaluates exprs one at a time, from left to right.

3

The definition syntax looks just like a method definition, except it's "defmacro" instead of "def", and the macro body receives an AST instead of (or in addition to) your usual arguments.

4

This actually isn't an issue most of the time; since functions' APIs vary so much already (arity, return values, types, etc.) (defmacro unless (condition branch) `(if,condition nil,branch));; Works (unless keep (delete-file "foo.txt")) - Do everything with syntax rewriting!

Frequently asked questions

Short answers drawn from the clearest meanings and examples for this word.

How do you use defmacro in a sentence?

The last obstacle is learning about defmacro and quasiquote/unquote, but that's easy once you're comfortable with lists and iteration.