all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Let* binding for running commands with a default value
@ 2024-07-07 13:55 Heime
  2024-07-07 14:25 ` CToID
  0 siblings, 1 reply; 4+ messages in thread
From: Heime @ 2024-07-07 13:55 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor

I aw setting a default when an optional argument is missing 
with a let* binding.

(defun mtj-requisites (&optional act)

   (let* ( (act (or act 'go)) )
      (when (eq act 'go) (require 'clipper)) ))

Do the commands dependent on act have to be placed in the 
let* body ?  Or can one also do

(let* ( (act (or act 'go)) ) )
(when (eq act 'go) (require 'clipper))





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Let* binding for running commands with a default value
  2024-07-07 13:55 Let* binding for running commands with a default value Heime
@ 2024-07-07 14:25 ` CToID
  2024-07-07 15:05   ` Heime
  0 siblings, 1 reply; 4+ messages in thread
From: CToID @ 2024-07-07 14:25 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

On 2024-07-07 Sun 21:55 UTC+0800, Heime <heimeborgia@protonmail.com> said:

> Or can one also do
> 
> (let* ( (act (or act 'go)) ) )
> (when (eq act 'go) (require 'clipper))

No, the `(eq act 'go)` outside doesn't know the value of `act` inside 
`let*`.  So depends on situation, the result may or may not be the same.

-- 
Best,
ID




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Let* binding for running commands with a default value
  2024-07-07 14:25 ` CToID
@ 2024-07-07 15:05   ` Heime
  2024-07-07 15:10     ` CToID
  0 siblings, 1 reply; 4+ messages in thread
From: Heime @ 2024-07-07 15:05 UTC (permalink / raw)
  To: CToID; +Cc: Heime via Users list for the GNU Emacs text editor

On Sunday, July 7th, 2024 at 2:25 PM, CToID <funk443@yahoo.com.tw> wrote:

> On 2024-07-07 Sun 21:55 UTC+0800, Heime heimeborgia@protonmail.com said:
> 
> > Or can one also do
> > 
> > (let* ( (act (or act 'go)) ) )
> > (when (eq act 'go) (require 'clipper))
> 
> 
> No, the `(eq act 'go)` outside doesn't know the value of `act` inside
> `let*`. So depends on situation, the result may or may not be the same.
 
The let* is then applying a different local variable, than the local variable
of the function argument.  But without the overhead associated with using setq
as

(or act (setq act 'go)) 
(when (eq act 'go) (require 'clipper))




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Let* binding for running commands with a default value
  2024-07-07 15:05   ` Heime
@ 2024-07-07 15:10     ` CToID
  0 siblings, 0 replies; 4+ messages in thread
From: CToID @ 2024-07-07 15:10 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

https://en.wikipedia.org/wiki/Variable_shadowing

-- 
Best,
ID




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-07-07 15:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-07 13:55 Let* binding for running commands with a default value Heime
2024-07-07 14:25 ` CToID
2024-07-07 15:05   ` Heime
2024-07-07 15:10     ` CToID

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.