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

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

Re: eval trouble


From: David Kastrup
Subject: Re: eval trouble
Date: Mon, 25 Aug 2008 23:36:01 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

"Lennart Borgman (gmail)" <address@hidden> writes:

> David Kastrup wrote:
>> "Lennart Borgman (gmail)" <address@hidden> writes:
>> 
>>> Pascal J. Bourguignon wrote:
>>>> "Lennart Borgman (gmail)" <address@hidden> writes:
>>>>>> Here is the code that does NOT work:
>>>>>>
>>>>>> (defun mumamo-define-no-mode (mode-sym)
>>>>>>   (let ((mumamo-repl4 (make-symbol (format "mumamo-repl4-%s" mode-sym)))
>>>>> It works if I replace make-symbol with intern. But why does eval care
>>>>> about that?
>>>> eval doesn't care, but how would you be able to refer again to the
>>>> defined thing if you don't have its name in some dictionary?
>>>
>>> Thanks. I see. I thought eval interned the symbol, or perhaps rather
>>> created an interned symbol. In this case it does not do that.
>> 
>> Eval _does_ create an interned symbol.  But it is not EQ to the
>> unique uninterned symbol that make-symbol creates.
>
> I am a bit confused, but I guess you mean if the symbol does not exist:
>
> (let ((sym (make-symbol "xýzw")))
>   (eval `(progn (setq ,sym 1)
>                 (put ',sym 'some 'value))))

Ok, I actually talked nonsense right now: eval does _not_ create or
intern symbols.  It is the Lisp reader that creates/interns symbols when
you feed an identifier to it.  The Lisp reader will, when given the
above, maybe-create/intern/lookup all of let, sym, make-symbol, eval, \`
or something similar, progn, setq, \, or something similar, sym, put,
some and value.  And whatever else follows.

> (mapatoms (lambda (atom)
>             (when (string= (symbol-name atom)
>                            "xyzw")
>               (error "Found %s" atom))))

Well, you wrote xýzw rather than xyzw above.  But even if you didn't, as
long as nothing else interned 'xyzw in some manner, such a symbol would
not get found.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum


reply via email to

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