宏(用户定义的代码转换)的想法是什么时候出现的?

发布于 2024-09-06 06:05:05 字数 366 浏览 7 评论 0原文

我读过 McCarthy 1960 年关于 LISP 的论文,没有发现任何与用户定义宏或正常顺序求值类似的内容。我想知道宏何时首次出现在编程语言历史中(以及 Lisp 历史中):

  • 用户定义代码转换(在解释或编译之前)的想法是什么时候(理论上)首次被描述的?
  • 第一个具有类似 Lisp 宏的编程语言实现是什么(我所说的“类似 Lisp”是指“使用可读的图灵完备语言来进行代码转换”)? (包括非 Lisps——例如 Forth 已经很老了,但我不确定第一个 Forth 实现是否已经有“立即”)
  • 其中哪一个是第一个高级编程语言(不包括汇编语言...... )
  • 第一个拥有宏的 Lisp 方言是什么?

谢谢你!

I have read McCarthy's 1960 paper on LISP and found no reference to anything that's similar to user-defined macros or normal order evaluation. I was wondering when macros first appeared in programming language history (and also in Lisp history):

  • When was the idea of user-defined code transformation (before interpretation or compilation) first described (theoretically)?
  • What was the first programming language implementation to have Lisp-like macros (by "Lisp-like" I mean "using a readable Turing-complete language to do code-transformation")? (including non-Lisps -- Forth for example is quite old, but I'm not sure if the first Forth implementation already had "IMMEDIATE")
  • Also which of those was the first high-level programming language (exclude assembler languages...)
  • What was the first Lisp dialect to have macros?

Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

骄傲 2024-09-13 06:05:06

要了解宏是如何引入 Lisp 的,您应该查找提及的 FEXPRsFSUBR,它们是现代 Lisp 宏的前身(或更准确地说,FEXPRs< /em> 是用户定义宏的前身)。这些在多个地方都提到过——例如,在从 LISP 1 到McCarthy 的 Lisp 的历史 的 LISP 1.5 部分。但事实上,早在这之前就已经提到过:LISP I PROGRAMMER'S MANUAL(从 1960 年开始)您可以看到 FEXPR 和 FSUBR 的描述。

顺便说一句,将 Lisp 宏与基于字符串的系统进行比较有点虚假。与字符串操作相比,使用树形转换器的优势足以使其成为一个完全不同的系统。 Lisp 宏的另一个重要方面是它们是本地转换与全局程序转换(对此最明显的阅读论文是 Felleisen 的 论编程语言的表达能力)。当然,这里有一个完整的领域——从 FEXPR 到现代的、行为更良好的宏,然后到 Scheme 中的卫生宏(它处理比符号解析树更丰富的表示),然后是宏和模块系统、语法扩展阶段等等。这里的内容可能足够供几年阅读...

To look for how macros where introduced into Lisp, you should look for mentions of FEXPRs and FSUBRs which the predecessors of modern Lisp macros (or more accurately, FEXPRs are the predecessors of user-defined macros). These are mentioned in several places -- for example, in the From LISP 1 to LISP 1.5 section of McCarthy's History of Lisp. But in fact, it's also mentioned earlier than that: in p.48 of the LISP I PROGRAMMER'S MANUAL (from 1960) you can see a description of FEXPRs and FSUBRs.

BTW, it's a little bogus to compare Lisp macros with string-based systems. The advantage of using a tree transformer vs string manipulations is significant enough to make it a completely different system. Another important aspect of Lisp macros is that they are local transformation vs a global program transformation (the most obvious paper to read for this is Felleisen's On the Expressive Power of Programming Languages). And of course there's a whole area here -- going from FEXPRs to the modern, more well behaved macros, then to hygienic macros in Scheme (which deal with a representation that is richer than symbolic parse trees), then a combination of macros and a module system, syntax expansion phases, etc etc etc. There's probably enough stuff here for a few years of reading...

写下不归期 2024-09-13 06:05:06

我认为这个想法可以追溯到帖子系统,用字符串重写(“如果你看到这个字符串,将其替换为该字符串”)。后期系统具有图灵能力,因此可以计算任何东西(包括程序文本!)。埃米尔·波斯特 (Emil Post) 关于这些的论文日期为 1943 年,但据说他在 1920 年代完成了最初的概念化。

通用宏处理器是最早广泛使用的宏处理器之一,于 20 世纪 60 年代初问世。

TRAC 是同一时期的另一个早期宏处理器。 计算机语言史 (TRAC) 说它是设计于 1959 年。

这两款都是具有图灵功能的宏处理器。

SNOBOL 也来自同一时期。

事实上,非常通用的宏处理器是在 60 年代初构建的,这一事实向我暗示,在那之前可能已经构建了专用宏处理器来提供灵感。我很确定在此之前宏处理器已经在汇编器中使用,但我没有具体的证据。

我知道 COBOL 有所谓的 COPY 库,它是宏和包含文件之间的交叉。我不知道 COBOL 何时引入这种语言,但这种语言可以追溯到 1958 年。

值得注意的是,LISP 宏可以被视为树到树重写的特殊情况(“如果您看到 s -表达式看起来像这样,将其替换为看起来像这样的 s-表达式”)。树可以很容易地建模为字符串(参见:“LISP”:),因此 LISP 宏是字符串重写的一种特殊情况。

树重写的一般情况现在是程序转换系统的基础,可以对程序文本进行大量修改。

I think the idea goes back to Post systems, rewriting with strings ("if you see this string, replace it with that string"). Post systems are Turing-capable, and can thus compute anything (including program texts!). Emil Post's paper on these is dated 1943, but supposedly he did the original conceptualization in the 1920s.

The General Purpose Macro Processor, one of the first widely used ones, was available in the early 60s.

TRAC is another early macro processor dating to the same period. The History of Computer Languages (TRAC) says it was designed in 1959.

Both of these are Turing-capable macro processors.

SNOBOL also dates from the same period.

The fact that very general-purpose macro processors were being built in the early 60s hints to me that there were likely special-purpose macro processors built before then to provide inspiration. I'm pretty sure macro processors were in use in assemblers before this point, but I don't have specific evidence.

I know that COBOL has so-called COPY libs, which are a cross between macros and include files. I don't know when this was introduced into COBOL, but the langauge goes back to 1958.

It is interest to note that LISP macros can be considered to be a special case of tree-to-tree rewrites ("if you see an s-expression that looks like this, replace it by an s-expression that looks like that"). Trees can be easily modelled as strings (see: "LISP" :) and thus LISP macros are a special case of string rewriting.

The generalized case of tree-rewriting is now the basis for Program Transformation Systems, which can carry out massive changes on program text.

撩起发的微风 2024-09-13 06:05:06

来自 Lisp 的演变 (PDF) (Steele/Gabriel):

3.3 宏

宏似乎是由 Timothy P. Hart 于 1963 年在一份简短的 MIT AI 备忘录中引入 Lisp [Hart, 1963],

参见:

MIT AI Memo 57,Timothy P. Hart,LISP 的宏定义,1963 年 10 月

From The Evolution of Lisp (PDF) (Steele/Gabriel):

3.3 Macros

Macros appear to have been introduced into Lisp by Timothy P. Hart in 1963 in a short MIT AI Memo [Hart, 1963],

See:

MIT AI Memo 57, Timothy P. Hart, MACRO Definitions for LISP, October 1963

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文