5

I'm working though SICP and wanted to try out some of the examples in guile. I'm trying the stream examples and wanted an implementation for cons-stream, which I got from this StackOverflow question. However when I type this into guile I get:

guile> (define-syntax cons-stream
  (syntax-rules ()
  [(cons-stream x y) (cons x (delay y))]))
ERROR: invalid syntax ()
ABORT: (misc-error)

I have no idea what's wrong with this - I've tried replacing () with '(), removing the [ ], but it still doesn't work even though it seems to be valid R5RS. I'm currently on guile 1.8.7, I can't see a package for v2.0.1 which the GNU docs mention, could this be why its not working for me?

1 Answer 1

8

Looks like you need to import support for syntax-rules first (see http://www.gnu.org/software/guile/docs/docs-1.8/guile-ref/Syntax-Rules.html):

(use-syntax (ice-9 syncase))

Then you need to change the square brackets to parens; after that it should work.

Definitely don't quote the literals list; that's a sequence of identifiers, like lambda formals, not an expression.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.