gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Modula-2 generics, exceptions, and optional parameters - how widely


From: Benjamin Kowarsch
Subject: Re: Modula-2 generics, exceptions, and optional parameters - how widely supported?
Date: Fri, 29 Mar 2024 06:34:15 +0900

We were talking about Modula-2 and the ISO M2 generics extension.

There is absolutely no difference whatsoever between a templating engine replacing placeholders in a template and ISO M2 generics other than that the former shows you the result, and the latter does not. Functionally they are doing exactly the same thing.

On Fri, 29 Mar 2024 at 02:58, Alice Osako <alicetrillianosako@gmail.com> wrote:
Benjamin Kowarsch:
On Thu, 28 Mar 2024 at 23:54, Alice Osako wrote:
I was going to write a long diatribe on the subject of
textual-replacement macros vs. lexical macros, but none of that is
really relevant.

There is no difference between text replacement and lexical replacement.

There absolutely is a difference between lexical macros and textual-replacement macros, but since we aren't discussing Lisp, that difference is irrelevant, hence why I didn't post my original screed. Macros in Lisp - and especially Scheme - are far, far more than just replacing one piece of text with another.

In principle, a classical Lisp macro (as seen in Common Lisp and Clojure) is simply a Lisp function that runs at translation time - most 'serious' Lisps are compiled, even when run at the REPL, though this applies to interpreted implementations as well - and returns a either an atom or a list, with that then interpolated into the translator input stream.

It is not a preprocessor in the sense that say, cpp or m4 is, but an integral part of the language; I would say that over 80% of what most Common Lisp programmers see as being part of the language are actually composed from macros, including such seemingly fundamental forms as (let), (cond), and (loop) - most of which expand to different combinations of the the rock-bottom (lambda) form (though most implementations do implement at least some of them as primitives for the sake of efficiency). The entirety of CLOS (Common Lisp Object System) is built on macros.

Clojure doesn't lean as heavily on macros as CL does, but they are still a key part of the language.

Scheme's hygienic macros take this even further, but at this point I am going a bit too far afield. Suffice it to say that macros are part of what makes a Lisp, a Lisp - even if a given Lisp family language didn't have macros, they could easily be added by wrapping the reader with a macro transformer.

Sorry for the tangent, but this is sort of a big deal to me. I'm not sure if I am really explaining just how different Lisp macros are from, say, C macros, or just how fundamental meta-programming is in Lisps.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]