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 01:35:30 +0100 Message-ID: References: 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="25916"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Help Gnu Emacs 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 01:36:10 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 1kphH8-0006eR-La for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 17 Dec 2020 01:36:10 +0100 Original-Received: from localhost ([::1]:33550 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kphH7-0004mn-9m for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 16 Dec 2020 19:36:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34700) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kphGZ-0004mc-Uk for help-gnu-emacs@gnu.org; Wed, 16 Dec 2020 19:35:36 -0500 Original-Received: from mout.gmx.net ([212.227.17.20]:53587) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kphGX-0005dn-Tj for help-gnu-emacs@gnu.org; Wed, 16 Dec 2020 19:35:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1608165330; bh=Vzav2Dk5ozvzZPq+LOaW9H1DJHsfBOJr7vyud7EOi0Q=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=OffXTuGmbxQxGyfkj47RArR6tWPv2NROv6ElAa0eEPX5g6apQ6xklV4lOH1pz9cJM A70OYZen3WaUKd1vNDwNJFM+lgEGMV6iLwoQ9wQgbk1FH31Xc8osdHJ9fidgNexesZ k9IAh8BlBhhgIe+BP/4PwwX+MwfQmDxVTUEpLNhs= 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 01:35:30 +0100 Importance: normal Sensitivity: Normal In-Reply-To: X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:eb9FVitk3Cc8SJmpWqUb9GDvgGx3p2IwM06/fmOA9nn102aRD3rTN2Y5sO5FNpy4FxgQs Apjc4VjrPADF0tnrQ3zVcfNRSv88Xb1Oz9zjyEiT0fgSTDxIgFSY/luihP/D42GctzXDH11jy4Eg JeLf8Ug9aQP+0SdbA/Pr6rQCdpJ3JXZDnEd4NWVFA5IvggaoxFdvdjVtjxbz9drJI8acuM8XKzwS yd/jNYJcqpKIOcT3XxiU7kJ2mIG9NrT8wuy74zNuQuxiBfwvauL5jOV78hO/tULwKUcA6yMDPPPk 9I= X-UI-Out-Filterresults: notjunk:1;V03:K0:RogA/L6QKyI=:TkDvA7yzje6AQ/MSlDD4vC ft36sS0p1spvOJbasmznyng/Qt172PkeBrVTaUYUdgYSWkIgSsID+EwnWmm2OAUHjntgpGvcu sTVwuOwWExC12UaZ0MPZT3kiuOho64iH/dOutYNIZc8xau64dhmFuelBRAlajYf1UJxFsVVun BMoah84AcMUPKrX/mAGTprk975MyQTAlfoO97UiF43Ddm+0Cx1KuOwoyf6+C0pL2wNqamov0B QP3dzWNyb1oNgsAuUMgYplBK5aUqU5Tew+jcgfuW3KzrsqEG1Uaev4OH2/Xn6drpXcRl2X7hC E2VqqSnaPo9WIFBzW2VtrN+wR8emLZXgJubZSdYonOLZ6KlZEmTTGTAZVrKQuoRr9HZfxZuIL a5Wv52s1C2/Z3senmUazViGoLfS3BUm9/rrTBhfWvFeQF99dskYtZzcMLt8Yj2mJjuav3SzDB R+zFQVW9at33OkN8LzmAkMRXtCfjcls6bUGGU3vopm4T9CyZ0iJ1QuTD55a4olJWYdsUgOMOr hwegGfrCxMZ/4urX9b14fgk7RftadKyAR+nhKwv2QxyMakDsUZQSzCQVmpHUybWuBqD1xZXEO KH64cbZWo6A3s= Received-SPF: pass client-ip=212.227.17.20; 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:126434 Archived-At: For example, the following fails. Why? Haw can one fix the function? (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)) (message "%d %d" tim_out) ) (message "%s" "lett") )) (lett 845 80) > Sent: Thursday, December 17, 2020 at 1:25 AM > From: steve-humphreys@gmx.com > To: steve-humphreys@gmx.com > Cc: "Help Gnu Emacs" > Subject: Re: Understanding the "let" construct and the setting of variab= les > > Let's introspect two questions. > > 1. In what simple circumstances would one use a "setq" in the body of a = let? > 2. What simple option does one have that is more advantageous than using= a "setq"? > > > > > Sent: Thursday, December 17, 2020 at 1:10 AM > > From: steve-humphreys@gmx.com > > To: "Help Gnu Emacs" > > Subject: Understanding the "let" construct and the setting of variable= s > > > > I have been writing some elisp to set the time grid in the agenda. > > The discussion progressed towards the use of the "let" construct. > > > > But, the discussion got too advanced for me to follow the different > > points of view and make a decision. > > > > This message is for showing some examples, of how to set and use varia= bles > > in a "let", because people criticise using "setq". But discussion nee= ds > > simple examples that would not overwhelm a relative beginner. > > > > (defun timfutur () > > (interactive) > > (setq tim 845) > > (setq tsk 80) > > > > (setq thr (/ tim 100)) > > (setq tmn (- tim (* thr 100))) > > > > (setq tinc_mn (+ tmn tsk)) > > (setq tinc_hr (/ (+ tmn tsk) 60)) > > (setq tinc_mn (- tinc_mn (* tinc_hr 60)) ) > > > > (setq thr_futur (* (+ thr tinc_hr) 100) ) > > (setq tmn_futur tinc_mn) > > (setq tim_out (+ thr_futur tmn_futur)) > > > > > > > > > > > > > >