This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: should GOOPS be built-in?
Valentin Kamyshenko <val@kamysh.materials.kiev.ua> writes:
> When thinking about the perspectives of Guile, I see its place first
> of all among such tools as tcl/tk, python, and perl. It is fine, that
> it is based on Scheme, which in its standard form is a very condensed
> language, thus, in principle, all what is needed for the beginner to
> begin his work is to read R*RS. Thus, "to sell" guile as an extension
> language it is sufficient to explain what is the module, how to write
> SMOBs, how to call guile functions from C, and how to compile and link
> the program (or/and to load modules dynamically). This could be an
> independent and self-contained part of the documentation. The text by
> Jim Blandy (data-rep.texi) seems to be an excellent introduction to
> the subject, it even gives to the reader an illusion of understanding
> of "how it works" - which is an important condition for smth. to
> become popular :). I would only add there the discussion of
> ALLOW_INTS/DEFER_INTS pairs (by the way, REALLOW_INTS/REDEFER_INTS are
> not mentioned in the documentation at all - I personally do not know
> what do they mean), and would explain how to raise different error
> conditions. Also, scm_must_alloc/scm_must_free must be described here
> in more details.
Actually, they should be drug out into the street and shot ;). But
since we have to live with them right now, I put a section on them in:
http://home.thezone.net/~gharvey/guile/gc-mistakes.txt
That should mostly satisfy the gc questions, as well.
> because I understood in that case what I am talking about; more
> interesting for me could be if somebody explain, why and when should I
> use dynamic-wind :).
Actually, dynamic-wind is a part of r5rs, so rtfm (sorry, but it's not
often you can actually say that wrt guile >;'). Uhm, since I can't
really help myself; basically, you use dynamic-wind to make sure that
certain bits of code are run before and after a certain block. Now,
normally you would just do:
(begin
(foo)
(bar)
(baz))
And everything's fine. But, what if bar captures a continuation (or
could throw an error?)? If you really needed the stuff in foo to be
done before bar, and baz cleans up that stuff, then if you re-enter
bar (or throw out from bar), things are all messed up. So, you use a
dynamic wind
guile> (define foo (lambda () (display "bleah\n")))
guile> (define call/cc call-with-current-continuation)
guile> (define cont-thing ())
guile> (define bar (lambda () (call/cc (lambda (x) (set! cont-thing x)))))
guile> (define baz (lambda () (display "urgh\n")))
guile> (dynamic-wind foo bar baz)
bleah
urgh
guile> (cont-thing 1)
bleah
urgh
1
guile> (define bar (lambda () (error 'foo)))
guile> (dynamic-wind foo bar baz)
bleah
urgh
standard input:23:25: In procedure error in expression (error (quote foo)):
standard input:23:25: foo
ABORT: (misc-error)
Notice how in the first case, when you enter the continuation, you end
up having foo and baz called every time, and in the second case, baz
is called before you go up to the error handler. The value of a
dynamic wind is the value of whatever the second thunk returns.
--
Greg: optionally, dynamic-wind is produced after an encounter with
java beans. Idiot Wind is produced by an encounter with "Blood on the
Tracks".