A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.gnu.org/software/emacs/manual/html_node/elisp/Accessing-Variables.html below:

Accessing Variables (GNU Emacs Lisp Reference Manual)

Next: Setting Variable Values, Previous: Tips for Defining Variables Robustly, Up: Variables   [Contents][Index]

12.7 Accessing Variable Values

The usual way to reference a variable is to write the symbol which names it. See Symbol Forms.

Occasionally, you may want to reference a variable which is only determined at run time. In that case, you cannot specify the variable name in the text of the program. You can use the symbol-value function to extract the value.

Function: symbol-value symbol

This function returns the value stored in symbol’s value cell. This is where the variable’s current (dynamic) value is stored. If the variable has no local binding, this is simply its global value. If the variable is void, a void-variable error is signaled.

If the variable is lexically bound, the value reported by symbol-value is not necessarily the same as the variable’s lexical value, which is determined by the lexical environment rather than the symbol’s value cell. See Scoping Rules for Variable Bindings.


  
;; Here the symbol abracadabra
;;   is the symbol whose value is examined.
(let ((abracadabra 'foo))
  (symbol-value 'abracadabra))
     ⇒ foo

  
;; Here, the value of abracadabra,
;;   which is foo,
;;   is the symbol whose value is examined.
(let ((abracadabra 'foo))
  (symbol-value abracadabra))
     ⇒ 9

  
(symbol-value 'abracadabra)
     ⇒ 5

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4