Subject: Re: Seeking computer-programming job (Sunnyvale, CA)
From: rpw3@rpw3.org (Rob Warnock)
Date: Sat, 16 May 2009 06:24:55 -0500
Newsgroups: comp.lang.lisp,comp.lang.java.programmer
Message-ID: <IdOdnarELrkaP5PXnZ2dnUVZ_vWdnZ2d@speakeasy.net>
Seamus MacRae  <smacrae319@live.ca.nospam> wrote:
+---------------
| Rob Warnock wrote:
| > Oddly enough, it is *much* easier to explain Lisp macros to those
| > who have experience with assembly language macros in such "antiques"
| > as the DEC PDP-10 or IBM 360/370 mainframes which supported looping,
| > deconstruction/construction of symbol names (down to individual
| > characters), definition of new macros *by* macros, access to the
| > assembler's symbol table at compile time (accessing & mutating the
| > values of symbols and tags), "pass1" vs. "pass2" conditionals
| > (collect data from the whole program in pass 1 and drop it into
| > instruction and/or data locations in pass 2), etc., etc.[1]
| > 
| > But for those whose first or only experience of "macros" came from
| > the crippled incarnation of them in C, well, you are quite correct,
| > sadly.
| 
| The preprocessor in gcc lets you write macros that glue symbol names 
| together out of pieces. I think it's not an ANSI-standard feature 
| though.
+---------------

As far as I know, the # (stringify) and ## (concat) macro expansion
operators now *are* a part of ANSI C. I think they came in with C99,
but I'm not sure.

+---------------
| On the other hand, gcc-only compatibility is enough to get you 
| pretty wide operating-system and hardware portability these days.
+---------------

(*yawn*) Come back when macros in GCC (or any other C compiler)
can take a symbol name *apart*, and place the characters of the
name in individual locations, generating new variable names to
disambiguate dups, counting the length of the symbol, and computing
a hash of the name, and other things like that; e.g. a macro XPLOD(x)
that can do this:

   XPLOD(hello)

expands to:

   int var_h = 104;
   int var_e = 101;
   int var_l = 108;
   int var_l2 = 108;
   int var_o = 111;
   int num_hello_vars = 5;
   int hash_of_hello = 25120; /* hash = ((hash * 85) + char[i]) & 0xffff; */
   char upcase_HELLO[] = {72, 69, 76, 76, 79, 0};

PDP-10 assembler macros could do that; so can Lisp macros.


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607