From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: wolf Newsgroups: gmane.lisp.guile.user Subject: Re: Does declaration order matter in guile? Date: Tue, 14 Feb 2023 21:00:47 +0100 Message-ID: References: <3c8f41c0-2978-1ab8-b265-a8ab59030929@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="CUs55bi8b9dao7Yq" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19363"; mail-complaints-to="usenet@ciao.gmane.io" Cc: guile-user@gnu.org To: Taylan Kammer Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Tue Feb 14 21:01:33 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 1pS1UZ-0004qc-9D for guile-user@m.gmane-mx.org; Tue, 14 Feb 2023 21:01:31 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pS1U4-000392-1j; Tue, 14 Feb 2023 15:01:00 -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 1pS1U2-00038f-Ls for guile-user@gnu.org; Tue, 14 Feb 2023 15:00:58 -0500 Original-Received: from wolfsden.cz ([37.205.8.62]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pS1U0-0006kz-AS for guile-user@gnu.org; Tue, 14 Feb 2023 15:00:58 -0500 Original-Received: by wolfsden.cz (Postfix, from userid 104) id 45B8B1EFF66; Tue, 14 Feb 2023 20:00:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1676404849; bh=PtDyOUp1IzUWiX3Q8hXhEZ/GXnG5Bb/GBua7QBIfOw4=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=MDHTYayMmnP+10COQ7x0IoVeTGpUR5kqQRNLusWPH+qTthSK6UCE/01IiThAWNKh+ Gq1LS+3WwP+PGFk/xcGblbIyxFdW2VSGYT2wefzAm/PbAuUHcwdSem3URgixnh/Ef7 U/DOVnS9hZPJQHsGDrrfFlc/sL7uHBM9KEM50xHKEuTUOBXTzg7IoxtN5ZNajEfBm9 d6BYpLQ6UCuOwTYU2aDVcOinDPk2niwr1rzoyTQciAyRirTKVYwojw9YkilPs/Z4c1 tX2y4CPkyAUWgl4HIxJIcYVs2jY2ryx+xrcLTeJ04Z2cN03BgOI08AiqKoFOHBZYQM xDHqx8x5Ig3k8dqsKaBl+ZAGoAgE+mkMTyzVIs8p15SRR4D8IqmtZQ7XkNosAv7J6s havO/vTsukFJxW/YtfhXdEimabmQMdxBmf7VM9Nk0jRMMAOfqQRbJups+jpy4+s4/Y lOpigTTqO/gnzCTEgTXUMaNQioaO0eeVroOZgef2mzX6PQVuEMqAFvxLoomtYnfr12 VagVR0ZDgAOVixXlg+xrD80BlRwKZ4H5HJqiLmIMsuVqpbwv5FQU/bAgGucALQmjAa 35y6Zxn5VBHWgHLKIUnmkAI8tZZ8Z/q7eklc8nW0Jp46OtBbNvsDFjUZXSNIvQbJCF 1HSW6L7nKcIt3fkXasGpCe8s= Original-Received: from localhost (unknown [128.0.188.242]) by wolfsden.cz (Postfix) with ESMTPSA id 6B00C1EFF64; Tue, 14 Feb 2023 20:00:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1676404848; bh=PtDyOUp1IzUWiX3Q8hXhEZ/GXnG5Bb/GBua7QBIfOw4=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=XR7enFAD714ZV5NFaVAdzXxdzOxoUod1Kb0Me0M8PhWNSgtMuV6Q3IjY+wbN5X/NS zELed4TUmaave+f5BMNc2DQe7qmJv67ATYsKtYvagpN8JqPJRsg7TLN6D1l8boTyFa tYC+kfu9FwsbUN//ZY3AhlgDt6vkY4WldkBGF4TmAxRtgL9yc+HspgqO1/l7UBfOKS JoP7zEfNX5pAK3fPBCn1qR4tYE96ZTrKdCJzMpytOG7joKdbba7SaDlzmSxpQElBvG 5QKtA98oIZnYwOYHfOPwTyGGTERiXhGOGUP1PrT4NFu6aNHHQJT0KzXzjCy1XlH3tR EO2u6YPAfQubxx3w1hM6sjWasZDlLD48NBLV/tWhCcFc18egpe5GHhPBGeWCe+HF15 yrD5yqyfEPPGuAkutj/RqkzJeZhXMDlozXhwT6+TpO282AZvJbcA4llIv92Fy2XEXW dCJXIaK7vXhzL4zsqJIvf6dBWA/mzuMvBazYiHPR3jf3lkVZr/qHulTihfwUQBENAd 4GInusA4Qcq+ZPBt6HaMACjZH32TI/IoQzO9Z+aRVlt6xEqS2/GzF2izM7uBVwBc4n 0ANgGF3hw1r/681aqtQXJgnrqBk9QSTCj0fWmOj9OZQVanCIa5qxS+K/tMk9y21D1z xDXcPe75qo5lGeVVrH5QOxbo= Mail-Followup-To: Taylan Kammer , guile-user@gnu.org Content-Disposition: inline In-Reply-To: <3c8f41c0-2978-1ab8-b265-a8ab59030929@gmail.com> Received-SPF: pass client-ip=37.205.8.62; envelope-from=wolf@wolfsden.cz; helo=wolfsden.cz 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, SPF_HELO_PASS=-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:18908 Archived-At: --CUs55bi8b9dao7Yq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello, first, let me thank you for thorough explanation, it helped and I (hopefull= y) now have better understanding. Few more questions are below. On 2023-02-12 20:52:16 +0100, Taylan Kammer wrote: > On 12.02.2023 19:46, wolf wrote: >=20 > > So, I have few questions I would like to ask: > >=20 > > 1. When does order matter? What is going on here? >=20 > Heya. >=20 > The order matters in this case because the SRFI-9 implementation in Guile= defines > syntax (macros) rather than just variables bound to procedures. >=20 > 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. >=20 > However, the "macro expansion" needs to happen immediately, so what happe= ns here is: >=20 > 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' >=20 > 2. You then bind 'foo' to a "syntax transformer" (macro) in the global en= vironment. >=20 > 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, becaus= e syntax > transformers are not a type that can be "applied" like procedures and = such. >=20 > (The error message would be clearer if it said "is not a procedure" inste= ad 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.) >=20 > What *needs* to happen for it to work instead, is: >=20 > 1. You bind 'foo' to the syntax transformer. >=20 > 2. During the compilation of (foo y), the compiler calls the syntax trans= former to > affect the generation of code, so it will do the right thing. >=20 Interesting, I think I understand the difference. So in some ways this can = be compared to the C pre-processor? Is there a way to view the resulting code after all the transformations were applied? > > 2. Why does guile recommend SRFI-9 over the R6RS records? They seem less > > verbose and more robust. At least to novice like me. >=20 > SRFI-9 is smaller and more widespread. Ultimately, it's a matter of tast= e, since > both have advantages and disadvantages, and some things that are either a= n advantage > or a disadvantage depending on who you ask. :-) >=20 > > 3. What does guile implement by default? There are --r6rs and --r7rs ar= guments, > > what scheme is used when neither is supplied? R5RS? Sorry if this is= stupid > > question, the scheme landscape seems... complicated. >=20 > No worries, not a stupid question at all. What Guile uses by default cou= ld 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. Meaning that if I want to use the many guile- libraries available under guix and elsewhere, the most pragmatic approach would be to just not care about = R6RS vs R7RS all that much, and just do what guile manual recommends. Correct? >=20 > > 4. Is the (install-r6rs!) global and affecting all reading from that po= int 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. >=20 > I'm not 100% sure on this one, but I don't think it can affect the readin= g of the file > it appears in, because the entirety of reading happens before anything is= executed. >=20 > It should affect *explicit* reading you do from that point on, i.e., what= the 'read' > procedure will do with its input. >=20 > > Thank you very much, > > W. > >=20 >=20 > You're welcome, and have fun with Guile! Thanks again and have a nice day, W. --=20 There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors. --CUs55bi8b9dao7Yq Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEt4NJs4wUfTYpiGikL7/ufbZ/wakFAmPr6G8ACgkQL7/ufbZ/ walkPA/+JrbRVH/n6rWhgPYEWD99yud9mPNiMuDWD4AwtAMiLiHQNFC94W5FzLKl oL4togtrY1sSnfdd2NYyRGmsFdeX7HXDSPyYALSk9bv335TTHHSP7fzwZ7oxWSCH MpygJXI3twWgmhoReBgACL6iN6F5+z+kvoCp3AJt4tkZxoJYVEwa76SzChMQmirV OjjC4PwaoIYU/DtZ7Zk5u2dKeclx3o5NoeJpBt8jZdM0rimNBxugsX8WY4cmBuZx vn53nkglow9QCMB6hmWHe3VJcMCe1ZA/IoI1tPpwwuwUqsslau1FYJ/DsVdKGd5G cvA/bX18KJg8DESq6XJm1bsYhUOLbPcYrf+BoemyJAbnu5+GbTqf/9vCkeuwaEnm oV/y7X8iQAC3i1wyEZihB8aWl0AWW8Xf0bM0fbOpVdAEnAqNdLKl6VoHTSgZpM1A eCno29g0KZdcxHOytyI+0q2v2kTgau9hE3Wr2qn3nsasF50qafPT82Ng2P11toQu HgkeWdnTaJm9AZIGw+AAmAcHh96pJn4NmWDSTuOgDLKShrYqwBAsV/zP+JP2x7v5 pyii9Rj06V+tiy1LCW0lAFRrjd7znsiTnVTW4RSZ8qbubb8lkymkbqcMzsbF29JI bVWHsZ9yWGrHqVzAi0gZXraaX+f/U84wm7w1D+QemMCDwTCV1aM= =SmPE -----END PGP SIGNATURE----- --CUs55bi8b9dao7Yq--