From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Taylan Kammer Newsgroups: gmane.lisp.guile.user Subject: Re: Does declaration order matter in guile? Date: Sun, 12 Feb 2023 20:52:16 +0100 Message-ID: <3c8f41c0-2978-1ab8-b265-a8ab59030929@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9066"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sun Feb 12 20:52:59 2023 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 1pRIPC-0002Bk-Vq for guile-user@m.gmane-mx.org; Sun, 12 Feb 2023 20:52:59 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRIOf-0008Ex-AZ; Sun, 12 Feb 2023 14:52:25 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRIOd-0008Ek-Lu for guile-user@gnu.org; Sun, 12 Feb 2023 14:52:23 -0500 Original-Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRIOc-0000Bd-1s for guile-user@gnu.org; Sun, 12 Feb 2023 14:52:23 -0500 Original-Received: by mail-ej1-x62f.google.com with SMTP id jg8so27192051ejc.6 for ; Sun, 12 Feb 2023 11:52:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=t1CpuPYARQYSXmWLVHUTHBP6ELY+nra4n9OtQFpPDuY=; b=BWx0huwOs2i+hMRh47qB6ySYNcxZtcdo3Cy/tj7gRaFoVAXtOkqH+C6lu/VHD/wGem 1w1HN+f074qbulgCKKNCfp1hwE3d8weSBZQN+MnJjCU2PS8r/IW1JyI7X+6ZnD+UK8oV 3U3Rejp71pMXSq2AGh7qn6Smhh2NQ7nn0CHEd4Zz9pTV9D6HixA7ywbuv8zgt7yTMQHb xjYbdy0wF9egePotFfIN5QtrkbhBu14qy91/bADfFZBaJV9wfpmf3Ws7jo2NHlNqRsxC CBqsMLG07LoPinAzV9TTanm0UZftlaiYiSTftX7F9yxn6bkzXf10ZOLN0717fT1tCtXg Kg8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=t1CpuPYARQYSXmWLVHUTHBP6ELY+nra4n9OtQFpPDuY=; b=d8JY8CEPOoFLKAKZDYscSuKgEsAxbm4T06yXt752XTlcOKXObwu5WssQzkbv/M48VH 55pVn+vg2zItWI3J5Fnqa1NEda8jUwEPookqg3sNIYs4+OHEwD56+Pni6YvQ1Ckvj1Gb fdEukXJ1deOevtz5fV9lSaFcQBzO89JsV19e+d0OxoISMgg+P28EOINFpP9xFYDXcKHQ hy8cnXn6/roEsCbzRoZUMXIxJvdvVRYWXL5Bh/54HPharRyikvGdkVAzLydT5c4x+CFi JprldYKxwSF4hIjNWgQuht6fpShSoSx0X0gdYTg3e2xusn3XDhuLSad53h9Z8bupP85t OslQ== X-Gm-Message-State: AO0yUKXooiURXLhWhu0i//YU0S3+pYTVZkgYt3lv5q1MEvHhqlQzpllr qH5ObtkURk/V+IPi0OupnBW4uiyBYio= X-Google-Smtp-Source: AK7set/GNESpkHt6TsNkuILP7Q+CzWPA8H6ASWnI7fKpw+9ng4w+gxC2Dcb/XW8lEi4oFhCXuwW3tg== X-Received: by 2002:a17:906:b1d0:b0:88b:a30:25f0 with SMTP id bv16-20020a170906b1d000b0088b0a3025f0mr21903501ejb.32.1676231538832; Sun, 12 Feb 2023 11:52:18 -0800 (PST) Original-Received: from [192.168.178.20] (ip-109-090-125-150.um36.pools.vodafone-ip.de. [109.90.125.150]) by smtp.gmail.com with ESMTPSA id hk12-20020a170906c9cc00b008b10d5b092csm859559ejb.119.2023.02.12.11.52.17 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 12 Feb 2023 11:52:18 -0800 (PST) Content-Language: en-US In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::62f; envelope-from=taylan.kammer@gmail.com; helo=mail-ej1-x62f.google.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 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, NICE_REPLY_A=-0.348, 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.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-bounces+guile-user=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.user:18903 Archived-At: On 12.02.2023 19:46, wolf wrote: > So, I have few questions I would like to ask: > > 1. When does order matter? What is going on here? Heya. The order matters in this case because the SRFI-9 implementation in Guile defines syntax (macros) rather than just variables bound to procedures. If you use an undefined variable in a lambda body like '(define (blah) )' then it will be compiled into a variable lookup in the global environment, so you can make it work by later defining that variable to something appropriate. However, the "macro expansion" needs to happen immediately, so what happens here is: 1. (foo y) is compiled into code that will: - Look up the global variable 'foo' - Try to "apply" its value to the value of 'y' 2. You then bind 'foo' to a "syntax transformer" (macro) in the global environment. 3. When the code is executed, it tries to apply the syntax transformer as if it were a procedure or another type that can be "applied," which fails, because syntax transformers are not a type that can be "applied" like procedures and such. (The error message would be clearer if it said "is not a procedure" instead of "wrong type to apply" but there's other types in Guile that can be "applied" and not just procedures, hence that slightly less clear error message.) What *needs* to happen for it to work instead, is: 1. You bind 'foo' to the syntax transformer. 2. During the compilation of (foo y), the compiler calls the syntax transformer to affect the generation of code, so it will do the right thing. > 2. Why does guile recommend SRFI-9 over the R6RS records? They seem less > verbose and more robust. At least to novice like me. SRFI-9 is smaller and more widespread. Ultimately, it's a matter of taste, since both have advantages and disadvantages, and some things that are either an advantage or a disadvantage depending on who you ask. :-) > 3. What does guile implement by default? There are --r6rs and --r7rs arguments, > what scheme is used when neither is supplied? R5RS? Sorry if this is stupid > question, the scheme landscape seems... complicated. No worries, not a stupid question at all. What Guile uses by default could be called "Guile Scheme." It neither completely fulfills the requirements of R7RS or R6RS, nor is it limited to either. I think that's what most Scheme implementations do... The standardization of Scheme is in a sad state. > 4. Is the (install-r6rs!) global and affecting all reading from that point on > or is it scoped to the file being currently read? I ask because I am curious > if I can mix files using R6RS and R7RS in one program. I'm not 100% sure on this one, but I don't think it can affect the reading of the file it appears in, because the entirety of reading happens before anything is executed. It should affect *explicit* reading you do from that point on, i.e., what the 'read' procedure will do with its input. > Thank you very much, > W. > You're welcome, and have fun with Guile! -- Taylan