unofficial mirror of emacs-tangents@gnu.org
 help / color / mirror / Atom feed
From: Marcin Borkowski <mbork@mbork.pl>
To: Rolf Ade <rolf@pointsman.de>
Cc: emacs-tangents@gnu.org
Subject: Re: 2016-05-23 Emacs News
Date: Fri, 10 Jun 2016 15:52:21 +0200	[thread overview]
Message-ID: <87shwlf8x6.fsf@mbork.pl> (raw)
In-Reply-To: <8737oldv21.fsf@linux-qg7d.fritz.box>


On 2016-06-10, at 15:37, Rolf Ade <rolf@pointsman.de> wrote:

> Nicolas Richard <youngfrog@members.fsf.org> writes:
>> Rolf Ade <rolf@pointsman.de> 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. While I'm
> far away to claim I'm a versed emacs lisp programmer, I've written a few
> screen full of emacs lisp code. Now this thing left me back with the
> feeling, that I've missed to understand something at the core of the
> language (with the additional unpleasant feeling, that my emacs lisp
> programming is even more cargo cult coding, than I already suspected).
>
> The "explanation", that the literal in the function definition was
> changed by the (sort) call doesn't help me on track. While I'm fluent
> with other programming languages, that are able to rewrite function
> definitions during run-time I don't know a programming language that do
> this as a 'side effect' of a function call (other than you craft one,
> that deliberate does so).
>
> Is what the article demonstrates something special to the 'build-in'
> function sort or to emacs lisp? It would help me, if someone explains
> what happen in this example in other words (not in implementation detail
> but language concepts).

Hi,

original author here.  Sorry for being rather terse.  I've got only
a couple of minutes, but let me try.

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.)

BTW, AFAIK, other Lisps have it similar with destructive functions.

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



  reply	other threads:[~2016-06-10 13:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-23 16:44 2016-05-23 Emacs News Sacha Chua
2016-06-10  0:04 ` Rolf Ade
2016-06-10 10:30   ` Nicolas Richard
2016-06-10 13:37     ` Rolf Ade
2016-06-10 13:52       ` Marcin Borkowski [this message]
2016-06-10 15:22         ` Rolf Ade
2016-06-10 16:45           ` John Mastro
2016-06-10 14:55       ` Nicolas Richard
2016-06-10 16:01         ` Rolf Ade

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87shwlf8x6.fsf@mbork.pl \
    --to=mbork@mbork.pl \
    --cc=emacs-tangents@gnu.org \
    --cc=rolf@pointsman.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).