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,gmane.lisp.guile.devel Subject: expression and definition context in Scheme Date: Sat, 27 Aug 2022 18:48:06 +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="40817"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-user , guile-devel Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sat Aug 27 18:48:50 2022 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 1oRyzK-000AUa-2T for guile-user@m.gmane-mx.org; Sat, 27 Aug 2022 18:48:50 +0200 Original-Received: from localhost ([::1]:43496 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRyzI-0006WO-AZ for guile-user@m.gmane-mx.org; Sat, 27 Aug 2022 12:48:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57992) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRyyv-0006WC-Gk; Sat, 27 Aug 2022 12:48:26 -0400 Original-Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]:35439) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oRyyr-00005B-Nr; Sat, 27 Aug 2022 12:48:25 -0400 Original-Received: by mail-lj1-x236.google.com with SMTP id k22so4269603ljg.2; Sat, 27 Aug 2022 09:48:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc; bh=46whUFHqL27BC4hgJ9WZyis/zgIxgrEOTijhrZk3c+U=; b=RwZm5IdfCXa0QRdwCX1y3+gs5Z02I9gHmUWjiU+rBMAliN+RgZawehVk6jzOjBBtTD vJQPGvdff8yq/Sh+mZYDvWp0p8H4NIZ40YvqHx4/diCXO2JXPIJjXWI/UkUDHqF7eQiQ Fps/KMjbQ2qJK/Ef6Pb7E4/15b15ACIiGHuERRpUj3X0GcfBawcNJ1VnYTFZBaoaKmC5 Tf95JXkP875dEb9IgDyHMqZnj2OOVpBynhsy2Hhh4mCgFshmwt2MukimPQRfpHPRlNto 6+7mjOj7qsGOxcOGIYtZXa7++3Efh7aK9ruB+QdF8va2yX7H3fzpTmWWPxnS/+AqDvye tdoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc; bh=46whUFHqL27BC4hgJ9WZyis/zgIxgrEOTijhrZk3c+U=; b=pngTf70+gVwi6Wo9h18cFhKpZ83dK6ymLF3swytQVH2QeIjcklLlh1b7Ovp3OyHLNR AwySyrhCTrRmum7ZmxuXefPFfBa1hFqyS9easpgJpu7+0jFoztw5A6/I9DWtn5PCEyqm EJNHHUnCYKMSqcbWxRBPmuzsLiPKcFlA4yNoqK5kMrKwOSnSJ74SavthSaqhmvpgxLx9 pi6vXoTsblZg4fkEoaeaf/c9KIJfSsNEZCgc20DgA3Y6AG12UnaiKeO623Cszl76mU3h 7XV/HB05SewT1FEYqq1HnnSKjjWosjd1UKjbT7uHRnR7z20TYnKZ98PMDkguyto3YvO7 EsdA== X-Gm-Message-State: ACgBeo2djpxbnevtbpzYFJ2gIAwNQdEsirdA29OQoEUbSEvwSiQ1b5YN RVjGUh5Hy9qp9SNUR/anmOLCH57OmwiqFdg+EJrOhpsYemY= X-Google-Smtp-Source: AA6agR5WorQvFTNnSsVSGGJpxMveHBjEYziAsQJijcSO1kB3yBK0JeRGcPZJsFCqoaBEJBk0obeY00jia6mL3w79nq4= X-Received: by 2002:a05:651c:1587:b0:261:b558:b6ab with SMTP id h7-20020a05651c158700b00261b558b6abmr3521897ljq.204.1661618897396; Sat, 27 Aug 2022 09:48:17 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::236; envelope-from=damien.mattei@gmail.com; helo=mail-lj1-x236.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 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:18542 gmane.lisp.guile.devel:21331 Archived-At: Hello, i'm facing sometimes recursively the problem to have definitions in expression context, which i manage every time by adding an upper empty (let () my definitions goes here ) the last case i was facing this probleme is defining a 'for macro: ;; scheme@(guile-user)> (for ({i <+ 0} {i < 5} {i <- {i + 1}}) (display i) (newline)) ;; 0 ;; 1 ;; 2 ;; 3 ;; 4 (define-syntax for (syntax-rules () ((_ (init test incrmt) b1 ...) (let () init (let loop () (when test b1 ... incrmt (loop))))))) this one fails in my Scheme+ code below: (define (compute-carries n) (for ( {k <+ 0} {k <= n} {k <- {k + 1}} ) { Ckp1 <+ (compute-Ck-plus1 k) } (display-nl Ckp1))) because { Ckp1 <+ (compute-Ck-plus1 k) } expands in : (define Ckp1 (compute-Ck-plus1 k)) and i get a compilation error: ;;; Syntax error: ;;; logic-syracuse+.scm:15:7: definition in expression context, where definitions are not allowed, in form (define Ckp1 (compute-Ck-plus1 k)) so i replace my 'for macro definition with: (define-syntax for (syntax-rules () ((_ (init test incrmt) b1 ...) (let () init (let loop () (when test (let () b1 ... incrmt (loop)))))))) and it works, but you will notice an abusive use of empty (let () ...) in the code to avoid the restrictions of definitions not allowed in expression context. My ideas is as it is so easy to cheat the compiler from seeing the expressio context why does the compiler restrict this? expression and defintion context, i'm not sure they are in scheme standarts, are they really usefull? why not remove this from Scheme at all? Regards, Damien