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: syntax-case equivalent to syntax-rules Date: Sun, 29 Aug 2021 13:29:19 +0200 Message-ID: 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="15877"; mail-complaints-to="usenet@ciao.gmane.io" Cc: julien.provillard@unice.fr, Jean-Paul Roy To: guile-user Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sun Aug 29 13:29:57 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 1mKJ0f-0003t1-9u for guile-user@m.gmane-mx.org; Sun, 29 Aug 2021 13:29:57 +0200 Original-Received: from localhost ([::1]:37240 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mKJ0d-0001zu-Q3 for guile-user@m.gmane-mx.org; Sun, 29 Aug 2021 07:29:55 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45786) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mKJ0J-0001zl-FB for guile-user@gnu.org; Sun, 29 Aug 2021 07:29:35 -0400 Original-Received: from mail-io1-xd36.google.com ([2607:f8b0:4864:20::d36]:39750) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mKJ0G-00024r-TK for guile-user@gnu.org; Sun, 29 Aug 2021 07:29:34 -0400 Original-Received: by mail-io1-xd36.google.com with SMTP id m11so7279380ioo.6 for ; Sun, 29 Aug 2021 04:29:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=qv2YBm4pguuXpP+vnZdITwGeO8RRkVkWKOMMYmKkdqM=; b=Zdqroik/nYalVXosjvis0qetebHW77TMJRVOOAqsGkiOIjgMU9NAt1xQO06CC9I+ne vUgLF3PMmqhuF2vrn2BH1FXAU97v48iQWx+YFa7GosWcxaUllgD4evDWNWGxzeuNARDp UgUPn9KNMGQVTvOw9dVJ71GDhHhsir0xQIs/DJZX655IiswZjbqWfi3HRss5UnjoZXDV vmOgZUDrB0R3DJcvSXjJp39/jBIk161+vmYCntSY1Bxi11VjJrcFyuL5+S9okt/67zKE renxl/mf2GIQmocnTAkOUBtKyvvkBtfMcrZkPQkjtu+gCxr+CvQPnfEtjYnDNJO5UIOI WRlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=qv2YBm4pguuXpP+vnZdITwGeO8RRkVkWKOMMYmKkdqM=; b=gOEc4QQatJ2LzZhS9AJ6rvi4bQknE9x24FL37ZlvxkM9tTGcjkOMnG2jlqtmzq8935 cDUG0WZLY91fQeI5i+u2FZoYJJunYZlKDIlxnNcQFt2Wx89xchxcvkPIIkaDlUNhLxeE Drkt/2o8C6C8fxINY92/rgJfl4ydKu50+w9Z/f+aqu2l9u2bNfTo6izXjERHEHiHDI1e kiWYZbvVPuhOHygHZsA3eysDtw6SRvv5E8lFmDiVaDm4PCNzb08Va0p76gYba9KKv7/q lB64zebwVLzrdSNPRSipy6m0vkQkY5jD09XmTx5sIUufUt5smlIvAE10ql9XqQgk3oHN ZjHg== X-Gm-Message-State: AOAM531FnhtsS3HZlDTI6TBwl89yBazDNBlFtzmdmB7JPrimnRXwHVzS +90pjYDogRU7db4eYCtTFXxMYyu1Y3lbuL16Pt7cdQasp8Q3VQ== X-Google-Smtp-Source: ABdhPJzGSJaFEApWT9u85o5NTwofOho/XXZOja0lwntDBvzoQq2Z3oApcfgKzWEN49+jeK/dtFZK4fjc2Zs2mOfNdXs= X-Received: by 2002:a5e:8349:: with SMTP id y9mr9218660iom.34.1630236570855; Sun, 29 Aug 2021 04:29:30 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::d36; envelope-from=damien.mattei@gmail.com; helo=mail-io1-xd36.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:17702 Archived-At: hello, i write a macro that needs both the features of syntax-rules and syntax-case based on documentation: https://www.gnu.org/software/guile/manual/html_node/Syntax-Case.html i have : ;; scheme@(guile-user)> (def (foo) (when #t (return "hello") "bye")) ;; scheme@(guile-user)> (foo) ;; "hello" ;; (def x) ;; TODO: study def of a recursive function (define-syntax def (lambda (stx) (syntax-case stx (declare) ;; definition without a value assigned ;; (def x) ((_ var) #`(define var '())) ;; (def x 7) ((_ var expr) #`(define var expr)) ;; added body body* ;;((_ (declare var1) * ...) #`(letrec ((var1 '())) * ...)) ;; 'compiles' but do not have the expected behavior: ((_ (declare var1 ...) ...) #`(letrec ((var1 '()) ...) ...)) ;; (def (foo) (when #t (return "hello") "bye")) ((_ ( ...) * ...) (let ((ret-id (datum->syntax stx 'return))) #`(define ( ...) (call/cc (lambda (#,ret-id) * ...)))))))) and def2 that have the good behavior: scheme@(guile-user)> (def2 (declare x y z) (list x y z)) $1 = (() () ()) (define-syntax def2 (syntax-rules (declare) ((_ (declare var1 ...) ...) (letrec ((var1 '()) ...) ...)))) i want to merge def and def2 in a single macro any solution? Damien