From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Joost Kremers Newsgroups: gmane.emacs.help Subject: Re: Understanding the "let" construct and the setting of variables Date: Thu, 17 Dec 2020 09:01:36 +0100 Message-ID: <87r1no26q1.fsf@fastmail.fm> References: <87zh2d1byp.fsf@fastmail.fm> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23058"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.5.7; emacs 27.1.50 Cc: help-gnu-emacs@gnu.org To: steve-humphreys@gmx.com Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 17 09:11:26 2020 Return-path: Envelope-to: geh-help-gnu-emacs@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 1kpoNh-0005uZ-JU for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 17 Dec 2020 09:11:25 +0100 Original-Received: from localhost ([::1]:53734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kpoNg-0000OH-Kc for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 17 Dec 2020 03:11:24 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57366) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpoN9-0000O1-Pk for help-gnu-emacs@gnu.org; Thu, 17 Dec 2020 03:10:51 -0500 Original-Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:51367) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpoMz-0001Th-5t for help-gnu-emacs@gnu.org; Thu, 17 Dec 2020 03:10:47 -0500 Original-Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id C301A839; Thu, 17 Dec 2020 03:10:39 -0500 (EST) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 17 Dec 2020 03:10:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= references:from:to:cc:subject:date:in-reply-to:message-id :mime-version:content-type; s=fm1; bh=WfWVJxvORerM52wpldrgI/x+iI jfuR25kFC28FqEqUE=; b=YMLDzqfdsHpjZocfb0aC+AjK1yc6jIfG/h3xreiUnq uiYrx044gbRIHKJDolPU6hw/priYD5N+YgLSaYL0Qsib2830bTSGm3AyUtIm/iV5 xxZDQU1/hOsdwSOYM5Z1jcsUWHrnzMKUl/s06GS0ODp2LKLy5DanOba1Bqxk0yS7 QC1ZHW9MrvPm7dkQ15QVotou5SwWHQSCEyuj3yhLKqiYYDyqY/GQnv+XPccMJxe1 7SKNqSNon/L2fZCw49oIS/2GWopQ0brJSjdTFM9OfZ+1VLbzGfSrjZHZgDIQMzva 92zeMoqr6ajQlK7cg5BrQ0k5OjSO/A0IdMTAqxYVR7Rg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=WfWVJx vORerM52wpldrgI/x+iIjfuR25kFC28FqEqUE=; b=G3IzQkbBSFeAzCEObfIGra CCLG7e8sBMdGha9ZHxTS5Eq2a7tBHYAI6bgnWtgqFg4A22Dn5eRc0eIGKWi9c0O9 jUV0MW5WAz0slcgsCS5cGgreZITyMij1PLaQ4bQafWNpus2MCcm467cLVuYEMyMP m40Ghw+IDkO/HE4cv5Wnx7SuD8Uq/YdS0sS/63bzbX8rFBkY47NWFuJUTqrOKFzd 52+BXdDPX8oj2Oqz7MmxFK/83J9XMrNHe+Am9k4k3XPUIR/XVLe2le0DxTBND7Yg Inz+jULhrV1HOZQEABWH2hOQpbSzdTfvWAM4C8Se10KAydUgdaQlqGQjQIgWdYsw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudelfedguddujecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepfhgfhffvufffjgfkgggtsehttd ertddtredtnecuhfhrohhmpeflohhoshhtucfmrhgvmhgvrhhsuceojhhoohhsthhkrhgv mhgvrhhssehfrghsthhmrghilhdrfhhmqeenucggtffrrghtthgvrhhnpedviefhteeuve ekudetheduieehvdelgfeijeehvdetfeegleelhefhjeduieejveenucfkphepleehrdel tddrvddvgedrvdegieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehjohhoshhtkhhrvghmvghrshesfhgrshhtmhgrihhlrdhfmh X-ME-Proxy: Original-Received: from Swift.fastmail.com (ip5f5ae0f6.dynamic.kabel-deutschland.de [95.90.224.246]) by mail.messagingengine.com (Postfix) with ESMTPA id 2FE92108005F; Thu, 17 Dec 2020 03:10:38 -0500 (EST) In-reply-to: Received-SPF: pass client-ip=64.147.123.19; envelope-from=joostkremers@fastmail.fm; helo=wout3-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:126453 Archived-At: On Thu, Dec 17 2020, steve-humphreys@gmx.com wrote: > I want the function "lett" to return "tim_out". I understand that the last command > is the output of the function. But should this be done in the binding part or in the > body part of the "let". Or outside the "let". If `message` is in the last form in the body of the `let`, the return value of `message` is also the return value of `let`. If `let` is the last form in the body of the function, its return value is the return value of the function. `message` can also be outside the body of `let`, but in that case it cannot refer to any of the variables bound in `let`, because they are then out of scope and no longer exist. > (defun lett (tim tsk) > > (let* ( (thr (/ tim 100)) > (tmn (- tim (* thr 100))) > > (tinc_mn (+ tmn tsk)) > (tinc_hr (/ (+ tmn tsk) 60)) > (tinc_mn (- tinc_mn (* tinc_hr 60))) > > (thr_futur (* (+ thr tinc_hr) 100)) > (tmn_futur tinc_mn) > (tim_out (+ thr_futur tmn_futur)) ) > ;; --- body of let ---- > (message "tim_out: %d" tim_out) )) -- Joost Kremers Life has its moments