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

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

Re: Applying intern-soft to a symbol


From: John Mastro
Subject: Re: Applying intern-soft to a symbol
Date: Mon, 24 Apr 2017 10:41:43 -0700

N. Raghavendra <nyraghu27132@gmail.com> wrote:
> I am confused about the following Emacs Lisp interaction, where I've
> numbered the prompts for ease of reference.
>
> *** Welcome to IELM ***  Type (describe-mode) for help.
> ELISP1> (intern-soft "quux")
> nil
> ELISP2> (intern-soft 'quux)
> quux
> ELISP3> (intern-soft "quux")
> quux
> ELISP4>
>
> As I understand, the value of ELISP1 indicates that `quux' is not an
> interned symbol in the default obarray.  The value of ELISP2 indicates
> that `quux' is now an interned symbol in the default obarray, and the
> value of ELISP3 confirms this.
>
> Now, the Emacs Lisp manual says the following about intern-soft:
>
> ----------------------------------------------------------------------
> Function: intern-soft name &optional obarray
>   This function returns the symbol in OBARRAY whose name is NAME, or
>   ‘nil’ if OBARRAY has no symbol with that name.  Therefore, you can
>   use ‘intern-soft’ to test whether a symbol with a given name is
>   already interned.  If OBARRAY is omitted, the value of the global
>   variable ‘obarray’ is used.
>
>   The argument NAME may also be a symbol; in that case, the function
>   returns NAME if NAME is interned in the specified obarray, and
>   otherwise ‘nil’.
> ----------------------------------------------------------------------
>
> According to the second paragraph of this description, ELISP2 should
> have returned nil, because the symbol `quux' was then not interned in
> the default obarray.  Can someone please explain why ELISP2 returns
> `quux' instead of nil?

The reader interned the symbol `quux' into the default obarray while
reading the expression (intern-soft 'quux). Reading occurs before
evaluation, so `quux' had been interned before the actual call to
`intern-soft' occurred.

        John



reply via email to

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