From: ···········@gmail.com
Subject: macros, in common lisp and before.
Date: 
Message-ID: <1116122460.068851.188210@f14g2000cwb.googlegroups.com>
I read somewhere (can't recall where at the moment) that lisp macros as
used today are not as powerful as original lisp macros.  I cannot
imagine how macros could be more powerful-is my recollection wrong, or
were they even more powerful before?

From: Eric Lavigne
Subject: Re: macros, in common lisp and before.
Date: 
Message-ID: <1116126177.351791.262850@g14g2000cwa.googlegroups.com>
>I read somewhere (can't recall where at the
>moment) that lisp macros as
>used today are not as powerful as original
>lisp macros.

Paul Graham suggested that, in some ways, Common Lisp took a step back
in power. See the following site and "search in page" for "Let yourself
be second guessed." He touches on the issue you mention, though he
doesn't go into much detail.

http://www.paulgraham.com/popular.html
From: Barry Margolin
Subject: Re: macros, in common lisp and before.
Date: 
Message-ID: <barmar-E46C94.02214215052005@comcast.dca.giganews.com>
In article <························@g14g2000cwa.googlegroups.com>,
 "Eric Lavigne" <············@gmail.com> wrote:

> >I read somewhere (can't recall where at the
> >moment) that lisp macros as
> >used today are not as powerful as original
> >lisp macros.
> 
> Paul Graham suggested that, in some ways, Common Lisp took a step back
> in power. See the following site and "search in page" for "Let yourself
> be second guessed." He touches on the issue you mention, though he
> doesn't go into much detail.
> 
> http://www.paulgraham.com/popular.html

Are you talking about the paragraph about the move from classic macros 
to hygienic macros?  Common Lisp macros aren't hygienic, so I don't 
think it's germane to this discussion.  Scheme offers hygienic macros, 
although I think you can also write Lisp-style macros when you need to, 
so you get the best of both worlds.

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
From: Eric Lavigne
Subject: Re: macros, in common lisp and before.
Date: 
Message-ID: <1116162532.764075.177830@f14g2000cwb.googlegroups.com>
>> Paul Graham suggested that, in some ways, Common Lisp took a step
back
>> in power. See the following site and "search in page" for "Let
yourself
>> be second guessed." He touches on the issue you mention, though he
>> doesn't go into much detail.

>> http://www.paulgraham.com/popular.html

>Are you talking about the paragraph about the move from classic macros
>to hygienic macros?  Common Lisp macros aren't hygienic, so I don't
>think it's germane to this discussion.  Scheme offers hygienic macros,
>although I think you can also write Lisp-style macros when you need
to,
>so you get the best of both worlds.

The paragraph about hygienic macros is probably about Scheme (though it
is not mentioned by name) because it refers to variable capture which
is possible (and perhaps too easy) in Common Lisp. Basically, macros
are not as powerful as they once were because they no longer have
access to everything. Actually, I think you can get that access. You
can pass the result of a nil format of the struct (a string) to a
function which strips out all words starting with ":", replaces ":"
with "-", appends those strings to the name of the struct, and converts
those strings into symbols. Not as efficient as it could be, but
certainly possible. Anyhow, here are the paragraphs (from Paul Graham's
essay) that I was referring to:

In Common Lisp I have often wanted to iterate through the fields of a
struct-- to comb out references to a deleted object, for example, or
find fields that are uninitialized. I know the structs are just vectors
underneath. And yet I can't write a general purpose function that I can
call on any struct. I can only access the fields by name, because
that's what a struct is supposed to mean.

Historically, Lisp has been good at letting hackers have their way. The
political correctness of Common Lisp is an aberration. Early Lisps let
you get your hands on everything. A good deal of that spirit is,
fortunately, preserved in macros. What a wonderful thing, to be able to
make arbitrary transformations on the source code.
From: Edi Weitz
Subject: Re: macros, in common lisp and before.
Date: 
Message-ID: <ull6gvd8w.fsf@agharta.de>
On 15 May 2005 06:08:52 -0700, "Eric Lavigne" <············@gmail.com> wrote:

> I know the structs are just vectors underneath.

That's not always the case.  See the CLHS entry for DEFSTRUCT and
specifically the :TYPE option.

Edi.

-- 

Lisp is not dead, it just smells funny.

Real email: (replace (subseq ·········@agharta.de" 5) "edi")
From: Pascal Costanza
Subject: Re: macros, in common lisp and before.
Date: 
Message-ID: <3ep0ssF49d5nU1@individual.net>
Eric Lavigne wrote:

> Anyhow, here are the paragraphs (from Paul Graham's
> essay) that I was referring to:
> 
> In Common Lisp I have often wanted to iterate through the fields of a
> struct-- to comb out references to a deleted object, for example, or
> find fields that are uninitialized. I know the structs are just vectors
> underneath. And yet I can't write a general purpose function that I can
> call on any struct. I can only access the fields by name, because
> that's what a struct is supposed to mean.

Structs are not necessarily vectors. The spec leaves this 
implementation-dependent. However, you can specify that you want a 
vector underneath, and then of course you can also iterate through the 
slots. It's trivial to shadow defstruct to get this implicitly for every 
struct you define.

The CLOS MOP also provides standard-instance-access for accessing the 
slot vector of CLOS objects directly via integers.


Pascal

-- 
2nd European Lisp and Scheme Workshop
July 26 - Glasgow, Scotland - co-located with ECOOP 2005
http://lisp-ecoop05.bknr.net/
From: Barry Margolin
Subject: Re: macros, in common lisp and before.
Date: 
Message-ID: <barmar-83F8BF.22442014052005@comcast.dca.giganews.com>
In article <························@f14g2000cwb.googlegroups.com>,
 ···········@gmail.com wrote:

> I read somewhere (can't recall where at the moment) that lisp macros as
> used today are not as powerful as original lisp macros.  I cannot
> imagine how macros could be more powerful-is my recollection wrong, or
> were they even more powerful before?

The only thing I can think of is that Maclisp allowed a macro to modify 
the original form destructively.  So it became popular to write 
"memoizing" macros, so that a macro would only have to be expanded once 
in the interpreter, rather than every time the function was executed.

But since we almost always compile code these days, the benefit of this 
is virtually nil.

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
From: William D Clinger
Subject: Re: macros, in common lisp and before.
Date: 
Message-ID: <1116289301.313797.212470@g14g2000cwa.googlegroups.com>
> I read somewhere (can't recall where at the moment) that lisp
> macros as used today are not as powerful as original lisp
> macros.  I cannot imagine how macros could be more powerful-is
> my recollection wrong, or were they even more powerful before?

MacLisp had things called FEXPRs, which were sometimes referred
to as macro-like entities.  FEXPRs could do things that CL-style
macros cannot do.  IIRC, they were so expressive that they didn't
even work in compiled code.  As Mitch Wand wrote, "the theory of
FEXPRs is trivial" because they don't obey any universal laws
that a compiler could use to translate them into another language,
e.g. machine code [1].

Will

[1]  Mitchell Wand.  The Theory of Fexprs is Trivial.
Higher-Order and Symbolic Computation, 10(10), May 1998,
pages 189-199.

Abstract:
We provide a very simple model of a reflective facility based
on the pure lambda-calculus, and we show that its theory of
contextual equivalence is trivial: two terms in the language are
contextually equivalent iff they are alpha-congruent.
From: ···········@gmail.com
Subject: Re: macros, in common lisp and before.
Date: 
Message-ID: <1116299746.259289.92060@z14g2000cwz.googlegroups.com>
I had never heard of fexprs, but they seem pretty understandable-they
are just lazily evaluated functions, right?
From: Barry Margolin
Subject: Re: macros, in common lisp and before.
Date: 
Message-ID: <barmar-2631C5.03160417052005@comcast.dca.giganews.com>
In article <·······················@z14g2000cwz.googlegroups.com>,
 ···········@gmail.com wrote:

> I had never heard of fexprs, but they seem pretty understandable-they
> are just lazily evaluated functions, right?

Not quite.  Their arguments are never evaluated automatically, the fexpr 
function has to evaluate them explicitly.  "Lazy evaluation" usually 
refers to a system that evaluates an argument automatically when the 
function references it for the first time.

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***