comp.lang.ada
 help / color / mirror / Atom feed
* OT: What was the first programming language to use 'generics'?...
@ 2005-08-18  9:18 Martin Dowie
  2005-08-18 11:29 ` Jean-Pierre Rosen
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Martin Dowie @ 2005-08-18  9:18 UTC (permalink / raw)


...and were they called 'generics'?

Not Ada but I just know /someone/ here will know this! ;-)





^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: OT: What was the first programming language to use 'generics'?...
  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
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 15+ messages in thread
From: Jean-Pierre Rosen @ 2005-08-18 11:29 UTC (permalink / raw)


Martin Dowie a �crit :
> ...and were they called 'generics'?
> 
> Not Ada but I just know /someone/ here will know this! ;-)
> 
> 
Not sure, but I think to remember that generics originated from Alphard

-- 
---------------------------------------------------------
            J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: OT: What was the first programming language to use 'generics'?...
  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-18 21:11 ` David Trudgett
  2005-08-18 21:36   ` Robert A Duff
  2005-08-19  2:47 ` Jeffrey R. Carter
  2005-08-21 17:33 ` adaworks
  3 siblings, 1 reply; 15+ messages in thread
From: David Trudgett @ 2005-08-18 21:11 UTC (permalink / raw)


"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? ;-)).

I'm only a Lisp learner myself (same as I'm learning Ada), but for
those who may be interested, the following is a very simple example of
a template style macro in Common Lisp (lifted from Peter Herth's LTk
package):

(defmacro with-ltk (&rest body)
  `(let ((*wish* nil)
         (ltk::*callbacks* (make-hash-table :test #'equal))
         (ltk::*counter* 1)
         (ltk::*event-queue* nil))
     (start-wish)
     ,@body
     (mainloop)))

This defines a macro called 'with-ltk' that takes a list of parameters
which it collectively (in this case) refers to as 'body'. The rest is
a code template (introduced by the backtick), into which the arguments
to 'with-ltk' are inserted (the ',@body' business). So, 'with-ltk' is
essentially just a simple code wrapper, and therefore not a
particularly fascinating example.

With this macro facility, the programmer can write a simple (or not!)
piece of code which generates different "parse trees" (I believe
that's the terminology) according to the context, for a similar effect
to Ada generics, which result in the generation of varying object code
according to context.

David


-- 

David Trudgett
http://www.zeta.org.au/~wpower/

As a computer, I find your faith in technology amusing.




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: OT: What was the first programming language to use 'generics'?...
  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 15:42     ` jayessay
  0 siblings, 2 replies; 15+ messages in thread
From: Robert A Duff @ 2005-08-18 21:36 UTC (permalink / raw)


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
is: what should names in the template refer to.  If a name in the
template refers to something local to the template, it refers to the
copy of that thing in the instance.  If it refers to a formal parameter
in the template, it refers to the actual parameter in the instance.  If
it refers to neither, what should it refer to?  To something visible at
the place of the template, or something visible at the place of the
instance?  The Ada answer is: at the place of the template.  The usual
macro answer is: at the place of the instance.

Some Lisp dialects have "hygienic macros", which are a lot more like Ada
generics in this regard.

- Bob



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: OT: What was the first programming language to use 'generics'?...
  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 15:08       ` OT: What was the first programming language to use 'generics'? Robert A Duff
  2005-08-19 15:42     ` jayessay
  1 sibling, 2 replies; 15+ messages in thread
From: David Trudgett @ 2005-08-18 23:43 UTC (permalink / raw)


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). Lisp's use
of "S-expressions" (for "symbolic expressions", but refers to the
parenthesis syntax: "(function-name argument argument argument...)" is
perhaps the major reason that Lisp macros can be as powerful as they
are (because it's easy for code to generate code in this format). No
language that I know of, besides the Lisp family (including Scheme),
uses this syntax.

Of course, there are many languages of which I have little or no
knowledge, such as Smalltalk, Haskell, Eiffel, ML. I wouldn't be (too)
surprised if one or more of these have some sort of "macro" facility;
but without the regularity of S-expressions, it's hard to see any
comparison to Lisp macros.

Anyway, I'm sure most of you have heard the Lisp macro spiel before.


> is: what should names in the template refer to.  If a name in the
> template refers to something local to the template, it refers to the
> copy of that thing in the instance.  If it refers to a formal parameter
> in the template, it refers to the actual parameter in the instance.  If
> it refers to neither, what should it refer to?  To something visible at
> the place of the template, or something visible at the place of the
> instance?  The Ada answer is: at the place of the template.  The usual
> macro answer is: at the place of the instance.

This all seems to be correct.


>
> 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. 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).

Thanks for your comments, Bob.


David


-- 

David Trudgett
http://www.zeta.org.au/~wpower/

"... we think the price is worth it."

    -- US Ambassador Madeleine Albright, when asked if the deaths of
       half a million Iraqi children were a price worth paying for
       sanctions




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: OT: What was the first programming language to use
  2005-08-18 23:43     ` David Trudgett
@ 2005-08-19  2:13       ` Larry Kilgallen
  2005-08-19  9:44         ` David Trudgett
  2005-08-19 14:22         ` jayessay
  2005-08-19 15:08       ` OT: What was the first programming language to use 'generics'? Robert A Duff
  1 sibling, 2 replies; 15+ messages in thread
From: Larry Kilgallen @ 2005-08-19  2:13 UTC (permalink / raw)


In article <m3y86yak0v.fsf@rr.trudgett>, David Trudgett <wpower@zeta.org.au.nospamplease>  writes:
> Robert A Duff <bobduff@shell01.TheWorld.com> writes:

>> 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).

Bliss macros are also entirely different from C macros.

A difference between Lisp and C does not automatically make Lisp
the only language with the right to use the word "system".



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: OT: What was the first programming language to use 'generics'?...
  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-18 21:11 ` David Trudgett
@ 2005-08-19  2:47 ` Jeffrey R. Carter
  2005-08-21 17:33 ` adaworks
  3 siblings, 0 replies; 15+ messages in thread
From: Jeffrey R. Carter @ 2005-08-19  2:47 UTC (permalink / raw)


Martin Dowie wrote:

> ...and were they called 'generics'?
> 
> Not Ada but I just know /someone/ here will know this! ;-)

The Ada-83 Rationale (available at the AdaIC) lists a number of earlier 
languages with generics of some sort: EL1, Simula, Clu, and Mary.

-- 
Jeff Carter
"Now look, Col. Batguano, if that really is your name."
Dr. Strangelove
31



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: OT: What was the first programming language to use
  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
  1 sibling, 0 replies; 15+ messages in thread
From: David Trudgett @ 2005-08-19  9:44 UTC (permalink / raw)


Kilgallen@SpamCop.net (Larry Kilgallen) writes:

> Bliss macros are also entirely different from C macros.
>
> A difference between Lisp and C does not automatically make Lisp
> the only language with the right to use the word "system".

So, it's good that nobody claimed that?

David


-- 

David Trudgett
http://www.zeta.org.au/~wpower/

The smart way to keep people passive and obedient is to strictly
limit the spectrum of acceptable opinion, but allow very lively debate
within that spectrum - even encourage the more critical and dissident
views. That gives people the sense that there's free thinking going
on, while all the time the presuppositions of the system are being
reinforced by the limits put on the range of the debate.

    -- Noam Chomsky



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: OT: What was the first programming language to use
  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
  1 sibling, 0 replies; 15+ messages in thread
From: jayessay @ 2005-08-19 14:22 UTC (permalink / raw)


Kilgallen@SpamCop.net (Larry Kilgallen) writes:

> In article <m3y86yak0v.fsf@rr.trudgett>, David Trudgett
> <wpower@zeta.org.au.nospamplease>  writes:
> > Robert A Duff <bobduff@shell01.TheWorld.com> writes:
> 
> >> 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).
> 
> Bliss macros are also entirely different from C macros.

Agreed, but Bliss macros are still no where near Lisp macros.


> A difference between Lisp and C does not automatically make Lisp
> the only language with the right to use the word "system".

I don't see where he said anything about it having the "only right" to
the term.


/Jon

-- 
'j' - a n t h o n y at romeo/charley/november com



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: OT: What was the first programming language to use 'generics'?...
  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 15:08       ` Robert A Duff
  2005-08-19 18:09         ` jayessay
  1 sibling, 1 reply; 15+ messages in thread
From: Robert A Duff @ 2005-08-19 15:08 UTC (permalink / raw)


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



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: OT: What was the first programming language to use 'generics'?...
  2005-08-18 21:36   ` Robert A Duff
  2005-08-18 23:43     ` David Trudgett
@ 2005-08-19 15:42     ` jayessay
  1 sibling, 0 replies; 15+ messages in thread
From: jayessay @ 2005-08-19 15:42 UTC (permalink / raw)


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

Apropos to the actual thread title, I don't think Lisp macros are much
of anything like "generics" as the term is typically used, because
while they can act as templates for simple cases, that is a small part
of what they do.


> is: what should names in the template refer to.

The distinctions here are harder to apply in the Lisp case, but it may
be interesting to look a bit more.


> If it refers to a formal parameter in the template, it refers to the
> actual parameter in the instance.

This is the easier of the two.  The most typical case in Lisp, would
adhere to this as well:

(defmacro hi (a)
  `(format nil "Hello there object ~A" ,a))

The backquote comma form is a shorthand for creating a template, so
this very simple example is indeed a code template.  The backquote
says to copy things verbatim except for "escaped" things (which the
comma does).

A call could be

(hi 1) ==> "Hello there object 1"

The expansion is just what you would think:

(FORMAT NIL "Hello there object ~A" 1)

(hi 'A) ==> "Hello there object A"

Expansion: (FORMAT NIL "Hello there object ~A" 'A)


However, this typical _use_ of parameters is not required or even what
you want to do in many cases.  Those cases are where the parameter(s)
may control the expansion process.  For example,

(defmacro foo (key)
  (let ((type-of-key (type-of key)))
    (if (eq key :one)
	`(identity '(One is the first counting number))
      `(identity '(the type of the KEY argument is ,type-of-key)))))

(foo :one) ==> (one is the first counting number)

Expansion: (identity '(one is the first counting number))

(foo :two) ==> (the type of the key argument is symbol)

Expansion: (identity '(the type of the key argument is symbol))


As you can see, the KEY parameter does not show up in either the
output (as its value) or the expansion code (as itself).


>  If a name in the template refers to something local to the
> template, it refers to the copy of that thing in the instance.

If you look at the foo macro and its expansion a bit, you can also see
there are things ("names") in the "template" (expander code) which do
not show up at all in the "instance" (expansion).  For example, the
LET, IF, etc are all gone. There are other things which do behave in
this fashion, for example, IDENTITY.

> If it refers to neither, what should it refer to?  To something
> visible at the place of the template, or something visible at the
> place of the instance?  The Ada answer is: at the place of the
> template.  The usual macro answer is: at the place of the instance.

In the case of Lisp, the answer is it refers to _expander code_ and it
doesn't exist (let alone being visible) at either noted place.  It
exists in the macro function:

(symbol-function 'foo) ==> #<macro FOO @ #x775b97f2>


It's this last bit, that a Lisp macro is really a function (like any
other, except that it runs at a special time), able to make use of any
resources available in the base language, 3rd party libs, your own
code and the macros lexical and expansion time environment, that makes
Lisp macros so completely different from templates, parameterized
code/types, generics, and other "macros".


> Some Lisp dialects have "hygienic macros", which are a lot more like Ada
> generics in this regard.

You're probably thinking of Scheme (syntax-case) or maybe Dylan here.
I'd say they are somewhat more like generics/templates.


/Jon

-- 
'j' - a n t h o n y at romeo/charley/november com



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: OT: What was the first programming language to use 'generics'?...
  2005-08-18 11:29 ` Jean-Pierre Rosen
@ 2005-08-19 16:25   ` Charles Lindsey
  0 siblings, 0 replies; 15+ messages in thread
From: Charles Lindsey @ 2005-08-19 16:25 UTC (permalink / raw)


In <6fr1ed.22f.ln@hunter.axlog.fr> Jean-Pierre Rosen <rosen@adalog.fr> writes:

>Martin Dowie a �crit :
>> ...and were they called 'generics'?
>> 
>> Not Ada but I just know /someone/ here will know this! ;-)
>> 
>> 
>Not sure, but I think to remember that generics originated from Alphard

That might well be so. Alphard introduced all sorts of interesting
concepts, but bear in mind that they remained as just concepts, because
they never implemented it.

-- 
Charles H. Lindsey ---------At Home, doing my own thing------------------------
Tel: +44 161 436 6131 Fax: +44 161 436 6133   Web: http://www.cs.man.ac.uk/~chl
Email: chl@clerew.man.ac.uk      Snail: 5 Clerewood Ave, CHEADLE, SK8 3JU, U.K.
PGP: 2C15F1A9      Fingerprint: 73 6D C2 51 93 A0 01 E7 65 E8 64 7E 14 A4 AB A5



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: OT: What was the first programming language to use 'generics'?...
  2005-08-19 15:08       ` OT: What was the first programming language to use 'generics'? Robert A Duff
@ 2005-08-19 18:09         ` jayessay
  0 siblings, 0 replies; 15+ messages in thread
From: jayessay @ 2005-08-19 18:09 UTC (permalink / raw)


Robert A Duff <bobduff@shell01.TheWorld.com> writes:

> 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).

The other big one is unintended multiple evaluation of parameters.

In the case of Lisp (Common Lisp), these are not a problem as David
Trudgett pointed out, i.e., there are simple mechanisms available
which _guarantee_ this cannot happen.  OTOH, there are times when
variable capture is _exactly_ what you _want_.

Example (impossible unintended variable capture and no multiple evaluation):

(defmacro with-foo (id &body body)
  (with-unique-names (gid temp)
    `(let* ((,gid ,id)
	    (,temp (get-foo ,gid)))
       (unwind-protect
	   (progn ,@body)
	 (release-foo ,temp)))))

gid and temp here act very similarly to "temporary variables"
generated by a compiler to hold intermediate values in a generated
code sequence.  Both are generated at expansion time and both are
universally unique.  Also, a parameter passed to the formal ID will be
evaluated exactly once.


(defun flubber (xyz info)
  (let ((temp (some-computation xyz)))
    (with-foo (determine-foo info)
      (do-some-stuff temp)
      (setf temp (some-other-computation))
      (if (some-test temp)
	  :success
	:fail))))

Here's what the body of flubber expands to:

(let ((temp (some-computation xyz)))
  (let* ((#:gid81696 (determine-foo info))
         (#:temp81697 (get-foo #:gid81696)))
    (unwind-protect
        (progn
          (do-some-stuff temp)
          (setf temp (some-other-computation))
          (if (some-test temp) :success :fail))
      (release-foo #:temp81697))))

For this _specific_ expansion, gid and temp become "temporary
variables" #:gid81696 and #:temp81697.  Another expansion will
generate new versions.  Note that TEMP is not inadvertantly captured
and the TEMP in the users code correctly refers to the outermost TEMP.


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

In this respect as well.



> >... 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.

Not really - as you can see above.  But then "hygiene" is pretty
subjective.  As I said above, there are times when you absolutely
_want_ to have a particular variable captured.  It makes the
_semantics_ exactly right.  In something like syntax-case, you can't
do that.  Which is one reason (amoung many) why all Scheme
implementations actually end up providing defmacro anyway.


> 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.

That does not capture lexical variables which is what you sometimes
want.


/Jon

-- 
'j' - a n t h o n y at romeo/charley/november com



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: What was the first programming language to use 'generics'?...
  2005-08-18  9:18 OT: What was the first programming language to use 'generics'? Martin Dowie
                   ` (2 preceding siblings ...)
  2005-08-19  2:47 ` Jeffrey R. Carter
@ 2005-08-21 17:33 ` adaworks
       [not found]   ` <odeig19vmplnbt67s3s148eb4mqrk9vujd@4ax.com>
  3 siblings, 1 reply; 15+ messages in thread
From: adaworks @ 2005-08-21 17:33 UTC (permalink / raw)



"Martin Dowie" <martin.dowie@baesystems.com> wrote in message
news:43045094_1@glkas0286.greenlnk.net...
> ...and were they called 'generics'?
>
> Not Ada but I just know /someone/ here will know this! ;-)
>
My first exposure to generics was with generic sort programs.

Consider, in the early sort programs supplied for operating systems
we had a set of behaviors already programmed.   All we had to do
was supply a description of the data.   Ada generics are a lot like
that.  We reuse behavior while describing the data to be processed
with that behavior.

With those sort facilities, we could even add some additional code for
what we called an "own code" sort.  Typically the "own code" was
used to accomplish some special input or output procedures on the
data.  This is analogous to generic formal subprograms or (in Ada 95)
generic formal package parameters.

My earliest recollection of this was for the IBM 1401 where our "own
code" was written in Autocoder.  Later, I discovered this same capability
was on other platforms, including the entire 360/370 series (along with
those that used IBM's operating systems), and all the machines from the
"seven dwarfs."    COBOL even has a SORT verb as part of the language
that one could think of as a generic capability.

So, the first high-order language to have a generic capability might well
be COBOL.

Richard Riehle





^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: What was the first programming language to use 'generics'?...
       [not found]   ` <odeig19vmplnbt67s3s148eb4mqrk9vujd@4ax.com>
@ 2005-08-23  7:03     ` adaworks
  0 siblings, 0 replies; 15+ messages in thread
From: adaworks @ 2005-08-23  7:03 UTC (permalink / raw)



"Dennis Lee Bieber" <wlfraed@ix.netcom.com> wrote in message
news:odeig19vmplnbt67s3s148eb4mqrk9vujd@4ax.com...
> On Sun, 21 Aug 2005 17:33:19 GMT, <adaworks@sbcglobal.net> declaimed the
> following in comp.lang.ada:
>
>
> > "seven dwarfs."    COBOL even has a SORT verb as part of the language
> > that one could think of as a generic capability.
> >
> > So, the first high-order language to have a generic capability might well
> > be COBOL.
> >
> This could be tricky... I think some implementations of the SORT
> verb assumed an external sort program existed to do the actual sorting
> after the parameters were translated.
>
Exactly so.  The algorithms of the SORT verb were in a separate facility.
This facility (program) was a generic program.  One simply stated the
description of the data and let the behavior of the sort work on that
data.   This is exactly what most generic units do in Ada.

Richard Riehle





^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2005-08-23  7:03 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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       ` OT: What was the first programming language to use 'generics'? Robert A Duff
2005-08-19 18:09         ` 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

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