[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Understanding the "let" construct and the setting of variables
From: |
steve-humphreys |
Subject: |
Re: Understanding the "let" construct and the setting of variables |
Date: |
Thu, 17 Dec 2020 09:31:47 +0100 |
> Sent: Thursday, December 17, 2020 at 9:01 AM
> From: "Joost Kremers" <joostkremers@fastmail.fm>
> To: steve-humphreys@gmx.com
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: Understanding the "let" construct and the setting of variables
>
>
> 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.
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 cannot
> 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
>
>
- Re: Understanding the "let" construct and the setting of variables, (continued)
Re: Understanding the "let" construct and the setting of variables, Emanuel Berg, 2020/12/18
Re: Understanding the "let" construct and the setting of variables, Joost Kremers, 2020/12/16
Re: Understanding the "let" construct and the setting of variables, Joost Kremers, 2020/12/17
Re: Understanding the "let" construct and the setting of variables, steve-humphreys, 2020/12/17
Re: Understanding the "let" construct and the setting of variables, Joost Kremers, 2020/12/17
Re: Understanding the "let" construct and the setting of variables, Emanuel Berg, 2020/12/18
Re: Understanding the "let" construct and the setting of variables, Emanuel Berg, 2020/12/18
Re: Understanding the "let" construct and the setting of variables, Jean Louis, 2020/12/18
Re: Understanding the "let" construct and the setting of variables, tomas, 2020/12/18
Re: Understanding the "let" construct and the setting of variables, Emanuel Berg, 2020/12/18
Re: Understanding the "let" construct and the setting of variables, steve-humphreys, 2020/12/16