0

I have this file named myprog.scm:

(error "Not found!")

Running the program using plt-r5rs myprog.scm gives an error:

error: undefined;
 cannot reference undefined identifier
  context...:
   /usr/share/racket/pkgs/r5rs-lib/r5rs/run.rkt: [running body]

Apparently, plt-r5rs does not define the error procedure.

  • Why did the authors of plt-r5rs not define the error procedure?
  • How can I define or import an error procedure so that my program can run? Perhaps there's a way to import SRFI-23 Error reporting mechanism?
Flux
  • 9,805
  • 5
  • 46
  • 92
  • Relevant: [DrRacket, R5RS and the error procedure](https://stackoverflow.com/q/3120379) – Flux Sep 04 '20 at 03:45

1 Answers1

0

Why did the authors of plt-r5rs not define the error procedure?

It appears that The Revised5 Report on the Algorithmic Language Scheme does not define a procedure named error. The initial environment created by plt-r5rs contains only the values and syntactic forms defined in the report (except for a handful of implementation-specific forms listed in the docs, like #%require, which are not legal identifiers according to R5RS).

How can I define or import an error procedure so that my program can run? Perhaps there's a way to import SRFI-23 Error reporting mechanism?

As you probably know, R5RS also does not define a module system, so there is no portable way to import anything. For plt-r5rs specifically, this version of your program works:

(#%require srfi/23)
(error "Not found!")

Of course, if you are relying on details of plt-r5rs already, I would suggest just using Racket, or at least R6RS.

LiberalArtist
  • 509
  • 4
  • 13