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.berkeley.edu!ucberkeley!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:nHMOPbwdQIVpNUFWXQI5bTCTv9E= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Fri, 19 Aug 2005 09:43:28 +1000 NNTP-Posting-Host: 61.8.40.160 X-Complaints-To: news@pacific.net.au X-Trace: nasal.pacific.net.au 1124408875 61.8.40.160 (Fri, 19 Aug 2005 09:47:55 EST) NNTP-Posting-Date: Fri, 19 Aug 2005 09:47:55 EST Xref: g2news1.google.com comp.lang.ada:4178 Date: 2005-08-19T09:43:28+10:00 List-Id: Robert A Duff writes: > David Trudgett writes: > >> "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? ;-)). > > 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