Just started learning Scheme.
I’m using Dr. Racket as my compiler/interpreter.
I need some String functions (string-replace to be exact), so I copied from SRFI 13.
When I test it, it shows..
reference to undefined identifier: let-string-start+end
That’s defined with
define-syntax let-string-start+end
It seems that it’s being ignored? What’s actually happening?
You don’t need to manually copy and paste items from SRFI 13: it is built into Racket. In fact, most of the major SRFI libraries are bundled with Racket: http://docs.racket-lang.org/srfi/index.html
If you are using the r5rs language in Racket, you can pull in SRFI 13 with the following line:
The strange-looking
#%requireis a Racket-specific hook that allows an r5rs program to load library modules from Racket.So an r5rs program in Racket would be something like this:
If, instead of using the basic
r5rslanguage, you use the full-fledged#lang racketinstead, importing SRFI 13 would look similar. Here’s a small program in#lang racketthat does the same as the previous program:Unfortunately, the error you’re reporting doesn’t have enough information to accurately diagnose the problem. I suspect an incomplete copy-and-pasting somewhere, since you mention that you copied from SRFI 13. One reason why I think you may have mis-copied the code is that you mention defining it with:
and that line is actually missing some crucial parentheses; in the original source, there’s a leading paren at the front of that line.
But you shouldn’t try to cull bits and pieces out of the SRFI implementation by hand, at least not until you’re more familiar with Scheme. Simplify by loading the entire library.