guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Guile Impressions


From: Martin Grabmueller
Subject: Re: Guile Impressions
Date: Fri, 11 May 2001 07:14:13 +0200

> From: John Fitzgerald <address@hidden>
> Date: Fri, 11 May 2001 16:30:34 +1200
> 
>       > -----Original Message-----
>       > From: Rob Browning [SMTP:address@hidden
>       > Sent: May 11, 2001 08:57
>       > To:   John Fitzgerald
>       > Cc:   'Martin Grabmueller'; 'address@hidden'
>       > Subject:      Re: Guile Impressions
>       > 
>       > Closure for C programmers:
>       > 
>       >   If C had closures, ...
>       >
>       So what do I make of a C function which is supposed to take a
> closure as an argument (e.g., scm_boot_guile())?

Here, `closure' is used in the C-sense, like in Rob's callback
example.  The `closure' paramter is nothing but an opaque pointer
which points to whatever data the programmer wishes.  It is there so
you can communicate from your own main procedure to the procedure
passed to scm_boot_guile().  With this mechanism, you can pass data
through Guile's startup trampoline mechanism without using global
variables.

> 
>       > 
>       > Continuations (continued from above example):
>       > 
>       Have you ever had reason to use continuations in production code?

I have not written much Scheme code for `production', that is which
was released, but in my Scheme utilities I use it sometimes to
implement `escape procedures'.  These are specialized continuations
only used to jump up in the call chain non-locally, just like you
would do with `setjmp' in C.

But recently, I replaced the use of call-with-current-continuation
with throw/catch, because that is simply faster in Guile.

I think most users don't use explicit continuations very often,
because they use the more traditional (and easier to understand)
concepts of threads, exceptions and so on.  Actually I remember having
read that continuations can be used to implement `coroutines'.
Anybody here (born after 1960) who has ever programmed coroutines?

Regards,
  'martin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]