Re: Seeking computer-programming job (Sunnyvale, CA)

A

ACL

because it isn't one? How ridiculous. Redefining things and then
acting all shocked and flamey when people call you on it. Really now.

I'm pretty sure lisp macros predate C macros.
Same would be true for the parse tree and source code.
(As lisp is older than c).

But anyway, maybe it would be less confusing if we called them
'compile time source-code manipulating functions'.

'Cotscmafu'.

'Macro' has had an too much of an association with excel spreadsheets
and cheating at MMOs to be really sexy anymore.

Food for thought. (maybe?)
 
T

Tim Bradshaw

I'm pretty sure lisp macros predate C macros.
Same would be true for the parse tree and source code.
(As lisp is older than c).

Yes, they do, by many years.
But anyway, maybe it would be less confusing if we called them
'compile time source-code manipulating functions'.

"macro" is a fine name.
 
T

Thomas F. Burdick

Yes, they do, by many years.

You sure about that? I thought that both C-ish macros and the Lisp
MACRO mechanism came about around 1970 or so. And in any case, the
term is clearly making reference to assembler macro-instructions,
which are much more like C macros than Lisp ones.
"macro" is a fine name.

Indeed. And when I have the need to contrast the two styles of macros,
the adjectives "textual" and "structural" work fine.
 
T

Tim Bradshaw

You sure about that? I thought that both C-ish macros and the Lisp
MACRO mechanism came about around 1970 or so.

The earliest reference I am aware of to Lisp macros is AIM-5, which
describes macros for Lisp 1.5 in 1963. The Lisp 1.5 manual does not
mention macros. So I'm guessing a date some time in 1963, or possibly a
little earlier.
 
S

Series Expansion

because it isn't one? How ridiculous. Redefining things and then
acting all shocked and flamey when people call you on it. Really now.

I'm pretty sure lisp macros predate C macros. [other irrelevancies
deleted]

But anyway, maybe it would be less confusing if we called them
'compile time source-code manipulating functions'.

'Cotscmafu'.

'Macro' has had an too much of an association with excel spreadsheets
and cheating at MMOs to be really sexy anymore.

Cotscmafu it is. I particularly like how it ends with "fu".
 
S

Series Expansion

Indeed. And when I have the need to contrast the two styles of macros,
the adjectives "textual" and "structural" work fine.

Structural, schmuctural. It's apparently a macro in much the way a
3.5" floppy disk is floppy.
 
K

Kaz Kylheku

The Software Preservation Group web page for Lisp history,
http://www.softwarepreservation.org/projects/LISP/ has a link to an
October 22, 1963 paper "MACRO Definition for LISP" by Timothy P. Hart,
ftp://publications.ai.mit.edu/ai-publications/pdf/AIM-057.pdf

I don't know enough about Lisp to evaluate whether what it describes is
the foundation of the current Lisp feature. Perhaps someone with the
necessary knowledge could take a look at it?

It positively, definitely describes the foundations of macros.

At the outset, an example is given for replacing an existing fexpr called
csetq by a macro.

Also, the macro STASH is defined which does almost exactly what PUSH does
today, with the same argument order:

(stash form x) ;; push value of FORM onto variable X.

expands to

(setq x (cons form x))

The modern PUSH can push onto any storage location, not only a named
variable.

The SETQ expansion is achieved by means of

MACRO ((STASH (LAMBDA (FORM)
(LIST (QUOTE SETQ)
(CADAR FORM)
(LIST (CONS (CADR FORM)
(CADAR FORM)))))))

(Indentation mine).

This is in an old-style ``eval quote'' notation in which the outer parentheses
were omitted from the toplevel form. But basically the macro would work
today, with only a minor code update.

Modern Lisp macros no longer just receive the entire macro call form as their
one and only argument, but the underlying plumbing still works that way, and
access to the whole form is still available using the &WHOLE keyword in the
macro lambda list. We don't have to use a lambda expression to define the
function, either.

So reusing the macro code in Common Lisp looks like this:

(DEFMACRO STASH (&WHOLE FORM VALUE PLACE)
(LIST (QUOTE SETQ)
(CADAR FORM)
(LIST (CONS (CADR FORM)
(CADAR FORM)))))

But now I see two bugs here. Firstly, it expects the form to have a weird shape!
Namely this:

((STASH PLACE) VALUE)
^CADAR ^CADR

Rather than

(STASH VALUE PLACE)
^CADR ^CADDR

I.e. unless this was really the representation, the paper possibly has a typo:
CADAR instead of CADDR.

Secondly, the macro is generating code, which means that certain symbols must
be quoted. But note that the CONS function is just called! That's wrong; we
need to /generate/ the code (CONS ...) not to invoke CONS at macro-expansion
time. I.e. we want

(LIST (QUOTE CONS) ...)

not:

(LIST (CONS ...))

Exactly the way the SETQ operator is quoted with (QUOTE SETQ),
the CONS operator must be quoted too.

Clearly, the paper's author didn't cut and paste his own code from
the text editor into the Lisp window of his graphics worksation
to try it out. :) :) :)

Bugfixed version:

(DEFMACRO STASH (&WHOLE FORM VALUE PLACE)
(LIST (QUOTE SETQ)
(CADDR FORM)
(LIST (QUOTE CONS)
(CADR FORM)
(CADDR FORM)))))

And now, actual test run in a Lisp session:

[1]>
(DEFMACRO STASH (&WHOLE FORM VALUE PLACE)
(LIST (QUOTE SETQ)
(CADDR FORM)
(LIST (QUOTE CONS)
(CADR FORM)
(CADDR FORM)))))
STASH
[2]> (macroexpand '(stash value place))
(SETQ PLACE (CONS VALUE PLACE)) ;
T

Our macro also has error checking. Though we don't use the VALUE and PLACE
arguments, the DEFMACRO still knows that the macro must take exactly two:

[3]> (macroexpand '(stash value place 42))

*** - The macro STASH may not be called with 3 arguments:
(STASH VALUE PLACE 42)

This error checking is absent from the 1963 version, and would have required
extra code. The 1963 STASH would simply have pulled the value and place forms
out, and ignored the superfluous 42.

The ``modern'' version (actually 1970's or 1980's modern) of the macro would
use the automatic form destructuring features of DEFMACRO, whereby the macro
lambda list (argument list to the DEFMACRO) constitutes a tree pattern
with variables, which is unified (one way) against the shape of the macro call.
Furthermore, we would use the backquote syntax to express the code generation
rather than a mess of list, quote and hard to understand ``cadavers'' like
CADAR:

(defmacro stash (value variable)
`(setq ,variable (cons ,value ,variable)))

That's it! The backquote may generate code similar to the 1963 stuff.
(Exactly how backquote works is implementation-specific). On the Lisp
implementation I'm using, the backtick is transliterated to a macro syntax,
which is then expanded, and so you can do the same thing:

[6]> (macroexpand '`(setq ,variable (cons ,value ,variable)))
(LIST 'SETQ VARIABLE (LIST 'CONS VALUE VARIABLE)) ;
T

Of course 'SETQ is a shorthand for (QUOTE SETQ), which is another
convenience not found in the original code. If we expand this notation,
we get:

(LIST (QUOTE SETQ) VARIABLE (LIST (QUOTE CONS) VALUE VARIABLE)) ;

Now, replace VALUE and VARIABLE with the expressions that compute their values,
namely (CADDR FORM) and (CADR FORM), and you get the 1963-ish code. :)
 
P

Pascal J. Bourguignon

Kaz Kylheku said:
The Software Preservation Group web page for Lisp history,
http://www.softwarepreservation.org/projects/LISP/ has a link to an
October 22, 1963 paper "MACRO Definition for LISP" by Timothy P. Hart,
ftp://publications.ai.mit.edu/ai-publications/pdf/AIM-057.pdf

I don't know enough about Lisp to evaluate whether what it describes is
the foundation of the current Lisp feature. Perhaps someone with the
necessary knowledge could take a look at it?

It positively, definitely describes the foundations of macros.

[...]

The SETQ expansion is achieved by means of

MACRO ((STASH (LAMBDA (FORM)
(LIST (QUOTE SETQ)
(CADAR FORM)
(LIST (CONS (CADR FORM)
(CADAR FORM)))))))

(Indentation mine).

This is in an old-style ``eval quote'' notation in which the outer parentheses
were omitted from the toplevel form. But basically the macro would work
today, with only a minor code update.

In http://www.informatimago.com/develop/lisp/small-cl-pgms/wang.html
you have a prefix that allow you to run directly these punch cards...
You just use (driver "stash.job") instead of (load "stash.lisp").

You will have to add the definition for the MACRO operator:

;; not tested.
(define macro (definitions)
(dolist (def definitions)
(destructuring-bind (name (lambda (form) &body body)) def
(assert (eq 'lambda lambda))
(eval `(defmacro ,name (&whole ,form) ,@body)))))

[...]

Clearly, the paper's author didn't cut and paste his own code from
the text editor into the Lisp window of his graphics worksation
to try it out. :) :) :)

Good luck trying to cut with scissors the top row of the punch cards
and paste it with glue on your paper... And this, if you have card
punchers able to print on the cards too.
 
O

Owen Jacobson

Who defines "what it is"?  Do you have some kind of tablets handed to
you by God with a definition of the word?

A user posting from Bell in Ottawa, who leaps to conclusions based on
rumour and naming and then defends those errors long past all
reason... Hmm, where have we seen this before?

-o
 
S

Series Expansion

A user posting from Bell in Ottawa, who leaps to conclusions based on
rumour and naming and then defends those errors long past all
reason... Hmm, where have we seen this before?

I honestly don't know. Certainly plenty of people here have been
making all sorts of errors and jumping to all sorts of conclusions,
though I'm not one of them. A number of them have apparently been
leaping to conclusions about me, though.
 
T

Tim Bradshaw

No, but I do have some paper handed to me by Webster's with a
definition of the word.

Webster's , of course, being the preferred source for any kind of
computing term.

But, actually:

macro |ˈmakrəʊ|
noun ( pl. -ros)
1 (also macro instruction) Computing a single instruction that expands
automatically into a set of instructions to perform a particular task.

That looks to me like a fine definition of Lisp-style macros.
 
A

Alan Bawden

Here, Mr. Expansion accuses us of "redefining" the word "macro".
Lisp has been calling them "macros" since they were originally proposed in
1963. [rest of irrelevant digression deleted]

But here he has deleted my evidence that the way Lisp uses the word is an
acceped meaning among computer scientists in 2009. He calls my evidence an
"irrelevant digression", and chooses to reply to the rest of my messsage in
the following manner:
I have not.


I am not.


I am not.

This is not even effective trolling any more. Mr. Expansion is now flying
randomly around the room like a rapidly deflating balloon. He'll
eventually come to rest behind the sofa, where we'll find him when cleaning
house next fall. "What the heck is this?", someone will say, holding up
the scrap of limp shriveled rubber he has become. "Oh", someone else will
answer, "that's what's left of Series Expansion. He wasn't fun for very
long. Just throw it out."
 
T

Thomas F. Burdick

Wow, I stand corrected (and by a decade, no less!).

The Software Preservation Group web page for Lisp history,http://www.softwarepreservation.org/projects/LISP/has a link to an
October 22, 1963 paper "MACRO Definition for LISP" by Timothy P. Hart,ftp://publications.ai.mit.edu/ai-publications/pdf/AIM-057.pdf

I don't know enough about Lisp to evaluate whether what it describes is
the foundation of the current Lisp feature. Perhaps someone with the
necessary knowledge could take a look at it?

Interesting, thanks for the link.
 
T

Tim Bradshaw

This is not even effective trolling any more. Mr. Expansion is now flying
randomly around the room like a rapidly deflating balloon. He'll
eventually come to rest behind the sofa, where we'll find him when cleaning
house next fall. "What the heck is this?", someone will say, holding up
the scrap of limp shriveled rubber he has become. "Oh", someone else will
answer, "that's what's left of Series Expansion. He wasn't fun for very
long. Just throw it out."

I find this kind of article really grossly unacceptable. I am sure I
am not alone in now requiring a new keyboard as my current one is now
full of coffee. Much worse, some people may have been typing while
reading and may now have scalded their hands. It is only through long
experience of this kind of behaviour on the part of certain people that
I know always to wear my asbestos-lined gloves while reading news.
Usually, of course I also wrap my laptop in cellophane.

Please refrain from this in future. I will be invoicing you for the
keyboard by return.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,685
Members
48,796
Latest member
Greg L.

Latest Threads

Top