emacs-tangents
[Top][All Lists]
Advanced

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

Re: 2016-05-23 Emacs News


From: Rolf Ade
Subject: Re: 2016-05-23 Emacs News
Date: Fri, 10 Jun 2016 17:22:16 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Marcin Borkowski <address@hidden> writes:
> On 2016-06-10, at 15:37, Rolf Ade <address@hidden> wrote:
>> Nicolas Richard <address@hidden> writes:
>>> Rolf Ade <address@hidden> writes:
>>>> (That is:
>>>> http://mbork.pl/2016-05-23_Literal_values_and_destructive_functions)
>>>> 
>>>> Wait, what?
>>>> [...]
>>>> in *Messages*. Could someone please explain that to me?
>>>
>>> The article you're referring to explains just that. Is it somehow
>>> unclear ? Quoting the article:
>>>
>>> | What’s going on?
>>> | 
>>> | Well, the literal in the function definition was actually changed. (If
>>> | you evaluate the defun form now, it will be redefined once again to
>>> | the “correct” value.) If you don’t believe it, try this: M-:
>>> | (symbol-function #'destructive-havoc), or even better, M-x
>>> | pp-eval-expression RET (symbol-function #'destructive-havoc) RET and
>>> | see for yourself.
>>
>> Well ..., sorry, yes, that explanation isn't clear to me. [...]
>
> It's not like `sort' changes the _function_.  But the function contains
> a _literal structure_ (like "a constant"), and it is remembered as
> a "pointer" (conceptually, not necessarily in C sense).  So when `sort'
> changes the structure "pointed to" by its argument (and it gets the
> "pointer" to the very same structure referred to by the function), it
> looks like the function is changed.
>
> Is that better?  (If yes, I'll amend the article.)

Hrrrhmm ... this discussion forces me, to paint myself as blockhead, but
no, it still feels I poke around in the dark with a long stick.

I could accept, that '(1 3 2) defines some global "constant", that gets
modified by the `sort' call.

But if I then look at:

(defun destructive-havoc1 ()
  "Example of destructive havoc."
  (setq foo '(1 3 2))
  (message "before sort, foo is: %s" foo)
  (sort foo #'<)
  (message "after sort, foo is: %s" foo))

(defun destructive-havoc2 ()
  "Example of destructive havoc."
  (setq foo '(1 3 2))
  (message "before sort, foo is: %s" foo)
  (sort foo #'<)
  (message "after sort, foo is: %s" foo))

Evalute both defuns. Then do M-: (destructive-havoc1), then M-:
(destructive-havoc2), then look at the *Messages* buffer. I see

before sort, foo is: (1 3 2)
after sort, foo is: (1 2 3)
before sort, foo is: (1 3 2)
after sort, foo is: (1 2 3)

So, ... '(1 3 2) defines some (defun local) "constant" ...?

I'm still afraid, I miss completely some basic concept or syntax
understanding.




reply via email to

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