From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: steve-humphreys@gmx.com Newsgroups: gmane.emacs.help Subject: Re: Understanding the "let" construct and the setting of variables Date: Thu, 17 Dec 2020 09:31:47 +0100 Message-ID: References: <87zh2d1byp.fsf@fastmail.fm> <87r1no26q1.fsf@fastmail.fm> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40325"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs@gnu.org To: Joost Kremers Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 17 09:33:42 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 1kpojG-000AOo-3h for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 17 Dec 2020 09:33:42 +0100 Original-Received: from localhost ([::1]:38648 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kpojF-0007AL-3y for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 17 Dec 2020 03:33:41 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33594) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpohX-000796-0P for help-gnu-emacs@gnu.org; Thu, 17 Dec 2020 03:31:57 -0500 Original-Received: from mout.gmx.net ([212.227.15.19]:49339) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpohT-0000a3-ON for help-gnu-emacs@gnu.org; Thu, 17 Dec 2020 03:31:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1608193907; bh=wBfcnlPAZlX9UY8Ctsu3dx24LxJ0Wuy9l46P9J/jSWA=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=jPG3OCzJeNxmGcdj8EIqHPFZf4TxnDwTz+eEIlCTCEoVDo+bdXT7EJzm9AUIFoJ5O c9VRZRfANZbOroFBQjGCoBl+mzUP8XwwT/CZ9pS9SaMES3F7zhivFUfiYm0i9hpMKj UixCOpO1PwbW/CoxLS+R9YCF5aPAh8MCkT8UeDF0= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from [213.165.168.94] ([213.165.168.94]) by web-mail.gmx.net (3c-app-mailcom-bs11.server.lan [172.19.170.179]) (via HTTP); Thu, 17 Dec 2020 09:31:47 +0100 Importance: normal Sensitivity: Normal In-Reply-To: <87r1no26q1.fsf@fastmail.fm> X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:9+S0tjIiEAXlyAsT7kJsYkTBF/Fiav2cz90jZpR81kcUW8S5we7fTegQDlecMaEUpJ4OC XNasJ+hFIUNIzPquw3TmmpoxiM2UNdynAJUUMZLUd4ydtUKy0bI9ybjdkBV0/jzIrLzIrdbBvxVx XPPcAAhMYhbRmRCrZrxoeZc8QzThvbq09uPwGVCPaoWbqjZU8HiZT+EvzzkiEtb6K2g9JnBB6nGQ qY70nWlnZxM+I8huEJIAYdpq4i8eW+2tYCiNDd9BHdC+Q2195xNqkdm47Q3Hj1DBKQLW1QqAd8lg gY= X-UI-Out-Filterresults: notjunk:1;V03:K0:z5wB1wq3e/U=:qDKoi9Y9sSIKYcgp14IDwY EPBPlEQdCEJxTL7bUFVehVj9YU2EGb4LjzcJHutNG1CX1QoXXD7HzRwIxcilbEz/z1B51iEim CbrbTwguYmiB30CkaMjfOEWYNZnI8pWuarH3M1Z9kUuwlPIiUWGVKdJn7gaeQ27RNMX/UgxXW 1WCy1I2G5jElwVeqy83TDBSVtJFzlbcmci6eFlN84prARobPpQf1nopd/9bwivl6GWKUZr6Qi UoeqKdWx8OiyzQV4hIxIZhMP066KKoIj0JOZRnD1pPAer2UP7Le4HVpC3J24Iseb0X1x/nW/R Xuo9UdsF653aGiCIitWhkReGe/masDS7EjBAM/cS2yUZZyffEWxwcG1rGU9be+OZzp2uNUp46 dhjovIFxUn7oDh2vjqxuXqCbMHwaSkivjZTrVFZFOREdi3g0Y4kkFhOBc+6h2ANLpyZo7pIq9 sFCoMMZ1uTm3htGdOGQPganoRUyZ+egPE1ehUYDToWHE4wJTFkvmSs2O0eeFVr3WY3KmtIxqu JiKwCHeJ8mdGa2BiCdF8PE9wqfnkF1vpemOnu1tX9/9i/rhPJyDNz8BOmxTWbZaGUs2fbky61 VS+IOVmuIqhtw= Received-SPF: pass client-ip=212.227.15.19; envelope-from=steve-humphreys@gmx.com; helo=mout.gmx.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=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:126456 Archived-At: > Sent: Thursday, December 17, 2020 at 9:01 AM > From: "Joost Kremers" > To: steve-humphreys@gmx.com > Cc: help-gnu-emacs@gnu.org > Subject: Re: Understanding the "let" construct and the setting of variab= les > > > 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 va= lue of > `message` is also the return value of `let`. If `let` is the last form i= n the > body of the function, its return value is the return value of the functi= on. I do not want the function to return the "message" (tah was for testing), = but the value of tim_out. How can one return a local variable? > `message` can also be outside the body of `let`, but in that case it can= not > refer to any of the variables bound in `let`, because they are then out = of scope > and no longer exist. Understood. Thank you. > > (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 > >