0

A 4-year-old old post suggests that one might be able access the current-seconds and related functions in the r5rs language.

Here's why I ask: I'm a high school teacher new to Racket and we are using the r5rs language. I would like to introduce students to functions by starting with a function that needs no arguments to make sense. The example that occurs to me is minutes-past-the-hour. But I am ignorant of how to make those functions recognized in an r5rs program.

Thanks for any helpful advice.

4

1 回答 1

1

首先,为什么不用#lang racketr5rs来代替呢?球拍在很大程度上考虑到了教育。它甚至有多种教学语言可用于“如何设计程序”教科书(或其第二版,仍在编写中)。


Racket 对 R 5 RS 的实现是有意限制的——它通常不打算用于任何实际的事情,因为 Racket 本身已经超越了它的 Scheme 根源。它可以用作教学工具,但正如您所见,它不包括任何特殊的扩展(除了一小组内部形式)。

如果您真的对使用 R 5 RS 方案感兴趣,则存在SRFI 19 的实现:与 Racket 捆绑的时间数据类型和过程。R 5 RS 没有模块系统,因此在纯 Scheme 中没有正式指定的加载外部库的方法。您需要使用 Racket#%require扩展来加载 SRFI 实现:

(#%require srfi/19)

这将使您能够访问所有 SRFI 19 功能和值。

您也可以只包含您想要从 Racket 本身获得的功能,因为这些语言实际上是可互操作的。要包含current-seconds,您需要执行以下操作:

(#%require (only racket/base
                 current-seconds))

但是,如果您要这样做,那么使用该r5rs语言似乎几乎毫无意义。只需使用racketorracket/base代替。

于 2015-03-09T01:12:55.170 回答