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: Heime
Subject: Re: Calling a function with undefined symbol
Date: Mon, 31 Oct 2022 08:57:09 +0000

------- Original Message -------
On Monday, October 31st, 2022 at 8:42 AM, <tomas@tuxteam.de> wrote:


> On Mon, Oct 31, 2022 at 08:15:32AM +0000, Heime wrote:
> 
> > Have written a function named "mbcomplt" that takes a symbol.
> 
> 
> The function takes an argument, that's what it does.
> 
> > (defun mbcomplt (sgnl)
> > "DOC."
> 
> 
> sgnl here is a variable. Or a variable name. Depending on how
> you look at it.
> 
> > (if (eq sgnl 'go)
> > (message "go")
> > (message "nogo")))
> 
> 
> Now you are comparing sgnl's /value/ to something (which happens
> to be a symbol).
> 
> > I can call this function with
> > 
> > (mbcomplt 'go)
> 
> 
> Yes. You could call it also with (mbcomplt 23). Or (mbcomplt "This is not a 
> pipe").
> So?
> 
> > This even though the symbol "'go" does not exist. What is happening here?
> 
> 
> As soon as you do 'go, the symbol exists.
> 
> > My understanding about symbols is that I can make a symbol using
> > 
> > (defvar seqr 3) ; set symbol seqr with value 3
> 
> 
> No, no. You are making a variable. Which is a binding of a symbol
> to a value.

Ok, I make a variable.  What happens after that?  A symbol 'seqr is made too?
 
> > (setq seqr 5) ; set symbol seqr with value 5
> 
> 
> No, you set the variable's value to 5. The symbol is not "set" to
> anything. It is an immutable thing, as far as Lisp is concerned.

Then, how is it that (symbol-value 'seqr) returns 5?  There seems to be 
a symbol and symbol-value returns 5.
 
> The symbol 'seqr is just taking the job of variable name here.
> Like you are called Heime (or whatever it is this week). That
> name is not you.
> 
> > (symbol-value 'seqr) ; get value of symbol (returns 5)
> > (symbol-name 'seqr) ; get name of symbol (returns "seqr")
> 
> 
> Symbol-value returns the value associated to the symbol. The
> association itself is called a "variable".
> 
> Please go re-read the manuals. You have got all of it confused :)

Yes, I have got really confused about what symbols are exactly.  Even
after reading several times.  I have never seen anybody make a symbol,
only variables.  So, what is a symbol?



reply via email to

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