My Technical Notes

Thursday, 17 March 2016

Elisp: Global vs Local Variables

Global Variables

If we use `setq` we can create global variables:


(setq my-name "tahir hassan")

Local Variables

To create a local variable, we must first enclose the name in a `let`, and thereafter any `setq` on this name will not be visible outside of the `let`:


(let (my-forename my-surname)
    (setq my-forename "Tahir")
    (setq my-surname "Hassan")
    (message "%s %s" my-forename my-surname))

References

No comments: