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.devel Subject: Re: new function Date: Wed, 22 Sep 2021 20:51:45 +0200 Message-ID: References: <147c2fb4-75d6-7cf6-4f4a-4edd996b0a4a@gmail.com> 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="15448"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 Cc: Jean-Paul Roy , guile-devel To: Damien Mattei , William ML Leslie Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Wed Sep 22 20:59:39 2021 Return-path: Envelope-to: guile-devel@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 1mT7T1-0003n8-L8 for guile-devel@m.gmane-mx.org; Wed, 22 Sep 2021 20:59:39 +0200 Original-Received: from localhost ([::1]:40168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mT7T0-0001eW-9I for guile-devel@m.gmane-mx.org; Wed, 22 Sep 2021 14:59:38 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51464) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mT7LR-0004GV-Uw for guile-devel@gnu.org; Wed, 22 Sep 2021 14:51:50 -0400 Original-Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:40709) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mT7LQ-0007OZ-7e for guile-devel@gnu.org; Wed, 22 Sep 2021 14:51:49 -0400 Original-Received: by mail-wr1-x431.google.com with SMTP id q26so9811085wrc.7 for ; Wed, 22 Sep 2021 11:51:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Rqbvj6ylbTPdhpvLlLrnwgLa9h5bs1a+4ofyxsRAZ2U=; b=LiHXRG7sZWYLjTuHEYH1o3q378RiwJQASSwb+mxdeMaQVnm1FZU41yayLEuTnqUlt7 9FhIyxBoruoJZujdF/0FcNPS9SWAAkBWLmCrLwV6JGBqvk7FoYzXeQYKZDYgQvFe0PgH L9YaYsislJQAMpk30tkrn71pNFYkoyCE72jETvz2RDe/0sLjnuMbk+hzC0rUVJ7FStj2 UMP1LvPkEOOI22GMf7btzPw4atwmn1u3A8wm/JfnTe6KToHruZIPrT1RdzL3bbiPLqYn daWanckYPakJWXi/afTOF58bsfAHgNExA6bgckSDx1RUxdvsGeTPHausH9E5l9vBbrjj lUvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Rqbvj6ylbTPdhpvLlLrnwgLa9h5bs1a+4ofyxsRAZ2U=; b=tmCnk/L6BJgWqUZgFHy5YU9nIbsjJSpTBit4lk6OVHQTpTMUUBXYKtlDwl9Ys9cQ3F nJ++m9t6Te4lTSZ6wFVumk0EZKI8hbqbU2/IQ4DeurwVd0NgnFguQ5/GX68RWKLDLhUd 8GnhSWdDeKkRZtpRrqRKTUOhgZkIpxTaKnSYyBkqB7KcvabHIf3OB8AKXXclRKTF82Gn NX3Pd98AJEVzjgKrppaw3CrjShHd6GJ7VAXCkQwm+/4zaoTIR8YHXcDA9YFi3M/fwyd8 bKlDL+nDMA3Go9T2/WdaarDUnWWziC2d++qzm1szT5cWUhJjASmkU+CuxCy1o5spqENl SXJg== X-Gm-Message-State: AOAM531gi1arh5mjmW12kzErOVMfT8GpDiNxYGu5zcSzgoT6rJQPsrCg 4gj/mYQVqGgau1R9D2m0aATXGmoA/cQ= X-Google-Smtp-Source: ABdhPJyT4b4XfTFyDxkoJaoFARZCpjyiEcaCPpOBHjb5TDnXmC4JQ+aKcUyqHmqqDzI6qC7N6bijZA== X-Received: by 2002:a1c:28b:: with SMTP id 133mr626999wmc.14.1632336706485; Wed, 22 Sep 2021 11:51:46 -0700 (PDT) Original-Received: from [192.168.178.20] (b2b-109-90-125-150.unitymedia.biz. [109.90.125.150]) by smtp.gmail.com with ESMTPSA id z6sm3012222wmp.1.2021.09.22.11.51.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Sep 2021 11:51:46 -0700 (PDT) In-Reply-To: Content-Language: en-US Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=taylan.kammer@gmail.com; helo=mail-wr1-x431.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, NICE_REPLY_A=-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-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.io gmane.lisp.guile.devel:20876 Archived-At: On 22.09.2021 11:53, Damien Mattei wrote: > i already do it this way for internal defines ,using a recursive macro that build a list of variable using an accumulator. It can works but macro expansion seems slow, it was not immediate at compilation on a little example (oh nothing more that 2 seconds) but i'm not sure it is easily maintainable, it is at the limit what macro can do i think ,for speed reasons. In fact i can not really understand in Guile as it is based on C and compiled when macro expansion happens,what is the time cost... so for all those ,perhaps not objective reason ,i prefer to avoid. I don't think there's any other way to achieve what you want, especially using portable Scheme code. The lexical scoping semantics of Scheme are a very fundamental part of the language, and cannot be worked around in portable Scheme code without using a macro that rewrites whole bodies of lambda expressions. Even using implementation-specific hacks, you won't get very far. Any compiled Scheme implementation, and even most interpreted ones, won't allow you to modify an outer scope's set of variable definitions from within an inner scope. So if you really want to have Python's scoping semantics in Scheme, you will probably have to write a complex 'def' macro that walks through the body and "hoists" variable definitions to the outermost scope. If you're targeting R6RS implementations, you can use syntax-case to write such a macro, but it won't be easy. If you're targeting R5RS or R7RS-small implementations, you will have to rely on syntax-rules, which will probably be extremely difficult for this kind of complex macro. Personally I don't even know how I would approach the problem using the more capable syntax-case, let alone pure syntax-rules. -- Taylan