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 02:20:53 +0100 Message-ID: References: <87wnxh1bpk.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="19001"; 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 02:22:07 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 1kphzb-0004q1-PV for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 17 Dec 2020 02:22:07 +0100 Original-Received: from localhost ([::1]:34544 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kphza-0002AH-NY for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 16 Dec 2020 20:22:06 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45018) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kphyW-0002A2-W0 for help-gnu-emacs@gnu.org; Wed, 16 Dec 2020 20:21:01 -0500 Original-Received: from mout.gmx.net ([212.227.17.22]:33893) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kphyU-0002Ya-SN for help-gnu-emacs@gnu.org; Wed, 16 Dec 2020 20:21:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1608168053; bh=l97hXQDZ+evguZJTTkHCtvdnFFtvJW+riJqRKHUHUSc=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=A99iSAu0E3vzdF+OiHdYdhW7crXTCjEI59D0aLraXDaa+ris97eWwDnDgOQ38gmhp oaKRHp5L0CIwVoxt/jLEy/OK7a7Da4TjAMVbCbsZ1IibRC3jPN/WRcRzt/cGwVBqUm lbo0caMTiySTcLGLStM8mb7H6KbfAXwUnP/IwdFU= 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 02:20:53 +0100 Importance: normal Sensitivity: Normal In-Reply-To: <87wnxh1bpk.fsf@fastmail.fm> X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:Gm7VhRaRvztk3EH2nu2lDuPPAbDUByTNvizoA4tnxFLMEkfRC4TcwamQh4agWGp0MUcaq syYQH1EYQjb1NnpKuDHFeHAVp/Er/HK2TK3h5nQEV51aMdl+pPMdgsZXwIPUrF1pIfCHpYSBt8mB Can0+E2BICxguFPsSa/vBs2Bt64cc7o2EbPDHnEQZQyP3vECXAF5epttnJM8pliOIHZZWWkndwjY iX7EWvZJVZDlH4EVPuZTRXu956Y06toKeO0iZ27pPomzhAFn3El0AM/kx77FSEBtKDfiqfPp6yLO jw= X-UI-Out-Filterresults: notjunk:1;V03:K0:7CP7HzdOxVc=:hawXHByyuxsgRtYggVePlJ sIb7RILyyGDyZ+VzYRpDRy+oSoP+QNi4QFKDhRUW2bubndGuV/QcvOoUZrdvU0Axkz/nG+R6v TzeVbGRyYQ8w1AYUlUSLetQbeGKNNWInTcN6BtvUsRGpFEy/wEg/z9JKuzLOa96W7rt3OSmpJ BDlXNd9V6RFJcrHvO0PEcOSi5W6bwddd/QKYkYUjiY0PzUy9cawADmg9VimkOIj9edIpu7KY1 jfdE+rYeuW/iGGWkloYMMbeQA+09ojxJREEs0QhxNFL6RCEVL6D0cv4hXYAqD33O1aXSRESxl XPhAdCmqsOErRrVuj65jcpfa4FdZaTnoH7hk1TpsgKShl27yemM6LxN7rS6szniNFDHTMJ/jk UwpQEvLW0lab4jCG81Uy/vV+qKAD8ldfTEtiV4a/sBty26uSeV7P0xJwckxDsKcgmAiINUKFY XguvXhA04QIy0ZdpkTttGM4n6+w4tuLuRtpru0Nol9TWJ3iaG+H++CGCEyQ8hWpZmY16Hhcld Fu8mjy2wQ7CAMW0VpqzVbiXPQRTs9wtf78S8zFRXCmejo3A8whqCbhltsU1BqSFmibXNyVHBr f8tJU4PUoe5S4= Received-SPF: pass client-ip=212.227.17.22; 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:126437 Archived-At: > Sent: Thursday, December 17, 2020 at 2:05 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: > > 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) > > The error is a bit cryptic, but it's telling you that you need to move t= he first > `message` into the body of the `let*`. Right now, it's in the list of va= riables > to bind, but it's not a valid binding form: > > ``` > (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") )) > ``` > > Note that this will still produce an error, because the first `message` = has a > format string that requires two arguments but only one is given. This means that I can use the variables in the body of the "let". Great e= xplanation, I fixed to. Now I need to have the function output "tim_out". > -- > Joost Kremers > Life has its moments >