This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: First try at using guile -- erk!


Telford Tendys <telford@eng.uts.edu.au> writes:

> Opening my scheme book at a random page and invoking the guile
> program to test out a simple scheme example, I type:
> 
> (define 'value 2112)
> 
> My scheme book says this should give an error but doesn't
> say which error exactly, guile gives no error at all but
> something seems strange because when I try to quit with ^D,
> I find myself in an endless loop of:
> 
> ERROR: Unbound variable: debug
> ERROR: Unbound variable: debug
> ERROR: Unbound variable: debug
> ERROR: Unbound variable: debug
> ERROR: Unbound variable: debug
> ERROR: Unbound variable: debug
> ERROR: Unbound variable: debug
> 
> Am I off to a bad start here?
> Should I stick to examples that are not supposed to give errors?

What happens above is the following:

At Guile startup you are in the root module.  This is the name space
where most of Guile's predefined macros and procedures live.

  (define 'value 2112)

is expanded to

  (define (quote value) 2112)

which means

"define a procedure with name `quote', argument `value' and body 2112".

Since you are in the root module, the effect is that you redefine a
fundamental component of the language itself => the internal
mechanisms of Guile break down.

My advice to you is that you shouldn't worry much about this problem.
This kind of thing only happens when you redefine builtins.  If you
want to be safeguarded against that, you can type:

 (define-module (user))

before starting to play around in Guile.


What Guile developers should do to amend this:

There is obviously something which is wrong with Guile here.

I think it is OK to be able to redefine builtins, but that should not
break the interpreter.

If the user isn't put in the root module when Guile starts, but in a
"user module", the above wouldn't break the interpreter.  (If, in
addition, the module system had the possibility to mark certain
bindings as "read only", it would be even better, but we have to wait
until we get a new module system for that.)

/mdj