unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Re: dynamic-wind
@ 2017-07-09 12:59 Chris Vine
  2017-07-09 14:09 ` dynamic-wind Vítor De Araújo
  0 siblings, 1 reply; 14+ messages in thread
From: Chris Vine @ 2017-07-09 12:59 UTC (permalink / raw)
  To: guile-user

On Sun, 09 Jul 2017 00:34:13 +0300
Marko Rauhamaa <marko@pacujo.net> writes:
> Hm. Python's try/finally has several uses in virtually every
> program.
>
> Trouble is, Scheme's continuations make it impossible to know when
> something is really final.  
> 
> In fact, implementing coroutines and cooperative multitasking using
> continuations almost guarantee a repeated back-and-forth through
> dynamic-wind.
>
> I strongly suspect Scheme's continuations are more trouble than they
> are worth.  

I disagree with that.  On the first point, you know that a
dynamic-wind block can no longer be re-entered (if that is what you mean
by "really final") when the continuation object concerned is no longer
accessible.  At that point it, and all references to other objects
encapsulated by the continuation, will be released in the ordinary
way.  You also know the same when your continuation is only an escape
continuation.

Secondly, this is something of an irrelevance.  I have found it very
rare that one would want to use dynamic-wind when implementing
co-operative multi-tasking with coroutines (at any rate,
https://github.com/ChrisVine/guile-a-sync only does so for thread pool
thread counts, and that is to cater for exceptions in local code rather
than for jumps via continuation objects).  Jumping out of a
dynamic-wind block using a coroutine is generally inimical to the kind
of asynchronous programming that coroutines are used for: you generally
don't want to unset the state of the continuation, and then set it up
again when you re-enter.  You normally want to leave it just as it was
at the time you yielded.

I may be mistaking you for another poster, but I think you have
previously said that you prefer the inversion of control ("callback
hell") style of asynchronous programming to using coroutines.  You
would not usually think of using dynamic-wind there either, I hope.

Scheme's continuations are very useful.  Guile's delimited
continuations are even more so.  Dynamic-wind not so much, because it
is a very blunt instrument.

Chris



^ permalink raw reply	[flat|nested] 14+ messages in thread
* dynamic-wind
@ 2017-06-30 20:33 Catonano
  2017-06-30 21:48 ` dynamic-wind Panicz Maciej Godek
  0 siblings, 1 reply; 14+ messages in thread
From: Catonano @ 2017-06-30 20:33 UTC (permalink / raw)
  To: guile-user

On the irc channel I was suggested that it might have been a good fit for
my use case

I took a look at it in the manual

I'm perplexed. I don't understand it

How is it supposed to be used ?

The provided example is somewhat contrived, I couldn't understand it anyway.

My use case is basic, really.

I have a scheme wrap around a C library for reading xls files, freexl.

Freexl uses a pointer to a structure tha represents the opened xls file and
its contents

Each function writes/reads in the memory region pointed to such pointer.

In the end, it requires to use a function that closes the file AND frees
all the involved structures in memory.

So my idea was that I would have gotten a simple macro, like this

(with-xls-file "path/to/my/xls-file.xls" handler-ptr
   (do-something handler-ptr)
   (do-something-more handler-ptr))

and this would have expanded to

(freexl-open "path/to/my/xls-file.xls" handler-ptr)
(freexl-do-something handler-ptr)
(freexl-do-something-more handler-ptr))
(freexl-close handler-ptr)

Do I need dynamic-wind at all ?


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2017-07-17 10:04 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-09 12:59 dynamic-wind Chris Vine
2017-07-09 14:09 ` dynamic-wind Vítor De Araújo
2017-07-09 14:49   ` dynamic-wind Chris Vine
2017-07-17 10:04     ` dynamic-wind Catonano
  -- strict thread matches above, loose matches on Subject: below --
2017-06-30 20:33 dynamic-wind Catonano
2017-06-30 21:48 ` dynamic-wind Panicz Maciej Godek
2017-07-02  6:00   ` dynamic-wind Catonano
2017-07-02  6:01     ` dynamic-wind Catonano
2017-07-02 11:58     ` dynamic-wind Chris Vine
2017-07-05  6:14       ` dynamic-wind Catonano
2017-07-05  8:23         ` dynamic-wind David Kastrup
2017-07-08 20:03         ` dynamic-wind Amirouche Boubekki
2017-07-08 21:34           ` dynamic-wind Marko Rauhamaa
2017-07-09  7:21             ` dynamic-wind David Kastrup

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).