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: Thu, 23 Sep 2021 21:03:19 +0200 Message-ID: <44ac5afd-24f3-df79-3b20-8c3645681163@gmail.com> References: <147c2fb4-75d6-7cf6-4f4a-4edd996b0a4a@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40184"; 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: Damien Mattei , guile-devel To: William ML Leslie Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Thu Sep 23 21:04:05 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 1mTU0r-000ACB-34 for guile-devel@m.gmane-mx.org; Thu, 23 Sep 2021 21:04:05 +0200 Original-Received: from localhost ([::1]:40702 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTU0p-0004sm-Ey for guile-devel@m.gmane-mx.org; Thu, 23 Sep 2021 15:04:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38440) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTU0C-0004sc-LR for guile-devel@gnu.org; Thu, 23 Sep 2021 15:03:28 -0400 Original-Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:41918) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mTU0B-0000sK-4A for guile-devel@gnu.org; Thu, 23 Sep 2021 15:03:24 -0400 Original-Received: by mail-wr1-x42b.google.com with SMTP id w29so20014722wra.8 for ; Thu, 23 Sep 2021 12:03:22 -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=XmC/h1dAMYpyTSNoVkUXAz4uk+tIBzRqnDbdg8iuh64=; b=fDKfk3gITM9H8E6jVQ9IMbNYPkuYthzJks60+YfAk4SPVUpomocZES7nTkdedJizro cyma9ADAYfZ+7H6L+HqZuzUuPNdQGcNHumUcLFbTU9K30K4o+x5YV0giNL73W0hj9UFv ftvN+Oyl5qD9cOGM9aOejSHRR6OtZR0vabsw34L9N9ggOqFSNjdEJUdt1h7mAg6JzJ9N Jz0OlTfle+ruY5DGWY3BnP25Qbjdj+Yl6ib/eWTg0pPmKIKculB5dqzdpwFxLyZbyr6j ltWvGl1SNC5X6XZmgv9stMP00LeoupaIbzum/skmA0pkcH6HIFby0OUvqukEo6NkBv07 HpMA== 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=XmC/h1dAMYpyTSNoVkUXAz4uk+tIBzRqnDbdg8iuh64=; b=ksuH2gtNedeZjLCd3y3jRE4RqrOQ3lKMd4+GeDAEaON/0Y6dqpwYu4DZfFp56InVxS t4nl1eZEBM1C1sqC4bLPhwbkYBj+YFWAAB9mJi9RiBXJEAMeQsFICkZmoF/sDiwhXxUj +WA5USqkTvwUAm2I0YgfmtU3DjswS4Y3j6MiEIBeIWK6N2l1vKFTM+LwSB9dG2MkxDWN pqvrZQXTT/knGIbJ8luHeT5oXRUXmE5VGNovt7Ya9FJ2j+CRGw7ppwvGWoRxLJ/dCRfo A2aeHNiUaX0UtTfpw9cMZLLij7kTTr7yYVGsegRPZpxNpeWXQ+W9PJ7dtSbXj3ND3yy9 kGsA== X-Gm-Message-State: AOAM530AdcS+7Ct0DuIMzm7bsu8uzTBa8RBYkVRRajJPTaZ4VzbEvpou zi5eIKYHI9MA8TkeAjnmruUErt/pK4I= X-Google-Smtp-Source: ABdhPJz+XunsBkBdKNjQCHauuOKOtjAB3gsrAeIGpAhUuvFDSbEFysDh6x+rKV8ILHpuWnZCE1bNTA== X-Received: by 2002:a05:600c:3209:: with SMTP id r9mr6176347wmp.35.1632423800958; Thu, 23 Sep 2021 12:03:20 -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 j20sm6175511wrb.5.2021.09.23.12.03.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Sep 2021 12:03:20 -0700 (PDT) In-Reply-To: Content-Language: en-US Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=taylan.kammer@gmail.com; helo=mail-wr1-x42b.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:20881 Archived-At: On 22.09.2021 23:52, William ML Leslie wrote: > On Thu, 23 Sep 2021, 4:51 am Taylan Kammer, > wrote: > > 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. > > > Python is lexically scoped, and the assignment here is supposed to be local. Well, yes and no. It implements variable hoisting, meaning all previously unset variables that are set within a function are implicitly declared at the beginning of the function. It doesn't have sub-scopes in function bodies. -- Taylan