Comments (16)
Updated the docs as described and added a new warning, hopefully this is clear enough:
WARNING: exception inside undefined operator: define
WARNING: did you forget to import a language? e.g. (import (scheme base))
ERROR on line 4 of file foo.scm: dotted list in source: (print x . rest)
called from <anonymous> on line 1268 of file ./lib/init-7.scm
called from <anonymous> on line 800 of file ./lib/init-7.scm
from chibi-scheme.
You didn't import define, or any bindings at all, which is why you get
"WARNING: exception inside undefined operator: define"
Obviously if define
is undefined then the expression is treated not as syntax but as a normal function application, where a dotted list is illegal syntax in pretty much every lisp.
Add '(import (scheme base))` to the top of your script to import define.
from chibi-scheme.
I was not able to find this information in the documentation. Maybe I'm missing something but actually, I don't see any Scheme code in docs at all. I would add this as the first thing in the docs on how to use the system. If someone is new to Chibi they have no clue how to use it.
To add: none of the other Scheme implementations, that I was testing, work like this.
from chibi-scheme.
from chibi-scheme.
Correct me if I'm wrong, but Chibi expects a source file to be a "program" in R7RS terminology. R7RS section 5.1 says:
A Scheme program consists of one or more import declarations followed by a sequence of expressions and definitions.
This is not obvious and the error messages are confusing. A specification is not a good tutorial or manual.
from chibi-scheme.
I had added the warning specifically for this case, thinking it was clear enough. Let me add a "Did you forget to import a language?" clause.
from chibi-scheme.
I would add information to the documentation on how to write cross-compatible code.
(cond-expand
(chibi
(import (scheme base)
(chibi)))
(else))
Only Chibi is required to import something to do anything.
from chibi-scheme.
I would add information to the documentation on how to write cross-compatible code.
(cond-expand (chibi (import (scheme base) (chibi))) (else))Only Chibi is required to import something to do anything.
Any conforming implementation of R7RS programs (see section 5.1 in the R7RS) starts with an empty environment unless something is imported. From the cited section: "The initial environment of a program is empty, so at least one import declaration is needed to introduce initial bindings."
This is different to REPL semantics (see section 5.7). Here, the standard says: "For convenience and ease of use, the
global Scheme environment in a REPL must not be empty, but must start out with at least the bindings provided by the base library."
Chibi implements both conforming programs and a conforming REPL.
from chibi-scheme.
Does it mean that only Chibi is a real R7RS compilat Scheme Implementation?
Anyway, this should be in the documentation, since no other Scheme I've tested works like this, so it's at least confusing (especially to newcomers).
I would add a section like this:
R7RS Scheme Conformance
Because the Chibi Scheme is fully compatible with R7RS it requires at least of import of base module to work.
e.g.:
(import (scheme base))
from chibi-scheme.
(cond-expand (chibi (import (scheme base) (chibi))) (else))
A cond-expand
is not necessary if you are targeting R7RS implementations.
(import (scheme base))
works in all of them. (Try it!)
(import (chibi))
is not needed to run portable programs in Chibi.
from chibi-scheme.
Does it mean that only Chibi is a real R7RS [compliant] Scheme Implementation?
It does not mean that.
The issue is confusing because "program" is a common word, but R7RS uses the word "program" in its own exact sense.
R7RS says how its "programs" behave. But RnRS does not cover the command line usage of Scheme implementations. So it does not dictate that chibi-scheme foo.scm
or lips foo.scm
should interpret foo.scm
as an R7RS program. The implementation is free to interpret foo.scm
as something else.
Anyway, this should be in the documentation, since no other Scheme I've tested works like this, so it's at least confusing (especially to newcomers).
+1
from chibi-scheme.
Historically, (import ...)
was added to Scheme quite late, in R6RS and R7RS. import
was not a part of R5RS. That's probably the reason why many Scheme implementations import a lot of stuff by default.
from chibi-scheme.
from chibi-scheme.
Gauche at least detects a source file that starts with (import ...)
and switches to R7RS mode. If the file starts with something else, it stays in its traditional mode. This is slightly confusing, but works well once you know it.
from chibi-scheme.
The Chibi docs are very explicit about being a native R7RS implementation. All examples, scripts and tests in the distribution begin with an import
(as does the sample program in the R7RS spec). I can add an extra note to the docs, but it's more important to make the error message clearer for people who don't read the docs.
As Marc points out, the reason R7RS chose not to provide a default language in programs is explicit control of bindings, to avoid import conflicts and in particular for clean macro semantics.
However as noted above, the Chibi repl does provide a (run-time configurable) default language and you can always load the script in repl mode with chibi-scheme < foo.scm
(or with the -l option).
Note the (cond-expand ...)
suggestion is pointless because it's not needed for R7RS implementations, and if you abandon even R7RS compatibility it's impractical to write useful programs.
from chibi-scheme.
Excellent. Thank you.
from chibi-scheme.
Related Issues (20)
- SRFI 231: fix for interval-contains-multi-index?
- SRFI 231: Fix interval-fold-left HOT 1
- SRFI 231: Fix flatten-vector->list
- SRFI 231: array-append redux
- Installing without sudo on Ubuntu 22.04
- SRFI 231: No error checking in storage-class-data? and storage-class-data->body HOT 2
- SRFI 231: array-inner-product fix HOT 6
- SRFI 231: interval-cartesian-product fix
- SRFI 231: interval-intersect fix
- SRFI 231: generic-storage-class fix
- SRFI 231: specialized-array-reshape issues HOT 2
- SRFI 231: specialized-array-reshape! "fix"
- f16<->double HOT 8
- 0.11 commit DETACHED from master?? HOT 2
- SEXP_USE_MUTABLE_STRINGS 0 is pretty broken HOT 1
- Syntactic closures behave unexpectedly (different from MIT scheme) HOT 21
- `quasiquote` changes renamed `quasiquote`, `unquote`, and `unquote-splicing` identifiers back
- Exposing the supported SRFIs trough (features) HOT 2
- chibi-doc text rendering broken in 0.11 HOT 3
- (chibi app) problems with `app-help-command` in 0.11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chibi-scheme.