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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Calling a function with undefined symbol


From: Jean Abou Samra
Subject: Re: Calling a function with undefined symbol
Date: Mon, 31 Oct 2022 09:32:57 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1

Le 31/10/2022 à 09:15, Heime a écrit :
Have written a function named "mbcomplt" that takes a symbol.

(defun mbcomplt (sgnl)
   "DOC."

(if (eq sgnl 'go)
     (message "go")
   (message "nogo")))

I can call this function with

(mbcomplt 'go)

This even though the symbol "'go" does not exist.  What is happening here?

My understanding about symbols is that I can make a symbol using

(defvar seqr 3)  ; set symbol seqr with value 3
(setq seqr 5)    ; set symbol seqr with value 5

(symbol-value 'seqr) ; get value of symbol (returns 5)
(symbol-name 'seqr)  ; get name of symbol (returns "seqr")




It may be helpful to view symbols as some kind of modified
strings. The symbol 'go is an amorphous object, just a name
for something. You can use it as a name, or as a discrete
key, or whatever. You can also "define" it, or rather
define a variable with its name, and then you are able
to use symbol-value on it, but the symbol object itself is
a *potential* name and does not need to have a variable with
its name defined in order to be used.

Jean






reply via email to

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