From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Amirouche Boubekki Newsgroups: gmane.lisp.guile.user Subject: Re: dynamic-wind Date: Sat, 08 Jul 2017 20:03:53 +0000 Message-ID: References: <20170702125831.192ddaec@bother.homenet> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1499544358 20080 195.159.176.226 (8 Jul 2017 20:05:58 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 8 Jul 2017 20:05:58 +0000 (UTC) Cc: guile-user@gnu.org To: Catonano , Chris Vine Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sat Jul 08 22:05:50 2017 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dTvzA-0004kH-BM for guile-user@m.gmane.org; Sat, 08 Jul 2017 22:05:48 +0200 Original-Received: from localhost ([::1]:33940 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dTvzF-0000iR-Oi for guile-user@m.gmane.org; Sat, 08 Jul 2017 16:05:53 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55448) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dTvyt-0000iH-Fd for guile-user@gnu.org; Sat, 08 Jul 2017 16:05:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dTvyq-00028l-8E for guile-user@gnu.org; Sat, 08 Jul 2017 16:05:31 -0400 Original-Received: from mail-pg0-f50.google.com ([74.125.83.50]:36771) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dTvyp-000229-Th for guile-user@gnu.org; Sat, 08 Jul 2017 16:05:28 -0400 Original-Received: by mail-pg0-f50.google.com with SMTP id u62so31623444pgb.3 for ; Sat, 08 Jul 2017 13:05:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=WWXvGWcvOZl7oGNLIyc+Iv+gdZzx3kvm1eeftdElIOk=; b=Qx8Ol6t3zygmqWSohRKHpK95buPDB4OKuKLkGoMbEUR4l1e8VHyqVJ2xv+/O3jGjqc YYX/TwHxtZSrMmn+WXpw+dn2oXykrLkrKuLznibB6D9JoQpFUzn4XoA3Gxy+i2Oj/Agk 9xe6F42NU2YDXmysqkY7rZjwg/gKWRxG1S09lZGkYN+8RgcXYEgZjo412vUh9sjBGubE 7eiCr3W15qypTSZgy4Ch7TjwTkUOGEByWjmTrpL6kQQVa/foGsrEPIl+MlKS04hX+B97 3jYh6xsvtHOVACi3ayveXELqvNLV0kk+Loq2yR44695kBvA9w5pUfQvEwLiGX7zglLC3 jOEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=WWXvGWcvOZl7oGNLIyc+Iv+gdZzx3kvm1eeftdElIOk=; b=FY1j5YNWsHo7oh4Wk2ZyWLWXpLJrRhJVWJTd4So9WVfWRco1apiG9DAkU9uWzULocA eU871+vOX6sn7chMaX2WpMlapRNYSjtnBunTpWRImvR7qZPyVfUk+UN7gGyQkw2cXx6Q Q8XKHX3OooLvsaiuStylashQ+oWdBy8u1CO7Xsk5zgo7v93CfRq0VnjPmIJhsABGSqVA LHP0AFvm+yXr4oIG2GI2Nm/eicx+I7rBLksOyKHEy4P9FrJMaA2zhNd1Ij+nq1lNvQew qIpu8lvYZvkdkQIouBd5S9pJIuVApcQG4S/AbR0c1mhPvU0fNcUWpZP8RdWdpksFEIUD /zdg== X-Gm-Message-State: AIVw111DkR7uPD9gKcnbNYnCnmnvcC8xez9D5fH0Ai71kWMkZhYSFJOk PQW8zfLtPNfvMdoAcHxUwkjtDCjA9Zj8 X-Received: by 10.99.177.78 with SMTP id g14mr7252146pgp.131.1499544244113; Sat, 08 Jul 2017 13:04:04 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 74.125.83.50 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:13907 Archived-At: H=C3=A9llo all! On Wed, Jul 5, 2017 at 8:14 AM Catonano wrote: > My point is that the manual does not a good job of _introducing_ people t= o > the concept of dynamic wind > > Especially people wo have not clear in mind a complete map of the use cas= es > with relative possible solutions. > > The manual tends to be a very good reference for already educated people. > But it's not as good in educating people in the first place, in my view. > Maybe you are right. Maybe [0] is missing some more usecases. I consider dynamic-wind an advanced concept not required for usual hacking. It's like "if you don't know what you are doing, don't use it" [0] https://www.gnu.org/software/guile/manual/html_node/Dynamic-Wind.html#Dynam= ic-Wind 2017-07-02 13:58 GMT+02:00 Chris Vine : > > > On Sun, 2 Jul 2017 08:00:58 +0200 > > > aahh I see now > > > > > dynamic-wind is much more general than just for dealing with database o= r > > network connections, which I think would be a poor focus for the manual= . > > > > I was not suggesting to _narrow_ the focus of the manual > > I was suggesting to use a more mundane example as an _introduction_ to th= e > functionality of dynamic wind > > The current example could still be given, maybe as the last one > > A general principle for the Wikipedia pages is to use an informal > description first and then move on to more formal discssion later in the > page > > To allow both audiences (interested in a quick overview and interested in= a > deeper analisys) to be served > > So I was thinking that the same principle could be used for the discussio= n > of dynamic wind > I agree with you. A small introduction and a deeper look should both make up the manual for each entry. That's said, the current page does in fact have an introduction but starts with some C stuff which I don't understand, which is why I prolly only skimmed over it the first time. Also the whole article only cite call/cc in the example. My understanding now is that dynamic-wind is only useful if you do use call/cc or one of its surrogate. So call/cc should appear be in the introduction paragraph. > That seems to confirm my view that the manual is not a great introduction > You are prolly more informed than me. I learned scheme from r7rs small paper [1] and I use the manual mainly as a reference. [1] http://trac.sacrideo.us/wg/raw-attachment/wiki/WikiStart/r7rs.pdf > > That said, Amirouche observed that in his Wiredtiger access layer, a stat= e > depending on the db is created and when leaving the dynamic wind context > that sould be unrolled > > When reentering it should be properly reproduced > > He also considered taht probably in his case, the oprtions of leaving the > context because of an exception and because of an intentional step should > be treated diferently, as you observed > Indeed, in wiredtiger the with-context procedure which is not perfect, but still does the job is implemented as follow: (define-syntax-rule (with-context env body ...) (let ((env* env)) ;; get or create a context and set it as current *context* value (let ((context (get-or-create-context env*))) (with-fluids ((*context* context)) ;; execute the body (call-with-values (lambda () (begin body ...)) (lambda out ;; push back the context to the context pool (with-mutex (env-mutex env*) (env-contexts! env* (cons context (env-contexts env*)))) (apply values out))))))) (define-syntax-rule (with-context* body ...) (let ((env (fluid-ref *env*))) (with-context env body ...))) (define-syntax-rule (with-env env body ...) (let ((env* env)) (with-fluids ((*env* env*)) (call-with-values (lambda () (with-context* body ...)) (lambda out (env-close env*) (apply values out)))))) It's inspired from ports procedures [2]. Like it tried to explain to Catonano it's wrong to say that all with-fu procedure must be written using dynamic wind. A proof of that is the port procedures in [2]. In fact, if you can't re-compute the state before the dynamic context is escaped, dynmaic wind is useless, which is the case of wiredtiger's with-context. [2] http://git.savannah.gnu.org/cgit/guile.git/tree/module/ice-9/ports.scm > > > > Having said all that, dynamic-wind is not the answer to all cases where > > control leaves a block of code non-locally. It is best suited to cases > > where invocation of a continuation object or the raising of an > > exception fall to be dealt with in the same way, say by releasing a > > resource such as by unlocking a mutex or closing a port. But that is b= y > > no means always the case - the invocation of a continuation object is > > usually a deliberate programmatic strategy, whereas the raising of an > > exception is usually not so and instead represents an unexpected > > failure event of some kind in the program. > > > Wrapping up: I concede that dynamic wind is more general than network or > dbs, and that doesn't even exhaust the whole range of possible cases > (thanks !) > > But the manual could be improved nonetheless (unless it is meant to NOT b= e > a tutorial) > > One last note: Amirouche lost this thread in his email client and asked m= e > to post something so he can recuperate this thread and intervene, perhaps > I figured I have a backup solution in my gmail account...