As someone who doesn't have a background in Lisp, I would expect executing
the same statement three times to give the same result as executing three
identical statements.
The three identical statements are not identical--they contain distinct
string constants.
Chong Yidong [EMAIL PROTECTED] writes:
This is a strange one. Evaluate the following two functions. Both of
them should do the same thing: replace each of the first 3 letters
in the buffer with the letter A.
(defun foo ()
(interactive)
(let ((pos '(1 2 3)))
(while pos
(defun foo ()
(interactive)
(let ((pos '(1 2 3)))
(while pos
(put-text-property (car pos) (1+ (car pos)) 'display A)
(setq pos (cdr pos)
(defun bar ()
(interactive)
(progn (put-text-property 1 2 'display A)
(put-text-property 2
(eq (substring fred 0 1) (substring fred 1 2))
nil
`substring' creates/allocates a string, so (eq (substring ...) ...) will
*always* return nil.
`eq' is pointer equality, whereas `equal' is structural equality.
Stefan
___
Emacs-pretest-bug
Forget the substring example, dotimes works like while in foo, but it still
doesn't seem right.
(setq b '())
nil
(dotimes (i 2)
(push a b))
nil
(eq (car b) (cadr b))
t
(setq b '())
nil
(push a b)
(a)
(push a b)
(a a)
(eq (car b) (cadr b))
nil
Nick
Type M-x foo. You end up with
A45
This is because the `display' property of all three characters is eq.
With bar, they are three different strings.
I will document this in the manual.
___
Emacs-pretest-bug mailing list
Forget the substring example, dotimes works like while in foo, but it still
doesn't seem right.
What doesn't seem right about it? It's bog-standard behavior.
In your (2nd) dotimes example, a only occured once in the source,so
there's really only one object a.
In the two
From my previous message:
Many other interactive languages indeed read _and_ execute
repeatedly in loops as well as in function calls, producing many
non-identical objects.
I should have said Some other interactive languages. I do not know
what percentage of interactive languages do what
Nick Roberts wrote:
As someone who doesn't have a background in Lisp, I would expect executing
the same statement three times to give the same result as executing three
identical statements.
I guess that with executed three times you mean read and evaluated
three times. The way I
As someone who doesn't have a background in Lisp, I would expect executing
the same statement three times to give the same result as executing three
identical statements. Perhaps its a bit like quantum mechanics, in that,
once you've passed the stage of disbelief, you can no longer see what
This is a strange one. Evaluate the following two functions. Both of
them should do the same thing: replace each of the first 3 letters in
the buffer with the letter A.
(defun foo ()
(interactive)
(let ((pos '(1 2 3)))
(while pos
(put-text-property (car pos) (1+ (car pos)) 'display
11 matches
Mail list logo