26

According to Emacs documentation:

progn is a special form in `C source code'.

(progn BODY...)

Eval BODY forms sequentially and return value of last one.
  1. What does progn stands for (or its origin)?
  2. Useage: Is it equivalent to Clojure's -> macro?

1 Answer 1

35
  1. progn is a special form borrowed from CL-like Lisp dialects. In their implementations it's composed from multiple progs, expressions that are evaluated and a number that specifies which expression value is returned. prog1 for instance evaluates all expressions and returns the value of the first, prog2 evaluates all expressions and returns the value of the second, progn evaluates all expressions and returns the n'th, or rather, the last expression's value.

  2. progn in Emacs Lisp is the equivalent of Clojure's do which is used as means to bundle multiple expressions into a single one. You'll need to use it for Clojure's if conditional for instance.

5
  • 1
    Good answer, I upvoted it. However, for the sake of formality: you don't really need it for conditionals, cond has an implicit progn.
    – mbork
    Commented Dec 28, 2014 at 21:01
  • 2
    Uh, I was speaking of Clojure which does not have implicit progn in its if.
    – wasamasa
    Commented Dec 28, 2014 at 21:04
  • 3
    Emacs also has prog1 and prog2 as built-in special forms.
    – cjm
    Commented Dec 29, 2014 at 6:32
  • 1
    I have seen this used in a lot of users' configurations. Is there a performance boost from "bundling" multiple expressions this way as opposed to evaluating them one after the other outside of progn?
    – elethan
    Commented Dec 3, 2015 at 3:41
  • Not sure what makes you think that. progn is the equivalent of a braced block in a C-like language...
    – wasamasa
    Commented Dec 3, 2015 at 7:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.