From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Damien Mattei Newsgroups: gmane.lisp.guile.user Subject: cond(itionals) with optional execution of statements Date: Sat, 11 Sep 2021 11:14:17 +0200 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="000000000000b1a9a105cbb4a8f2" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32616"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-user Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sat Sep 11 11:14:49 2021 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 1mOz61-0008Oq-8G for guile-user@m.gmane-mx.org; Sat, 11 Sep 2021 11:14:49 +0200 Original-Received: from localhost ([::1]:53978 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mOz5z-0007Jk-0h for guile-user@m.gmane-mx.org; Sat, 11 Sep 2021 05:14:47 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51822) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOz5k-0007JO-TQ for guile-user@gnu.org; Sat, 11 Sep 2021 05:14:32 -0400 Original-Received: from mail-io1-xd35.google.com ([2607:f8b0:4864:20::d35]:42655) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mOz5i-0001cG-Ob for guile-user@gnu.org; Sat, 11 Sep 2021 05:14:32 -0400 Original-Received: by mail-io1-xd35.google.com with SMTP id b10so5480649ioq.9 for ; Sat, 11 Sep 2021 02:14:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=XyxUnCaiw3vVxzOgCpGJVsQjgXrHlOoMPisiJNE7pOY=; b=G4flAJpynokd8F1qSIGQ1qbM/tWDA/GIl3hFPcy4iI8J0BshnWslAWGj2/4U3hiChu uUySAh44u4hWM0wfc1x/XHY5cJsYfR+Ca/6Y6I+2dfGcexJMItON379Ac16bQewXmoWD CsVi5NRw3xvBxn5ZzFAhI9NEHk8RRkHmrDkdWVAtv2RMpLyeeyRC184EstJZLfNqS88P 8pD/KWLrJK4UUwWiojJTUarAV2WR6AKXZeMnJjzf8gmiFZzoSIpr5TwdqzUgi3ReVx+I BQ9PO4GzQHlnroER5ctUBUoIFG4NWII4hEeA4qo1tem8/SEfFZ6V0pzIoWy63M8go5lV kj4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=XyxUnCaiw3vVxzOgCpGJVsQjgXrHlOoMPisiJNE7pOY=; b=H/s/UR/K/+3CL9X6shRWtdabLnfSx7tT0gb7y8/JdL0IgpCaa9Zfo7f9+EB1sbbgCB MnDjwjA7a08H9a6Bw2FugZRiMcEFiWJ+SuIJUyBOBqtZE9VUW20L1ypeKP1Ch63kgex/ bAaPpwbTg8jVpF0atXYZf27UOKwyIuXHYBuKG8Qhd0taPu/6m8Ih4vRHMFmWj0rLpurT Q1XDnidnMRP2GS44K+SvRjYVapuhSvTBcF5JvbdiAejAWeA2G0WGFGBdXu1+8iXO85+/ eJUAH36j+Iu3LOsniB2LBgP6i35uyiz96zebUsrQ0PFf51dRX90TRLEuKkwHCyg5l2EH w1uw== X-Gm-Message-State: AOAM5303sVUqukqu/x/qJa+PPCHWSe08HTbPXK3UIk/shXHOCaUpkAvI fl/vYus5fXLqPXRZUye6oKnCeJPp6Sw1B1xikU3TomUExFFcSw== X-Google-Smtp-Source: ABdhPJw+XWQm5RawJoZjiK9O6yKtU7eKV5j84xNLU/P7O/kZD3R5wXrcIQRIM4yOIxOqPmCEgwYVnVU7gl4xjTiK7oo= X-Received: by 2002:a02:cac2:: with SMTP id f2mr1467327jap.78.1631351668306; Sat, 11 Sep 2021 02:14:28 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::d35; envelope-from=damien.mattei@gmail.com; helo=mail-io1-xd35.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_FROM=0.001, HTML_MESSAGE=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-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:17724 Archived-At: --000000000000b1a9a105cbb4a8f2 Content-Type: text/plain; charset="UTF-8" hello, i wrote a little macro (file condx.scm) that allow : cond(itionals) with optional execution of statements before: (define-syntax condx (syntax-rules (exec) ((_) (error 'condx "No else clause")) ((_ (else e ...)) (let () e ...)) ((_ (exec s ...) d1 ...) (let () s ... (condx d1 ...))) ((_ (t e ...) tail ...) (if t (let () e ...) (condx tail ...))))) use it like that: mattei@macbook-pro-touch-bar library-FunctProg % guile GNU Guile 3.0.7 Copyright (C) 1995-2021 Free Software Foundation, Inc. Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'. This program is free software, and you are welcome to redistribute it under certain conditions; type `,show c' for details. Enter `,help' for help. scheme@(guile-user)> (load "condx.scm") ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0 ;;; or pass the --no-auto-compile argument to disable. ;;; compiling /Users/mattei/Dropbox/git/library-FunctProg/condx.scm ;;; compiled /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.5/Users/mattei/Dropbox/git/library-FunctProg/condx.scm.go scheme@(guile-user)> (define x 1) (condx ((= x 7) 'never) (exec (define y 3) (set! x 7)) ((= y 1) 'definitely_not) (exec (set! y 10) (define z 2)) ((= x 7) (+ x y z)) (else 'you_should_not_be_here)) $1 = 19 i share it to have idea about critics or idea to improve it as it will be part of a Scheme extension to scheme language that will include other features.... have a good day Damien --000000000000b1a9a105cbb4a8f2 Content-Type: application/octet-stream; name="condx.scm" Content-Disposition: attachment; filename="condx.scm" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_ktfkk6dm0 OzsgY29uZHg6IGNvbmQoaXRpb25hbHMpIHdpdGggb3B0aW9uYWwgZXhlY3V0aW9uIG9mIHN0YXRl bWVudHMgYmVmb3JlCjsKOyBleGFtcGxlOgo7KGRlZmluZSB4IDEpCjsoY29uZHggKCg9IHggNykg J25ldmVyKQo7ICAgICAgICAoZXhlYwo7ICAgICAgICAgIChkZWZpbmUgeSAzKQo7ICAgICAgICAg IChzZXQhIHggNykpCjsgICAgICAgICgoPSB5IDEpICdkZWZpbml0ZWx5X25vdCkKOyAgICAgICAg KGV4ZWMKOyAgICAgICAgICAoc2V0ISB5IDEwKQo7ICAgICAgICAgIChkZWZpbmUgeiAyKSkKOyAg ICAgICAgKCg9IHggNykgKCsgeCB5IHopKQo7ICAgICAgICAoZWxzZSAneW91X3Nob3VsZF9ub3Rf YmVfaGVyZSkpCjsKOyAxOQoKKGRlZmluZS1zeW50YXggY29uZHgKICAoc3ludGF4LXJ1bGVzIChl eGVjKQogICAgKChfKQogICAgIChlcnJvciAnY29uZHggIk5vIGVsc2UgY2xhdXNlIikpCiAgICAo KF8gKGVsc2UgZSAuLi4pKQogICAgIChsZXQgKCkgZSAuLi4pKQogICAgKChfIChleGVjIHMgLi4u KSBkMSAuLi4pCiAgICAgKGxldCAoKSBzIC4uLiAoY29uZHggZDEgLi4uKSkpCiAgICAoKF8gKHQg ZSAuLi4pIHRhaWwgLi4uKQogICAgIChpZiB0CiAgICAgICAgIChsZXQgKCkgZSAuLi4pCiAgICAg ICAgIChjb25keCB0YWlsIC4uLikpKSkpCg== --000000000000b1a9a105cbb4a8f2--