unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Let clause with defvar
@ 2024-09-04  0:49 Heime
  2024-09-05 10:32 ` Philip Kaludercic
  2025-01-03  8:39 ` Joel Reicher
  0 siblings, 2 replies; 4+ messages in thread
From: Heime @ 2024-09-04  0:49 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor

Consider two versions of setting  xiakos.  The let defines local bindings. 
Can the let block be placed outside a defvar or inside.  Does it make a 
difference ?  Although defvar is used to define global variables, can it
be used to evaluating local bindings like let ?  Which version would one
suggest ?

(let ( (orella-waypt
           (questor-path-snip marshal-waypt "orella")) )

  (defvar xiakos
    `( ("GLXKS" . ,(concat orella-waypt "/xiakos"))
       ("GLXKS" . ,(concat orella-waypt "/xiakos")) ))

and

(defvar xiakos

  (let ( (orella-waypt (questor-path-snip marshal-waypt "orella")) )

    `( ("GLXKS" . ,(concat orella-waypt "/xiakos"))
       ("GLXKS" . ,(concat orella-waypt "/xiakos")) ))






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

* Re: Let clause with defvar
  2024-09-04  0:49 Let clause with defvar Heime
@ 2024-09-05 10:32 ` Philip Kaludercic
  2024-09-05 11:33   ` Heime
  2025-01-03  8:39 ` Joel Reicher
  1 sibling, 1 reply; 4+ messages in thread
From: Philip Kaludercic @ 2024-09-05 10:32 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

Heime <heimeborgia@protonmail.com> writes:

> Consider two versions of setting  xiakos.  The let defines local bindings. 
> Can the let block be placed outside a defvar or inside.  Does it make a 
> difference ?  Although defvar is used to define global variables, can it
> be used to evaluating local bindings like let ?  Which version would one
> suggest ?
>
> (let ( (orella-waypt
>            (questor-path-snip marshal-waypt "orella")) )
>
>   (defvar xiakos
>     `( ("GLXKS" . ,(concat orella-waypt "/xiakos"))
>        ("GLXKS" . ,(concat orella-waypt "/xiakos")) ))
>
> and
>
> (defvar xiakos
>
>   (let ( (orella-waypt (questor-path-snip marshal-waypt "orella")) )
>
>     `( ("GLXKS" . ,(concat orella-waypt "/xiakos"))
>        ("GLXKS" . ,(concat orella-waypt "/xiakos")) ))

I'd place the `let' inside the `defvar', because it makes it easier to
evaluate the value manually without changing the value of the variable.

-- 
	Philip Kaludercic on siskin



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

* Let clause with defvar
  2024-09-05 10:32 ` Philip Kaludercic
@ 2024-09-05 11:33   ` Heime
  0 siblings, 0 replies; 4+ messages in thread
From: Heime @ 2024-09-05 11:33 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Heime via Users list for the GNU Emacs text editor

On Thursday, September 5th, 2024 at 10:32 PM, Philip Kaludercic <philipk@posteo.net> wrote:

> Heime heimeborgia@protonmail.com writes:
> 
> > Consider two versions of setting xiakos. The let defines local bindings.
> > Can the let block be placed outside a defvar or inside. Does it make a
> > difference ? Although defvar is used to define global variables, can it
> > be used to evaluating local bindings like let ? Which version would one
> > suggest ?
> > 
> > (let ( (orella-waypt
> > (questor-path-snip marshal-waypt "orella")) )
> > 
> > (defvar xiakos
> > `( ("GLXKS" . ,(concat orella-waypt "/xiakos"))
> > ("GLXKS" . ,(concat orella-waypt "/xiakos")) ))
> > 
> > and
> > 
> > (defvar xiakos
> > 
> > (let ( (orella-waypt (questor-path-snip marshal-waypt "orella")) )
> > 
> > `( ("GLXKS" . ,(concat orella-waypt "/xiakos"))
> > ("GLXKS" . ,(concat orella-waypt "/xiakos")) ))
> 
> 
> I'd place the `let' inside the` defvar', because it makes it easier to
> evaluate the value manually without changing the value of the variable.

Can you clarify what you are talking about ?  What would one want to evaluate ?
 
> --
> Philip Kaludercic on siskin



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

* Re: Let clause with defvar
  2024-09-04  0:49 Let clause with defvar Heime
  2024-09-05 10:32 ` Philip Kaludercic
@ 2025-01-03  8:39 ` Joel Reicher
  1 sibling, 0 replies; 4+ messages in thread
From: Joel Reicher @ 2025-01-03  8:39 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

Heime <heimeborgia@protonmail.com> writes:

> Consider two versions of setting  xiakos.  The let defines local 
> bindings.  Can the let block be placed outside a defvar or 
> inside.  Does it make a  difference ?  Although defvar is used 
> to define global variables, can it be used to evaluating local 
> bindings like let ?  Which version would one suggest ?

In my experience, as a general rule it is better to make scopes as 
small as possible.

I'm also curious why you're using a defvar at all.

Regards,

        - Joel



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

end of thread, other threads:[~2025-01-03  8:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-04  0:49 Let clause with defvar Heime
2024-09-05 10:32 ` Philip Kaludercic
2024-09-05 11:33   ` Heime
2025-01-03  8:39 ` Joel Reicher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).