Lisps use read/eval, quote/syntax-quote, unquote/unquote-splicing and so on to make writing macros possible.

Does Mathematica has any operators like these?

I know there is a topic on HoldAll, Unevaluated, Hold, HoldFirst, HoldRest, NHoldAll, HoldAllComplete, SequenceHold, Inactivate, Extract.

And Mathematica itself implemented lazy-eval, so that symbolic computation works.

Are there any operators who works as unquote-splicing? And are there any other operators do the same kind of things?

For example:

Racket has unquote-splicing:

(quasiquote (0 (unquote-splicing (list 1 2)) 4))

;; => '(0 1 2 4)

and ~@ is unquote-splicing in Clojure:

`(1 2 ~@(list 3 4))

;; => (1 2 3 4)


  • 3
    $\begingroup$ Are there any operators who works as unquote-splicing? but you have not explained what unquote-splicing is, or given a link to what it is. Since most folks here probably are not lisp programmers, it helps to explain what this unquote-splicing does. $\endgroup$ – Nasser Feb 23 '17 at 6:41
  • 5
    $\begingroup$ You would have a better chance of getting an answer if you were to describe the kind of macro you want in Mathematica terms. You should give an example or two of input and output expressions for such macros. $\endgroup$ – m_goldberg Feb 23 '17 at 6:47
  • 2
    $\begingroup$ So, Sequence? {1, 2, Sequence@@{3, 4}, 5} => {1, 2, 3, 4, 5} $\endgroup$ – user484 Feb 23 '17 at 8:27
  • 4
    $\begingroup$ For anybody who might be interested in this question, the macro characters cmal is asking about are described in 22.1.3 of Steele's Common Lisp: the Language. It is a strictly lexical macro facility which operates only at top-level read time. Do not confuse it with the facility for defining functions with non-stanard evaluation discussed in Chapter 8, Macros. The Chapter 8 tools are, in my opinion, more in correspondence with Mathematica's tools for managing evaluation (Hold, Sequence, Unevaluated, Inactivate, Defer, etc.) than the Chapter 22 macro facility. $\endgroup$ – m_goldberg Feb 23 '17 at 8:35
  • 2
    $\begingroup$ Is this what you are after? 103286 $\endgroup$ – Kuba Feb 23 '17 at 9:03