Racket 与Scheme 有何不同?

发布于 2024-09-12 07:54:15 字数 126 浏览 5 评论 0原文

Racket 是Scheme 的后代。 Racket 与 R6RS 有何不同?它添加了什么,删除了什么,或者只是有所不同?

我知道 Racket 不仅仅是一种语言,它还是一个语言平台。但我指的是主要的 Racket 方言。

Racket is a descendant of Scheme. How is Racket different than R6RS? What did it add, or take away, or is just different?

I understand that Racket is more than a language, it's a platform for languages. But I'm referring to the main Racket dialect.

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

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

发布评论

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

评论(6

花海 2024-09-19 07:54:15

Racket 最终基于 R5RS,而不是 R6RS,也不是两者的严格超集。我不认为它可以被称为“Scheme”,因为它不向后兼容任何Scheme 标准。

大多数实现都提供扩展,但在其他方面都向后兼容,当然,Racket 附带的编译器也可以在 R5RS 或 R6RS 模式下运行。在球拍模式下运行的有效 R5/6RS 方案可能会被拒绝、导致运行时错误或行为与应有的不同。话虽如此,它不向后兼容的要点是:

  • Racket 没有 set-cdr!set-car!,而是 set-mcar! 仅适用于专门创建为可变的对。
  • Racket中调用的letrec在R6RS中称为letrec*,在R5RS中不存在,R5RS和R6RS中调用的letrec在R5RS中不存在球拍。
  • 在 Racket 中,很多东西都是自我评估的,这会在 R5RS 中引发错误,最重要的是空列表
  • Racket 区分大小写,尽管 R6RS 也区分大小写
  • Racket 将 ( ... )[ ... ] 视为等效,R5RS 不这样做,但 R6RS 这样做。

可能还有更多,但在大多数其他部分,racket 是Scheme 的超集。

Racket is ultimately based on R5RS, and not R6RS and not a strict superset of either. I don't think it can be called 'Scheme' because it's not backwards compatible with any Scheme standard.

Most implementations offer extensions, but are otherwise backwards compatible, of course, the compiler that comes with Racket can also run in R5RS or R6RS mode. Valid R5/6RS Scheme that runs in racket mode may either be rejected, cause runtime errors, or behave differently than it should. With that said, the main points where it is not backwards compatible are:

  • Racket has no set-cdr! and set-car!, rather set-mcar! which only works on pairs specifically created as mutable.
  • What Racket calls letrec is called letrec* in R6RS and doesn't exist in R5RS, what R5RS and R6RS call letrec doesn't exist in Racket.
  • In Racket, a lot of things are self-evaluating which would raise an error in R5RS, most importantly the empty list.
  • Racket is case sensitive, though R6RS is also case sensitive
  • Racket treats ( ... ) and [ ... ] as equivalent, R5RS does not, but R6RS does.

There are probably more, but on most other parts racket is a superset of Scheme.

今天小雨转甜 2024-09-19 07:54:15

如上所述,它包含不可变列表。它还包含一个比 R6RS 记录系统更干净的结构系统。它有一个面向对象的类和对象系统。它具有对合同设计的本机支持。它有一个让人想起ML模块系统的单元系统,以及一个很像R6RS模块系统的模块系统。我确信我已经忘记了我提到过的很多事情。

我不确定重命名除了营销噱头之外还有什么用处,但球拍绝对是一种独特的方案方言。

It contains immutable lists, as mentioned above. It also contains a structure system that is a bit cleaner than the R6RS record system. It has an object oriented class and object system. It has native support for design by contract. It has a unit system reminiscent of the ML module system, as well as a module system much like the R6RS module system. I'm sure I've forgotten as many things as I've mentioned.

I'm not sure that the rename was useful as anything other than a marketing gimmick, but racket is definitely a distinct dialect of scheme.

淡忘如思 2024-09-19 07:54:15

Racket 网站讨论了从 PLT 方案更名为 Racket 的理由。

The rationale for the name-change from PLT Scheme to Racket is discussed on the Racket site.

尾戒 2024-09-19 07:54:15

Scheme编程语言的语言规范R5RS基于多个Scheme实现者之间的共识。这意味着该语言非常稳定。这也意味着许多有用的功能并不属于 R5RS 标准的一部分。

Racket 以 R5RS 为基础,并对其进行了极大的扩展。有些扩展被定义为宏,但有些功能需要运行时系统的支持。

Racket 中的功能不能单独通过宏实现:

  • 分隔连续(比 call/cc 更通用)
  • 连续标记
  • 线程
  • 位置
  • ffi

模块和宏系统比 RnRS 规范更通用。
#lang 阅读器/语言规范一起,可以定义自定义语言(使用自定义语法)并将其与普通 Racket 程序一起使用。

在少数情况下,Racket 的构造的行为与 R5RS 不同。最明显的一个是让 cons 构造一个不可变对(mcons 构造一个可变对)。具有不可变对的一个优点是 length 现在运行时间为 O(1) 摊销时间。

The language specification R5RS on the Scheme programming language is based on consensus between the multiple Scheme implementors. This imply that the language is very stable. It also implies that many useful features are not part of the R5RS standard.

Racket has built upon R5RS and extended it greatly. Some extensions are defined as macros, but some features require the support of the runtime system.

Features in Racket not implementable by macros alone:

  • delimited continuations (more general than call/cc)
  • continuation marks
  • threads
  • places
  • ffi

The module and macro system are much more general than the RnRS specification.
Together with #lang reader/language specification makes it possible to define custom languages (with custom syntax) and use them with normal Racket programs.

In a few cases Racket has constructs whose behaviour deviates from R5RS. The most obvious one is making cons construct an immutable pair (mcons constructs a mutable pair). One advantage of a having immutable pairs, is that length now runs in O(1) amortized time.

淡水深流 2024-09-19 07:54:15

Racket 包含许多 R6RS 方案中未包含的非常好的语言结构,例如 "match"。

Racket includes a lot of really nice language constructs not included in R6RS scheme, like "match".

悲念泪 2024-09-19 07:54:15

举一个重要的例子,默认情况下,Racket 列表是不可变的,而 Scheme 列表是可变的。 Racket还包括许多其他Scheme没有的标准库(例如Web Server)。

For one big example, Racket lists are immutable by default whereas Scheme's are mutable. Racket also includes a lot of standard libraries (e.g. Web Server) that other Schemes do not.

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