comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: OT: What was the first programming language to use 'generics'?...
Date: 19 Aug 2005 11:08:05 -0400
Date: 2005-08-19T11:08:05-04:00	[thread overview]
Message-ID: <wcc4q9m6k2y.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: m3y86yak0v.fsf@rr.trudgett

David Trudgett <wpower@zeta.org.au.nospamplease>  writes:

> Robert A Duff <bobduff@shell01.TheWorld.com> writes:
> 
> > David Trudgett <wpower@zeta.org.au.nospamplease>  writes:
> >
> >> "Martin Dowie" <martin.dowie@baesystems.com> writes:
> >> 
> >> > ...and were they called 'generics'?
> >> >
> >> > Not Ada but I just know /someone/ here will know this! ;-)
> >> >
> >> >
> >> 
> >> Probably (given I'm not a language historian) Lisp code macros were
> >> the first, except for a couple of provisos: (a) Lisp never had the
> >> strong static typing that Ada has, so Lisp macros weren't invented to
> >> solve the same problem as Ada generics; and (b) Lisp macros are more
> >> general than Ada generics in the sense that they allow essentially
> >> arbitrary code (not text) generation (every Ada programmer's
> >> nightmare? ;-)).
> >
> > An important difference between Ada's generics and most macro systems
> 
> A small quibble, perhaps: I don't think one can use the phrase "most
> macro systems" for the simple reason that (as far as I'm aware) no
> language family besides the Lisp one has a macro system (in the sense
> that Lisp has it -- they may well use the same word, but C language
> "macros", for instance, are a completely different beast).

I was including Lisp macros and C macros and the macros of many other
languages, including assembly languages in the term "macro systems".
Larry Kilgallen mentioned Bliss, which has an extremely powerful macro
system.  Most of them, I believe, share the same problem of accidentally
referring to names visible at the place of the instantiation (macro
call).

But I agree that most of them are inferior to the Lisp version
in many other respects.

> > Some Lisp dialects have "hygienic macros", which are a lot more like Ada
> > generics in this regard.
> 
> You would be referring to Scheme dialects here.

Yes, Scheme is one example.  I think there are others, but I can't
remember any examples at the moment.

>... Interestingly,
> Scheme's "hygienic macros" do not make Common Lisp's macros
> "unhygienic"! They just add an extra restriction which stops the
> programmer from doing certain things that can be done in Common Lisp
> macros (from what I hear). The same level of "hygiene" can be had in
> Common Lisp macros by the use of appropriate programming style,
> including the use of GENSYM to avoid referring to extraneous "symbols"
> (read "variable names", close enough).

This has been debated intensely in the Lisp community.
My opinion is that GENSYM doesn't make them hygienic, because GENSYM
is something you have to remember to do by hand all over the place.
In Scheme macros, and Ada generics, it happens automatically.
Also, I don't see how this hygiene loses any power -- if you *want*
to capture variable names visible at the call site, you can pass
parameters to the macro/generic.

> Thanks for your comments, Bob.

Likewise.

- Bob



  parent reply	other threads:[~2005-08-19 15:08 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-18  9:18 OT: What was the first programming language to use 'generics'? Martin Dowie
2005-08-18 11:29 ` Jean-Pierre Rosen
2005-08-19 16:25   ` Charles Lindsey
2005-08-18 21:11 ` David Trudgett
2005-08-18 21:36   ` Robert A Duff
2005-08-18 23:43     ` David Trudgett
2005-08-19  2:13       ` OT: What was the first programming language to use Larry Kilgallen
2005-08-19  9:44         ` David Trudgett
2005-08-19 14:22         ` jayessay
2005-08-19 15:08       ` Robert A Duff [this message]
2005-08-19 18:09         ` OT: What was the first programming language to use 'generics'? jayessay
2005-08-19 15:42     ` jayessay
2005-08-19  2:47 ` Jeffrey R. Carter
2005-08-21 17:33 ` adaworks
     [not found]   ` <odeig19vmplnbt67s3s148eb4mqrk9vujd@4ax.com>
2005-08-23  7:03     ` adaworks
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox