From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: John Cowan Newsgroups: gmane.lisp.guile.user Subject: Re: "Missing" libraries/concepts found in other languages/ecosystems? Date: Sat, 11 Jul 2020 14:20:22 -0400 Message-ID: References: <20200710112109.b2ffa630699452541835924b@gmail.com> <14a24bd8-2664-c7bf-eff8-ca3f4e068ef8@posteo.de> <20200711111359.acacd7d4a6b328bab44ba11e@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="761"; mail-complaints-to="usenet@ciao.gmane.io" Cc: guile-user To: Chris Vine Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sat Jul 11 20:20:51 2020 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1juK7F-000Adi-Bk for guile-user@m.gmane-mx.org; Sat, 11 Jul 2020 20:20:49 +0200 Original-Received: from localhost ([::1]:54190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1juK7D-0001N3-TD for guile-user@m.gmane-mx.org; Sat, 11 Jul 2020 14:20:47 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46982) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1juK74-0001Mt-M0 for guile-user@gnu.org; Sat, 11 Jul 2020 14:20:38 -0400 Original-Received: from mail-qv1-xf34.google.com ([2607:f8b0:4864:20::f34]:46279) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1juK71-0006gw-Ss for guile-user@gnu.org; Sat, 11 Jul 2020 14:20:38 -0400 Original-Received: by mail-qv1-xf34.google.com with SMTP id el4so4066799qvb.13 for ; Sat, 11 Jul 2020 11:20:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ccil-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qNVo6RlfpVrkYvEt+DPvv+nUCZYsOAFtjhx9oxK23pA=; b=tQ288uOhWTdF7xgfYEtlJ9vUDXwg3W/a0ewvv4FW3yk4lkH1z/fnpv5Mchs6V/CnUx L+GYiCQXW7E8uwbnw5UjwUPbWzzx7o9PKlcTYIRegYtEM2pY3E5l+xejiRIL4lmn2Vvf cmUQW0hJ4pyVV82d1sY6BRf4ZImknZEL0DGEo0TLpEKYs9PaXV22qmm/SwzSGfZIsWsX 3iNe94WChdMZSpQqIJ3kqHDip+AENOjMKGOBbis7xRfiOjaRMhl66cZnVOl28oNv7vmj rdZryQGdQy2p4soGsdUx/65AZMSVNFXaZVJhgAqtDZIwecFuiw7wOYJHu3QQmfKAe6n4 /37Q== 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=qNVo6RlfpVrkYvEt+DPvv+nUCZYsOAFtjhx9oxK23pA=; b=GKU3X6sI6Nz7Kroz/1+niohvJP907BVt5Dvb2Mn5pbS8rL00s0VRYFkdaobWDURzQw Lnjacpiy32KOQoI6NuES7kuo8n6oHpR6TW5jBvYbD+guaXg93YsFJ5knqWohRt7RiW4U z5kIAUuTkGjUSU62otlVs8kwZnKehNg5TL8TF4SDXeCpKcCXuno/oWs8iSS/3cKWKEZA 2DaN5ML+KZUrEK3v6VtyWYhWxB8nDaG4DWHi+077hEEcewMlcJUuQg9oMmsJrZzimFod m7sAE2Px08Y0X+E+JX6pnOGgwTIEKs+QfWVgOUNVuVE3W+UVzk+jzcrof6dUnoecO+7o wVxg== X-Gm-Message-State: AOAM531H9ezFxHheD0ikJXBQy0w6pF/fX0ljkyF3Nxbcv2T0YuyemiZZ dG58owOAZlnKKAxydyOuQcncF7pQCuEtW3Lp3enQKQ== X-Google-Smtp-Source: ABdhPJxlrkiQutbhMGKeWGX0MymCwud4OTAv9rOA4R53273IG6lrqScAqUydpzoh6XcctMw3/SSIi3UwLCAXevNfj+A= X-Received: by 2002:ad4:4cc3:: with SMTP id i3mr64346365qvz.114.1594491633938; Sat, 11 Jul 2020 11:20:33 -0700 (PDT) In-Reply-To: <20200711111359.acacd7d4a6b328bab44ba11e@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::f34; envelope-from=cowan@ccil.org; helo=mail-qv1-xf34.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:16665 Archived-At: On Sat, Jul 11, 2020 at 6:14 AM Chris Vine wrote: > (To answer the question in your > following email, continuable exceptions are in some sense analogous to > common lisp restarts.) Continuable and non-continuable in Scheme are exactly like CL raise and error (and its variants), except that the machinery is different. Restarts are another matter, independent of the condition system (though often considered with it). I have a pre-SRFI for them at < https://github.com/johnwcowan/r7rs-work/blob/master/RestartsCowan.md>, similar to but simpler than the CL restart system, and using first-class restarts. It currently lacks restart-case. The point arising from this is that in the case of a non-continuable > exception the handler procedure passed to with-exception-handler must > not return, or a &non-continuable exception will be raised when > control does attempt to return. > In CL the exact machinery is different: a CL handler refuses to handle a condition by returning. A continuable exception must use a non-local exit to get back to the signaler, whereas an unhandled non-continuable exception drops into the semi-standardized facility called the debugger. > R6RS/R7RS's guard form is a wrapper for this which also > incorporates a cond form to enable different exception types to be > handled by different handlers. > Is the intention to provide `guard` in Guile 3.x? I think common lisp restarts are by and large useless. They rely on > the assumption that the caller of a procedure which throws knows better > how to handle an exception arising in that procedure than the procedure > itself. That is rarely the case. Usually the code at the site of the > error should do what it can to remedy the problem and then (if it cannot > be fully rectified) throw an exception which unwinds the stack, for the > exception to be picked up elsewhere. Here's a straightforward example of restarts in action. Suppose a library reads a file in a format known to itself, performs some complex in-memory transformations of the data, and then writes the data to another or the same file in the same format. Of course the files may be inaccessible to the library for whatever reasons, and some kind of recovery is needed. The usual approach is to export three procedures: one to read the input file and return the data in an opaque internal format, one to process the data and return the transformed data, and one to write the output file. Any of them may throw exceptions if something goes wrong. However, this exposes the internal data format to the caller, and requires the caller to strictly follow the input-process-output sequence of calls, a tiny design pattern. With continuable exceptions plus restarts, however, there can be just one exposed procedure which is passed an input file name and an output file name which does it all. If any of the I/O components fail, a continuable exception can be raised which when handled invokes a restart (of type "use-value") with the name of a replacement file name to use instead. As a result, the opaque data is now always concealed from the caller, but a write failure does not require the already-transformed data to be recomputed. Just as a condition communicates information from a signaler (which knows what is wrong) to a handler (which knows what to do), a restart communicates information from the handler (which knows what should be done) back to the signaler (which knows how to do it). John Cowan http://vrici.lojban.org/~cowan cowan@ccil.org All Norstrilians knew that humor was "pleasurable corrigible malfunction". --Cordwainer Smith, Norstrilia