help-gnu-emacs
[Top][All Lists]
Advanced

[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 01:35:30 +0100

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" <help-gnu-emacs@gnu.org>
> Subject: Re: Understanding the "let" construct and the setting of variables
>
> 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" <help-gnu-emacs@gnu.org>
> > Subject: Understanding the "let" construct and the setting of variables
> >
> > 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 variables
> > in a "let", because people criticise using "setq".  But discussion needs
> > 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))
> >
> >
> >
> >
> >
> >
>
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]