From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Aleix_Conchillo_Flaqu=C3=A9?= Newsgroups: gmane.lisp.guile.user,gmane.lisp.guile.devel Subject: Re: expression and definition context in Scheme Date: Wed, 7 Sep 2022 16:12:11 -0700 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20052"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Damien Mattei , guile-user , guile-devel To: =?UTF-8?Q?Linus_Bj=C3=B6rnstam?= Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Thu Sep 08 01:12:44 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 1oW4Dr-00051r-R1 for guile-user@m.gmane-mx.org; Thu, 08 Sep 2022 01:12:43 +0200 Original-Received: from localhost ([::1]:51624 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oW4Dq-0003Yn-3S for guile-user@m.gmane-mx.org; Wed, 07 Sep 2022 19:12:42 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34372) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oW4Da-0003XJ-3L; Wed, 07 Sep 2022 19:12:26 -0400 Original-Received: from mail-ua1-x931.google.com ([2607:f8b0:4864:20::931]:33447) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oW4DX-0003k0-RX; Wed, 07 Sep 2022 19:12:25 -0400 Original-Received: by mail-ua1-x931.google.com with SMTP id z26so2416512uaq.0; Wed, 07 Sep 2022 16:12:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=CeEtls6wmW3Y50xT6CsxBsdAQDsV1xVYMFfC7cnGOAY=; b=mm8qXKkJmVzDrk+c2nX1h9S1zfgLsLAN0jH49DH0tEzLQJL96vHD9kycsTuuLjdyhq xErdmqkhd6uKeqEnXuBZqEw9Ds2OlJOI/DeZ6Sxctn8DX9HR4LfvlbCynBltIMo0XN/k SKcPk+iFoDm4Q2uefl6evyADcJtNrfSGa8YhGiawA8jffv+30ootkvFZzWAO39Olimnq +DUOH1+BRSHDeKye+HrYl5ol4OMXWLQQUep8jdnW6yBHcwt8zfPInD1h24FfPi4iv1qu KhEeXjCSDXyJVITidqVwZLVCNeI0K0WzNs6VJrWBJb2tvGi/vCtzW0vuLFNCOnfxwg/o nKPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=CeEtls6wmW3Y50xT6CsxBsdAQDsV1xVYMFfC7cnGOAY=; b=rN6oFM6OqjrR/TDOt9h+CcmRi27ylDLw4cthv7AfsDMJWYgNCea+pLPdcDuBV2cklr fQ5qsk8NMCzIuJtSDxUxQL2n0ZUdNWYgcU5gyDd1p6qFgO8cZs4Lt+y07IGxSRggHaRA td9KsoLI+VmDlWOQIdAt0U42Jmz8srh+27eAC1gYqjITNm9MQ8BjZoKxlBcuKFW8Dadv gieR1Wpc3khCVyktzwex12bMVPkdQeBUUxIotcsR0vlMux0s7CYVtUtSszZQismu7GQJ 80YK19JGhUBsyw7vSKk76gxvEnAWwEbT5+wKTRVpR/0PLSjaorbfNmqszKb8Dr8ZGt7N JcLg== X-Gm-Message-State: ACgBeo1aLMjpaES8FYk4xW7yGqLIkO/fb8631MtIG6rUEdFmHO7CxaWM 3QNLPiCdgX9kNgmLXJa0m8ODpFzr/Fm0vU2jrdc= X-Google-Smtp-Source: AA6agR7z3w/gicukMqPCkZU6rfezv5DNhb0CQV04Nx5wcY9Evz+bUa/rUfbGis4IMLZUtYCPqi8g9sSQ7E3elrKPHEQ= X-Received: by 2002:ab0:4846:0:b0:3a6:236d:f57e with SMTP id c6-20020ab04846000000b003a6236df57emr2059481uad.41.1662592342110; Wed, 07 Sep 2022 16:12:22 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::931; envelope-from=aconchillo@gmail.com; helo=mail-ua1-x931.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:18574 gmane.lisp.guile.devel:21342 Archived-At: Just came here to say: Congratulations Linus! That was definitely the most important part of your message :-). Aleix On Tue, Aug 30, 2022 at 3:48 AM Linus Bj=C3=B6rnstam < linus.bjornstam@veryfast.biz> wrote: > I am working on a patch to guile to add definitions to just about every > body except for (begin ...) outside definition context. > > The patch is trivial, but I have to document it and a patch to r6rs that > makes the r6rs cons work according to spec. > > I had a kid recently so it might take some time before I have any compute= r > time, so if anyone has some time this is a really simple thing. You can > find the first patch somewhere in this mailing list, it only changes the > (begin ...)s in the derived forms in (ice-9 boot-9) to (let () ...). Then= i > was going to copy the cond and case from the r6rs appendix and add some > error reporting. > > The most difficult part is documenting it :) > > Andy have the idea hos blessing, and will mean guile gets define in > expression context in when, unless, cond, case, while, and do as well as = in > derived forms. > > -- > Linus Bj=C3=B6rnstam > > On Sat, 27 Aug 2022, at 18:48, Damien Mattei wrote: > > 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 <=3D 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 > >