From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Chris Vine Newsgroups: gmane.lisp.guile.user Subject: Re: "Missing" libraries/concepts found in other languages/ecosystems? Date: Sat, 11 Jul 2020 11:13:59 +0100 Message-ID: <20200711111359.acacd7d4a6b328bab44ba11e@gmail.com> References: <20200710112109.b2ffa630699452541835924b@gmail.com> <14a24bd8-2664-c7bf-eff8-ca3f4e068ef8@posteo.de> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8572"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sat Jul 11 12:14:39 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 1juCWk-00027f-5v for guile-user@m.gmane-mx.org; Sat, 11 Jul 2020 12:14:38 +0200 Original-Received: from localhost ([::1]:47000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1juCWj-0004T6-0V for guile-user@m.gmane-mx.org; Sat, 11 Jul 2020 06:14:37 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44466) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1juCWQ-0004So-DJ for guile-user@gnu.org; Sat, 11 Jul 2020 06:14:18 -0400 Original-Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:40715) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1juCWO-0008UP-Gx for guile-user@gnu.org; Sat, 11 Jul 2020 06:14:18 -0400 Original-Received: by mail-wm1-x329.google.com with SMTP id f139so8284830wmf.5 for ; Sat, 11 Jul 2020 03:14:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=hG3/G+cKC5/b3P2o+fWo4H/Yx66+iJcLvcsZvZwVEDc=; b=gxPhDfjNbCWByaM8BIs+P+O33wmYf3Gbxol3pBctLHE3Dv2XDk3QLxQbY1DjQe2JWn a/i1gRgOfxNm3nO/eai4dN6omV+zPuUlpLdo9KURw+pAQf7r4+Hrz+ZN9ALkbwLlr7ww GHUYAruTNs0ElCmflbKRU3BUspAYdTGpLjf6ps5V9MZRSrtCq/+SoNnl8AiHU3z5rtiH jkkiLrI/4HOZrQOgSP1bMAf4ZrQ7/VLWC4kQwkZwR7cSdtJWKXtlkhDgzzZ7lLluO4JQ 0Mqv4XwyEKfatWXSZgKI/1SGBmghJD7LTRNh+WdZd1KPEPgISUvzwAo+Bc+RLvCoKgTE Ko2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hG3/G+cKC5/b3P2o+fWo4H/Yx66+iJcLvcsZvZwVEDc=; b=BJjH7wzhD2uKG2sM02bhmchS5pC4G/re2Ch5naTxVxfXnefiiy4lhw67VOycvOz1/l EBXpVlihjCzOO6c7vdcV1hTL/u3iw9U3BhUXaKwrjGifnVXdLs3+pc2nulXRXpxQ44ML j60g4WsIzigjkUzS93ySnxHFAK6Jr6TKeernN47wnzniWWGR890EpD4bC/5cwPkm7xPy KgE6kgIut22cSfh30lDxwfiILagnF8KCLGBwRbglb12rUn0Y0Ak3AzV52DSnHH2ACCKu o1AFeoIO1VnsT5TZGAyAP/S7Z0Rc/D+6nN1ssj5xUXRvzzBRq2vsR2ZCyTNSo4ijXAjn Pf7w== X-Gm-Message-State: AOAM530SehxhC7B/30EjPXFw7e2cUNJlQydRXXjMJQDjaLfxTPFNKbeY 8us5arV0ubpIgY6nSlwHAs2VhHoo X-Google-Smtp-Source: ABdhPJzwP3iCPxrbSwqNP1fSSMnSSwRklx11N/+0GJ44qmb6/FGm4bu/rb5dATOoeOBQ39BYQmC22w== X-Received: by 2002:a1c:2602:: with SMTP id m2mr9868902wmm.50.1594462454648; Sat, 11 Jul 2020 03:14:14 -0700 (PDT) Original-Received: from dell.homenet ([84.93.37.204]) by smtp.gmail.com with ESMTPSA id z25sm11955531wmk.28.2020.07.11.03.14.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jul 2020 03:14:14 -0700 (PDT) Original-Received: from dell.homenet (localhost [127.0.0.1]) by dell.homenet (Postfix) with SMTP id 2AA504241D6 for ; Sat, 11 Jul 2020 11:13:59 +0100 (BST) In-Reply-To: <14a24bd8-2664-c7bf-eff8-ca3f4e068ef8@posteo.de> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-unknown-linux-gnu) Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=vine35792468@gmail.com; helo=mail-wm1-x329.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: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:16661 Archived-At: On Sat, 11 Jul 2020 02:19:43 +0200 Zelphir Kaltstahl wrote: [snip] > I would be glad, if any non-optimal example was extended or updated by a > more knowledgeable person or I was told what I could improve in some > example. The examples in the repository are only, what I was able to > understand and I often find myself looking up, how to do something again. > > If anyone wants to take any example and put it in the docs, go ahead. > Only don't think that my examples are the last word on how to do things. > Far from it! > > About the exceptions thing: Aha! I should look into that again. I > thought the "conditions" thing was already pretty cool and useful. Once > an exception happens, you can react on it. I did not understand the > "call/ec helper" part, but perhaps I can understand it, when I check the > docs for the new exceptions in Guile 3. The issue is that "non-continuable" in "non-continuable exception" does not mean an exception that the program cannot survive, it means an exception for which, after handling, control cannot return to the point at which the exception was raised[1]. (To answer the question in your following email, continuable exceptions are in some sense analogous to common lisp restarts.) Most guile exceptions are non-continuable. 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. With R6RS/R7RS's with-exception-handler, for non-continuable exceptions the handler procedure should normally therefore either invoke a call/ec continuation object to unwind the stack to the point where the exception is handled, or it should (after it has done what it is intended to do) re-raise the exception to be handled and/or unwound elsewhere. Guile-3.0's with-exception-handler procedure will do the former for you automatically if you set its #:unwind? argument to true. The nearest to guile-2.2's catch expression in guile-3.0's exception system is to use with-exception-handler with #:unwind? set as #t. 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. I therefore suggest that your first example using with-exception-handler should set #:unwind? to #t so that the program does not end with a &non-continuable exception. I also suggest that, if intended for guile-3.0 and not guile-2.2, you should use guile's exception objects rather than R6RS conditions (basically you use 'make-exception' instead of 'condition' - the two are in effect the same). If intended also for guile-2.2 the other issue is that its R6RS/R7RS exception procedures can only handle R6RS/R7RS exceptions emitted by raise or raise-continuable, and not guile exceptions raised by throw. This means that your divide by 0 example will not work in guile-2.2. Chris [1] Microsoft in its C++ and .NET languages amalgamates machine exceptions, and some signal exceptions, with language exceptions. In their nomenclature "non-continuable exception" does mean an exception that the program cannot survive, such as SIGSEGV or an irrecoverable hardware exception. This is not however its general meaning. Most languages do not have continuable exceptions. Scheme, common lisp and smalltalk do.