unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* What's wrong with value?
@ 2003-02-06 16:50 Pascal Bourguignon
  2003-02-06 17:05 ` Barry Margolin
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Pascal Bourguignon @ 2003-02-06 16:50 UTC (permalink / raw)



What's happening with this symbol:

(setq value :toto) ;; C-x C-e, :toto appears in Mini-buffer.
(show value)       ;; But value has not been assigned!
==> nil

(progn (setq value :toto)
       (show value))         ;; well, here yes it's assigned !
==> :toto
(show value)                 ;; but not here !?!?  What's happening?
==> nil
(show (assoc 'value (buffer-local-variables)))
==> nil

(show (version))
==> "GNU Emacs 21.2.1 (i686-pc-linux-gnu, X toolkit)
 of 2002-10-26 on thalassa"


(defun show (&rest x)
  "Insert the formated value X."
  (unless (= (point) (progn (beginning-of-line) (point))) 
    (end-of-line)
    (insert "\n"))
  (insert (format "==> %S\n"
      (if (= 1 (length x)) (car x) x)))
  (if (= 1 (length x)) (car x) x)
  );;show


(progn
  (setq key 'ListenAddress)
  (setq value '("127.0.0.3" . 25002))
  (show value)
  (show (symbol-value 'value))
  (show (symbol-function 'value))
  (show (symbol-plist 'value))
  (show (assoc 'value (buffer-local-variables)))
  (show (format "%-30s   %s port %s\n" key (car value) (cdr value)))
  )
==> ("127.0.0.3" . 25002)
==> ("127.0.0.3" . 25002)
==> (lambda (&rest local-args) "Retrieves the slot `value' from an object of class `AEToken'" (eieio-generic-call (quote value) local-args))
==> (eieio-generic t eieio-method-tree [nil nil ((AEToken lambda (this) "Retrieves the slot `value' from an object of class `AEToken'" (eieio-oref this (quote value)))) nil nil nil nil] eieio-method-obarray [[0 0 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 AEToken 0 0] [0 0 0 0 0 0 0 0 0 0 0] nil nil nil] setf-method (lambda (widget) (block value (let* ((--widget--temp-- (gensym "--widget--")) (--store--temp-- (gensym "--store--"))) (list (list . #1=(--widget--temp--)) (list widget) (list --store--temp--) (let* ((widget --widget--temp--) (store --store--temp--)) (list (quote eieio-oset) widget (quote (quote value)) store)) (list (quote value) . #1#))))))
==> nil
==> "ListenAddress                    127.0.0.3 port 25002
"

(show (symbol-value 'value))
==> nil
(show (symbol-function 'value))
==> (lambda (&rest local-args) "Retrieves the slot `value' from an object of class `AEToken'" (eieio-generic-call (quote value) local-args))
(show (symbol-plist 'value))
==> (eieio-generic t eieio-method-tree [nil nil ((AEToken lambda (this) "Retrieves the slot `value' from an object of class `AEToken'" (eieio-oref this (quote value)))) nil nil nil nil] eieio-method-obarray [[0 0 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 AEToken 0 0] [0 0 0 0 0 0 0 0 0 0 0] nil nil nil] setf-method (lambda (widget) (block value (let* ((--widget--temp-- (gensym "--widget--")) (--store--temp-- (gensym "--store--"))) (list (list . #1=(--widget--temp--)) (list widget) (list --store--temp--) (let* ((widget --widget--temp--) (store --store--temp--)) (list (quote eieio-oset) widget (quote (quote value)) store)) (list (quote value) . #1#))))))
(show (assoc 'value (buffer-local-variables)))
==> nil
(show (format "%-30s   %s port %s\n" key (car value) (cdr value)))
==> "ListenAddress                    nil port nil
"


Note that  while 'value is a  method defined with eieio,  it's not the
only one and other don't have this problem:


(setq generate-conf :titi)
(show generate-conf)
==> :titi
(show (symbol-plist 'generate-conf))
==> (eieio-generic t eieio-method-tree [nil nil ((Generic . #[(self) "\303\304\305\b!\"\303\306\305\b!\"\x19\x1a\307
\310\"\210\212\311	!\210\312 \210\313\314\b!!c\210\315\316!\210\317p!\210\320\316!+\207" [self conf-file etc-dir format "%s/etc" instance-dir "%s/etc/avmailgate.conf" make-directory t find-file erase-buffer generate-configuration config save-buffer 0 kill-buffer sleep] 5 "
DO:      Writes the avmailgate.conf file for this test case.
"])) nil nil nil nil] eieio-method-obarray [[0 0 0 0 0 0 0 0 0 0 0] [0 Avgated-listen 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 Avgated-listen 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Generic 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [0 Avgated-listen 0 0 0 0 0 0 0 0 0] nil nil nil])


-- 
__Pascal_Bourguignon__                   http://www.informatimago.com/
----------------------------------------------------------------------
There is a fault in reality. Do not adjust your minds. -- Salman Rushdie

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: What's wrong with value?
  2003-02-06 16:50 What's wrong with value? Pascal Bourguignon
@ 2003-02-06 17:05 ` Barry Margolin
  2003-02-06 17:44 ` Jesper Harder
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Barry Margolin @ 2003-02-06 17:05 UTC (permalink / raw)


In article <871y2l73pv.fsf@thalassa.informatimago.com>,
Pascal Bourguignon  <pjb@informatimago.com> wrote:
>
>What's happening with this symbol:
>
>(setq value :toto) ;; C-x C-e, :toto appears in Mini-buffer.
>(show value)       ;; But value has not been assigned!
>==> nil
>
>(progn (setq value :toto)
>       (show value))         ;; well, here yes it's assigned !
>==> :toto
>(show value)                 ;; but not here !?!?  What's happening?
>==> nil
>(show (assoc 'value (buffer-local-variables)))
>==> nil

Try 'C-h v value'

-- 
Barry Margolin, barmar@genuity.com
Genuity Managed Services, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: What's wrong with value?
  2003-02-06 16:50 What's wrong with value? Pascal Bourguignon
  2003-02-06 17:05 ` Barry Margolin
@ 2003-02-06 17:44 ` Jesper Harder
  2003-02-06 18:28   ` David Kastrup
  2003-02-06 18:47 ` Greg Hill
       [not found] ` <mailman.1580.1044557265.21513.help-gnu-emacs@gnu.org>
  3 siblings, 1 reply; 8+ messages in thread
From: Jesper Harder @ 2003-02-06 17:44 UTC (permalink / raw)


Pascal Bourguignon <pjb@informatimago.com> writes:

> What's happening with this symbol:
>
> (setq value :toto) ;; C-x C-e, :toto appears in Mini-buffer.
> (show value)       ;; But value has not been assigned!
> ==> nil
>
> Note that  while 'value is a  method defined with eieio

I don't think eieio is the culprit.

Try it with a clean 'emacs -q --no-site-file' -- the same thing happens.
Very mysterious!

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: What's wrong with value?
  2003-02-06 17:44 ` Jesper Harder
@ 2003-02-06 18:28   ` David Kastrup
  2003-02-06 20:31     ` Pascal Bourguignon
  0 siblings, 1 reply; 8+ messages in thread
From: David Kastrup @ 2003-02-06 18:28 UTC (permalink / raw)


Jesper Harder <harder@myrealbox.com> writes:

> Pascal Bourguignon <pjb@informatimago.com> writes:
> 
> > What's happening with this symbol:
> >
> > (setq value :toto) ;; C-x C-e, :toto appears in Mini-buffer.
> > (show value)       ;; But value has not been assigned!
> > ==> nil
> >
> > Note that  while 'value is a  method defined with eieio
> 
> I don't think eieio is the culprit.
> 
> Try it with a clean 'emacs -q --no-site-file' -- the same thing happens.
> Very mysterious!

(defun eval-last-sexp (eval-last-sexp-arg-internal)
  "Evaluate sexp before point; print value in minibuffer.
Interactively, with prefix argument, print output into current buffer."
  (interactive "P")
  (if (null eval-expression-debug-on-error)
      (eval-last-sexp-1 eval-last-sexp-arg-internal)
    (let ((old-value (make-symbol "t")) new-value value)
      (let ((debug-on-error old-value))
	(setq value (eval-last-sexp-1 eval-last-sexp-arg-internal))
	(setq new-value debug-on-error))
      (unless (eq old-value new-value)
	(setq debug-on-error new-value))
      value)))

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: What's wrong with value?
  2003-02-06 16:50 What's wrong with value? Pascal Bourguignon
  2003-02-06 17:05 ` Barry Margolin
  2003-02-06 17:44 ` Jesper Harder
@ 2003-02-06 18:47 ` Greg Hill
       [not found] ` <mailman.1580.1044557265.21513.help-gnu-emacs@gnu.org>
  3 siblings, 0 replies; 8+ messages in thread
From: Greg Hill @ 2003-02-06 18:47 UTC (permalink / raw)


Pascal,

For whatever it's worth...

I just pasted the code from your email into the scratch buffer in 
both Emacs-20 and Emacs-21, executed the defun of show, then

(setq value :toto)
(show value)

and got

==> :toto

--Greg

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: What's wrong with value?
  2003-02-06 18:28   ` David Kastrup
@ 2003-02-06 20:31     ` Pascal Bourguignon
  0 siblings, 0 replies; 8+ messages in thread
From: Pascal Bourguignon @ 2003-02-06 20:31 UTC (permalink / raw)


David Kastrup <dak@gnu.org> writes:

> Jesper Harder <harder@myrealbox.com> writes:
> 
> > Pascal Bourguignon <pjb@informatimago.com> writes:
> > 
> > > What's happening with this symbol:
> > >
> > > (setq value :toto) ;; C-x C-e, :toto appears in Mini-buffer.
> > > (show value)       ;; But value has not been assigned!
> > > ==> nil
> > >
> > > Note that  while 'value is a  method defined with eieio
> > 
> > I don't think eieio is the culprit.
> > 
> > Try it with a clean 'emacs -q --no-site-file' -- the same thing happens.
> > Very mysterious!
> 
> (defun eval-last-sexp (eval-last-sexp-arg-internal)
>   "Evaluate sexp before point; print value in minibuffer.
> Interactively, with prefix argument, print output into current buffer."
>   (interactive "P")
>   (if (null eval-expression-debug-on-error)
>       (eval-last-sexp-1 eval-last-sexp-arg-internal)
>     (let ((old-value (make-symbol "t")) new-value value)
>       (let ((debug-on-error old-value))
> 	(setq value (eval-last-sexp-1 eval-last-sexp-arg-internal))
> 	(setq new-value debug-on-error))
>       (unless (eq old-value new-value)
> 	(setq debug-on-error new-value))
>       value)))

Yes,  I thought  about something  like  that.  Hence  the interest  of
lexical scoping of Common-Lisp...

Thank you.

-- 
__Pascal_Bourguignon__                   http://www.informatimago.com/
----------------------------------------------------------------------
There is a fault in reality. Do not adjust your minds. -- Salman Rushdie

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: What's wrong with value?
       [not found] ` <mailman.1580.1044557265.21513.help-gnu-emacs@gnu.org>
@ 2003-02-06 20:44   ` Pascal Bourguignon
  2003-02-07  0:07     ` Greg Hill
  0 siblings, 1 reply; 8+ messages in thread
From: Pascal Bourguignon @ 2003-02-06 20:44 UTC (permalink / raw)


Greg Hill <ghill@synergymicro.com> writes:

> Pascal,
> 
> For whatever it's worth...
> 
> I just pasted the code from your email into the scratch buffer in both
> Emacs-20 and Emacs-21, executed the defun of show, then
> 
> (setq value :toto)
> (show value)
> 
> and got
> 
> ==> :toto

If  you used  eval-region, ok,  I  too get  :toto.  But  with C-x  C-e
(ie. eval-last-sexp),  it's the value  in the let  of eval-last-sexp-1
that gets setq'ed, and it's that same value in that let that is passed
to my show function.

Since eval-region is a built-in, it should not shade any lisp variable
I  guess.    Perhaps  eval-last-sexp-1  should   be  implemented  with
eval-region avoiding any variables.

-- 
__Pascal_Bourguignon__                   http://www.informatimago.com/
----------------------------------------------------------------------
There is a fault in reality. Do not adjust your minds. -- Salman Rushdie

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: What's wrong with value?
  2003-02-06 20:44   ` Pascal Bourguignon
@ 2003-02-07  0:07     ` Greg Hill
  0 siblings, 0 replies; 8+ messages in thread
From: Greg Hill @ 2003-02-07  0:07 UTC (permalink / raw)


At 9:44 PM +0100 2/6/03, Pascal Bourguignon wrote:
<snip>
>If  you used  eval-region, ok,  I  too get  :toto.  But  with C-x  C-e
>(ie. eval-last-sexp), ...
<snip>

Pascal,

The problem does not appear in Emacs-20.3, even for eval-last-sexp.

At first I couldn't replicate it in Emacs-21.2 either.  But then I 
tried starting Emacs with the -q command line option, and was finally 
able to see it happen.  I tracked down the difference to the presence 
of:

(when (> emacs-major-version 20)
   (setq-default eval-expression-debug-on-error nil))

in my .emacs file, which prevents the problem from appearing.

--Greg

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2003-02-07  0:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-02-06 16:50 What's wrong with value? Pascal Bourguignon
2003-02-06 17:05 ` Barry Margolin
2003-02-06 17:44 ` Jesper Harder
2003-02-06 18:28   ` David Kastrup
2003-02-06 20:31     ` Pascal Bourguignon
2003-02-06 18:47 ` Greg Hill
     [not found] ` <mailman.1580.1044557265.21513.help-gnu-emacs@gnu.org>
2003-02-06 20:44   ` Pascal Bourguignon
2003-02-07  0:07     ` Greg Hill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).