Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

simple example doesn't work #307

Closed
JeNeSuisPasDave opened this issue Sep 5, 2015 · 2 comments
Closed

simple example doesn't work #307

JeNeSuisPasDave opened this issue Sep 5, 2015 · 2 comments

Comments

@JeNeSuisPasDave
Copy link

This simple example from Teach Yourself Scheme in Fixnum Days does not work.

If I put the code in a "hello.scm" file and run picrin hello.scm I get this:

$ picrin hello.scm
error: "uninitialized global variable: 2.16356e-314" 2.16356e-314
  at (anonymous lambda) (unknown location)
  at (anonymous lambda) (native function)

If I type the code into the REPL, I get this:

$ picrin
> (begin
  (display "Hello, World!")
  (newline))
Hello, World!
#undefined
> 

Yep, I'm trying to learn Scheme. Perhaps picrin isn't the best tool for that ...

@KeenS
Copy link
Member

KeenS commented Sep 6, 2015

@JeNeSuisPasDave
That's because picrin is R7RS implementation. Unlike R5RS, R7RS scheme separates functions into libraries and you need to explicitly import them. To run your example, put import like below,

(import (scheme base)
        (scheme write))

(begin
 (display "Hello, World!")
 (newline))

(scheme base) is the basis library and (scheme write) is a IO library. This is R7RS way.
However, if you want to learn R5RS scheme, you can use (scheme r5rs) library, which is compat library to R5RS scheme,

(import (scheme r5rs))

(begin
 (display "Hello, World!")
 (newline))

Bests

@JeNeSuisPasDave
Copy link
Author

Forgot to say "thanks". :-/

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants