From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: taylanbayirli@gmail.com (Taylan Ulrich B.) Newsgroups: gmane.lisp.guile.user Subject: Re: Define in let Date: Tue, 20 Aug 2013 19:02:29 +0200 Message-ID: <87a9kc9ty2.fsf@taylan.uni.cx> References: <87k3jgb9kr.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1377018175 7135 80.91.229.3 (20 Aug 2013 17:02:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 20 Aug 2013 17:02:55 +0000 (UTC) Cc: guile-user@gnu.org To: Dmitry Bogatov Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue Aug 20 19:02:57 2013 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VBpKa-0004oQ-8i for guile-user@m.gmane.org; Tue, 20 Aug 2013 19:02:56 +0200 Original-Received: from localhost ([::1]:49050 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VBpKZ-0007gk-S2 for guile-user@m.gmane.org; Tue, 20 Aug 2013 13:02:55 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57173) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VBpKM-0007fa-DK for guile-user@gnu.org; Tue, 20 Aug 2013 13:02:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VBpKE-0005Pp-Mt for guile-user@gnu.org; Tue, 20 Aug 2013 13:02:42 -0400 Original-Received: from mail-ee0-x231.google.com ([2a00:1450:4013:c00::231]:61160) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VBpKE-0005PZ-HS; Tue, 20 Aug 2013 13:02:34 -0400 Original-Received: by mail-ee0-f49.google.com with SMTP id d41so320432eek.8 for ; Tue, 20 Aug 2013 10:02:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=5JkWX/OnnSBhIHFtjrLsf0QcGz4QegtsMNkcFVdM5rM=; b=x1h4fF+QA1uvsoBCwTQLACG89g1pVu/ueBA2+NH7y57j57oPoxlN/GEdGQURJ3Byxa Whkt4I08ZSKNUlNT5KZLlrUoZBTTKztxdvI1DKS7GJ/ZBB1dHUdA6wI7b2lgJPLjoYYA Ncw/ak7b9IGuf+JScMoku1Jk10qmMkEDPpO0s85w/TiDm9Sk9bIRzVUBIzu4sFYg9wVn 7nMoeTzKTIwOwilv6/p913GiCJX2s8W2wxQ9MAOQtAxi3jTKCpA6VQUy1mLt7hPN/FnZ fO0d50v6Q6o1Yb12Ee1poQJ5gyzPPNEN422tSwGgUho8+wbmxJNDhd5Rls91vN6WYn2g nqFA== X-Received: by 10.14.199.3 with SMTP id w3mr3515047een.33.1377018152988; Tue, 20 Aug 2013 10:02:32 -0700 (PDT) Original-Received: from taylan.uni.cx (p4FD93981.dip0.t-ipconnect.de. [79.217.57.129]) by mx.google.com with ESMTPSA id m54sm3638387eex.2.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 20 Aug 2013 10:02:32 -0700 (PDT) In-Reply-To: <87k3jgb9kr.fsf@gnu.org> (Dmitry Bogatov's message of "Tue, 20 Aug 2013 20:39:32 +0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (berkeley-unix) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4013:c00::231 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:10652 Archived-At: Dmitry Bogatov writes: > It seems following is invalid: > > (let ((a 2)) > (define (foo x) (+ a x))) > > I prefer to reduce scope of variable as much as possible, so > I find this restriction unconvinent. Is is part of standard or technical > limitation? Is it any workaround? > > Please, keep in CC, I am not subscribed. > > -- > Best regards, Dmitry Bogatov , > Free Software supporter and netiquette guardian. > git clone git://kaction.name/rc-files.git --depth 1 > GPG: 54B7F00D > Html mail and proprietary format attachments are forwarded to /dev/null. No Scheme standard so far has supported such a thing, and neither Guile. It would be neat, I had the idea too (it would allow re-use of the semantics of `begin' and thus be coherent/orthogonal in a way), but I think it's a non-trivial change, probably both to the implementation of Guile and the semantics for `let' that have been well-understood ever since very old Lisps: that `let' is a thin wrapper around a call to an in-place `lambda'. (let ((a x) (b y)) ...) is just ((lambda (a b) ...) x y) in pretty much any Lisp. Note that you can do (define foo (let ((a 2)) (lambda (x) (+ a x)))) and if you want to define multiple things that use that `a' binding, you could use `define-values', but Guile doesn't have that yet (there's a hacky in-Scheme definition in R7RS-small if you want something quick): (define-values (foo bar) (let ((a 2)) (values (lambda (x) (+ a x)) (lambda (y) (* a y))))) Taylan