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 22:27:31 +0200 Message-ID: <9c058f24-5b15-417a-17ff-10bc13fed12d@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="12139"; 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 Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Thu Sep 23 22:35:49 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 1mTVRY-0002sq-Ut for guile-devel@m.gmane-mx.org; Thu, 23 Sep 2021 22:35:44 +0200 Original-Received: from localhost ([::1]:34030 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTVRX-0001Mt-SK for guile-devel@m.gmane-mx.org; Thu, 23 Sep 2021 16:35:43 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53034) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTVJj-0006FK-8v for guile-devel@gnu.org; Thu, 23 Sep 2021 16:27:39 -0400 Original-Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:43696) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mTVJe-0005Lf-IA for guile-devel@gnu.org; Thu, 23 Sep 2021 16:27:38 -0400 Original-Received: by mail-wr1-x433.google.com with SMTP id w17so20579377wrv.10 for ; Thu, 23 Sep 2021 13:27:33 -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=Ryntg207RPuPxml1SuwzGkqJ+3hWqPspTXzu3R6erxA=; b=juvaKfjT6JcypLEYlPUoZgdlOdPA/zZdrcFA67EX4G2hpLJLNDXhpWs1qPTUlVnkee WRakfezGS2VOkYj0u/5t8Gg3nqQ6q7NO1GTiLh4TALnIs8Lby1Jz4+BPQnAcnSoSQJWH ktwdYNgUCXpIANnMFVyZEDV8BR2o67x4zxujWL0HNGq7oJI01QHMJ/VByTcBwSHz8nmf MHOsIKFopDCL05dRpao3cip9maApcTLS6RslE0ELQOa+7iTjGBXYD0t415uuUnF6qeJT UdDj3RTyUkh9cC4FyP+IJ1DedfCD83GjgY/oyHiH+x5h4nEZKGyjVsx5Lw7AbR3/un8S afxQ== 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=Ryntg207RPuPxml1SuwzGkqJ+3hWqPspTXzu3R6erxA=; b=6JHji1nFDoWMiy6/yuLvxrSl9P6l+bkDh+l1sw33qpCD1dWoMRflSRe0vq2BJSkMiS S89J9NeLkTnonqPDs/UefPcL3ea3J8eRSrZ0AbZxtUMF1Yac79eefn+qAUeSiYplR5SD I02OOWyHOdpYHnuNg8Zvzu+CiOLYjWy4YN7AXGhhSYB0g9VRJUJXacPtf2q3G4j0RaEQ EoNXkxspFXe+F65PU7VQjmMYX66SZAsTWaeySijApC9QA+QA+ATKCJ7MNOCrjkm4RuDZ fjq5fpSVnwgeZ8Gg13fuVJctO/Yc9A9/bxFov+8fXzG3PvqjRgFqGmmJRqoFm0Lu5XRS MDiw== X-Gm-Message-State: AOAM5306RBlVuV7UjOGebhuD9RdCFyVrHTDXySgPw7qDeZdRDvjS3Xs4 sgBSA0uXuJDMWyLlPjF8KTskqEFDr9I= X-Google-Smtp-Source: ABdhPJxGr5cZJnH0xccjulJqL8Dq9l2bdGzio5lGOSA6rCrQ0rB+sMNagKywIsAvamwO8P45uqiYzw== X-Received: by 2002:a05:600c:3652:: with SMTP id y18mr6563148wmq.66.1632428852417; Thu, 23 Sep 2021 13:27:32 -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 h15sm6098450wrc.19.2021.09.23.13.27.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Sep 2021 13:27:32 -0700 (PDT) In-Reply-To: Content-Language: en-US Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=taylan.kammer@gmail.com; helo=mail-wr1-x433.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:20882 Archived-At: On 23.09.2021 19:27, Damien Mattei wrote: > yes i know parsing the whole code is the only portable solution, but it is slow,even on a few dozen of lines the slowing is visible ,so i can even think of that on one thousand lines... > > I finally succeed in Guile with simple piece of code to make my example run with a single assignment operator <-  , here i define for variable the assignment operator <$ , <- is working with arrays too: > > *Preview:* > > (define-syntax <$ > > (lambda (s) > > (syntax-case s () > > ((_ var value) > > (case (syntax-local-binding #'var) > > ((lexical) #'(begin > (display "<$ : lexical scope : ") > (display (quote var)) > (newline) > (set! var value))) > > ((displaced-lexical) #'(begin > (display "<$ : displaced-lexical scope : ") > (display (quote var)) > (newline) > (set! var value))) > > ((global) #'(begin > (display "<$ : global scope : ") > (display (quote var)) > (newline) > (define var value))) > > (else #'(begin > (display "<$ : unknow variable scope :") > (display (quote var)) > (error "<$ : unknow variable scope : ")))))))) > I can't seem to find syntax-local-binding in Guile 2.2 or 3.0. Did you have to import some special module, or are you using another version? Either way, I suspect that the following will not work with your macro: (let () (let () (<$ x 1)) (display x) (newline)) If I understand correctly, it will expand to: (let () (let () (define x 1)) (display x) (newline)) And that won't work because 'x' is only defined in the inner 'let'. This is where we see the crucial difference between Scheme and Python: in Python there is nothing similar to an inner 'let'. There is only one function-level scope. In Scheme, there can be as many nested scopes as you want, and an inner scope can't affect an outer one. -- Taylan