From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,3413256b2f4bedfc X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!newsfeed.stanford.edu!newsfeed.news.ucla.edu!newsfeed.media.kyoto-u.ac.jp!news1.optus.net.au!optus!newsfeeder.syd.optusnet.com.au!news.optusnet.com.au!newsfeed.pacific.net.au!nasal.pacific.net.au!not-for-mail Newsgroups: comp.lang.ada Subject: Re: OT: What was the first programming language to use 'generics'?... From: David Trudgett Organization: Very little? References: <43045094_1@glkas0286.greenlnk.net> Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:Tge3qOgXdyb2fWi9MuTWn3SMBbI= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Fri, 19 Aug 2005 07:11:08 +1000 NNTP-Posting-Host: 61.8.40.160 X-Complaints-To: news@pacific.net.au X-Trace: nasal.pacific.net.au 1124399733 61.8.40.160 (Fri, 19 Aug 2005 07:15:33 EST) NNTP-Posting-Date: Fri, 19 Aug 2005 07:15:33 EST Xref: g2news1.google.com comp.lang.ada:4174 Date: 2005-08-19T07:11:08+10:00 List-Id: "Martin Dowie" 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.