Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

First Lisp with macros?

McCarthy's original Lisp and some number of incarnations thereafter did not have a macro facility like we now have in Common Lisp, Clojure, Scheme, etc... This I know.

However, it is unclear to me exactly how macros came to be, what implementation(s) had them first, and what motivated them. References to papers and source would be ideal if you please.

like image 959
fogus Avatar asked Nov 09 '10 20:11

fogus


People also ask

What is so special about Lisp macros?

The special power that Lisp macros have is that they can control evaluation (as seen by evaluating the input expression via ~expr and do arbitrary source-to-source transformations with the full power of the language available.

What is a macro Lisp?

The Common Lisp macro facility allows the user to define arbitrary functions that convert certain Lisp forms into different forms before evaluating or compiling them. This is done at the expression level, not at the character-string level as in most other languages.

Are rust macros like Lisp macros?

Rust's macros are very good. They act like Lisp's macros, unlike Haskell's. The fact that Rust has type-classes (“traits”) and sum types (“enums”) and pattern matching is very attractive.

Is a macro not a function Lisp?

Macros do code transformations at compile time or runtime. That's different from functions. Just look into the Common Lisp standard for many different pre-defined macros and their different syntax. Now think about, why these are macros and not functions.


1 Answers

From The Evolution of Lisp (PDF):

Macros appear to have been introduced into Lisp by Timothy P. Hart in 1963 in a short MIT AI Memo [Hart, 1963]

See:

AIM-57 Author[s]: Timothy P. Hart

MACRO Definitions for LISP

October 1963

ftp://publications.ai.mit.edu/ai-publications/0-499/AIM-057.ps

ftp://publications.ai.mit.edu/ai-publications/pdf/AIM-057.pdf

In LISP 1.5 special forms are used for three logically separate purposes: a) to reach the alist, b) to allow functions to have an indefinite number of arguments, and c) to keep arguments from being evaluated. New LISP interpreters can easily satisfy need (a) by making the alist a SPECIAL-type or APVAL-type entity. Uses (b) and (c) can be replaced by incorporating a MACRO instruction expander in define. I am proposing such an expander.

like image 60
Rainer Joswig Avatar answered Oct 24 '22 08:10

Rainer Joswig