Contents
What does progn mean in Lisp?
Description: progn evaluates forms, in the order in which they are given. The values of each form but the last are discarded. If progn appears as a top level form, then all forms within that progn are considered by the compiler to be top level forms.
When to use progn Lisp?
progn is typically used when dealing with macros. Some macros ( use-package is a macro, last I checked) accept only 1 form, where others consume all remaining forms. progn is used in the former case to turn a sequence of forms into a single form.
How do you define Lisp?
In Lisp, a symbol such as mark-whole-buffer has code attached to it that tells the computer what to do when the function is called. This code is called the function definition and is created by evaluating a Lisp expression that starts with the symbol defun (which is an abbreviation for define function).
What is the function of LISP?
LISP also allows optional, multiple, and keyword arguments. The documentation string describes the purpose of the function. It is associated with the name of the function and can be obtained using the documentation function. The body of the function may consist of any number of Lisp expressions.
What does the N stand for in progn?
The n or 1 or 2 part of the name stands for the statement from the list whose result you are interested in. In other words, progn will return the result of the last statement it contains, whereas prog1 will return the first, and similar for prog2.
When to use progn and when to omit progn?
It is worth noting that using progn works in both cases, while omitting it only works if the macro accepts multiple forms. As a result of this, some people prefer to simply always use progn, because it will always work. The most important reason for progn is described in the first line of the progn documentation (emphasis added):
Which is the best definition of the word curiosity?
the desire to learn or know about anything; inquisitiveness. a curious, rare, or novel thing. a strange, curious, or interesting quality.
Why is progn important in a C like language?
In C-like languages this feature is sometimes known as sequence point (i.e. ; and , for example). progn is as essential to Lisp-like languages as ; is to C-like languages. It is a fundamental feature of the language one cannot easily replace.