[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-users] Binding identifiers with set!
From: |
Category 5 |
Subject: |
[Chicken-users] Binding identifiers with set! |
Date: |
Sun, 12 Oct 2003 10:19:49 +0100 |
User-agent: |
Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (berkeley-unix) |
In <address@hidden> on
comp.lang.scheme, Anton van Straaten pointed out that set! can be used
to introduce new bindings in Chicken:
% csi
; This is the CHICKEN interpreter.
; Version 1, Build 17 - netbsd-gnu-ultrasparc
; (c)2000-2003 Felix L. Winkelmann
>>> foo
Error: unbound variable: foo
>>> (set! foo 1)
>>> foo
1
>>>
This clearly doesn't jive with R5RS (5.2.1):
At the top level of a program, a definition
(define <variable> <expression>)
has essentially the same effect as the assignment expression
(set! <variable> <expression>)
if <variable> is bound. If <variable> is not bound, however, then
the definition will bind <variable> to a new location before
performing the assignment, whereas it would be an error to perform a
set! on an unbound variable.
How do people feel about this? I find the behaviour a bit worrying, as
it amounts to the omission of a basic form of error checking supported
by R5RS as well as every other implementation I'm aware of. I can
imagine situations where this would bite.
My first choice would be to see set! changed to support the more
restrictive semantics, but failing that, I think the current behaviour
should be explicitly documented in the "Deviations from the standard"
section of the manual.
--
- [Chicken-users] Binding identifiers with set!,
Category 5 <=
Re: [Chicken-users] Binding identifiers with set!, felix, 2003/10/13