From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: emacs-devel@gnu.org
Subject: Re: Help with recursive destructive function
Date: Wed, 06 Jun 2018 14:04:53 -0700 [thread overview]
Message-ID: <87wovbvd6y.fsf@ericabrahamsen.net> (raw)
In-Reply-To: 87in6yw06e.fsf@web.de
Michael Heerdegen <michael_heerdegen@web.de> writes:
> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>> [...]
>> That only worked for consp values. I don't understand this: `nth' is
>> implemented in C as (car (nthcdr)), and nthcdr looks to me like it's
>> producing a chunk of the underlying list structure. So does car of
>> nthcdr return a simple value (ie something un-setf-able)
>
> Yes, setf'able are only (some) expressions (the "place expressions"),
> not plain values. If you evaluate a (place) expression (functions
> evaluate their arguments), you loose the connection to the place.
> That's why `setf', `cl-callf', `pop' e.a. are necessarily macros.
>
> (A suggesting analogy with quantum states that collapse when measured:
> places collapse to values when passed to a function.)
Right, "places collapse to values when passed to a function". I
understood this intuitively, but was confounded by this sort of thing:
(defun my-set-car (thing)
(setcar thing 'ferrari))
(let ((tree '(1 volvo pinto)))
(my-set-car tree)
tree) => (ferrari volvo pinto)
Where it sure looks like the tree has retained its identity and
integrity throughout the operation. But this is only a side-effect of
the fact that lisp re-uses structures (I think there was a bug report
not long ago about identical strings getting re-used in unexpected
ways). And all the n* functions like `nconc' and `nreverse' only act on
lists. Okay, I think this is sinking in.
[...]
>> If that's the case, I'm not sure how to reliably pass a settable value
>> in to `deep-edit'. We could pass gv-refs into `deep-edit',
>
> That would also be my first naive idea.
>
>> In which case it would have to check values to see if they're already
>> references or not (or gv-ref itself could do that check).
>
> It's easy to change the function to accept gv-refs instead of values,
> since it already uses them internally. But AFAIK there is no test if
> some value is a `gv-ref'. Do you need deep-edit to also accept plain
> values? Then you could just pass values V as (list :value V) to make
> the cases distinguishable.
I think this function could be useful in many situations, so I'd like to
make it fairly general -- gv-refs or values.
How would you feel about gv-ref itself doing a check?
(if (and (eq 'closure (caar place))
(eq 'closure (cadr place)))
place
(gv-letplace ...etc...)
Too hacky?
Eric
next prev parent reply other threads:[~2018-06-06 21:04 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-05 1:04 Help with recursive destructive function Eric Abrahamsen
2018-05-05 1:18 ` Stefan Monnier
2018-05-05 1:37 ` Michael Heerdegen
2018-05-05 15:41 ` Michael Heerdegen
2018-05-06 17:29 ` Eric Abrahamsen
2018-05-06 19:29 ` Michael Heerdegen
2018-05-06 19:34 ` Eric Abrahamsen
2018-05-06 18:27 ` Eric Abrahamsen
2018-05-07 2:01 ` Michael Heerdegen
2018-05-07 3:01 ` Eric Abrahamsen
2018-05-07 4:16 ` Clément Pit-Claudel
2018-05-07 14:14 ` Michael Heerdegen
2018-05-07 16:26 ` Stefan Monnier
2018-05-07 16:52 ` Eric Abrahamsen
2018-05-08 13:15 ` Michael Heerdegen
2018-05-08 18:42 ` Eric Abrahamsen
2018-05-08 19:03 ` Clément Pit-Claudel
2018-05-08 19:41 ` Eric Abrahamsen
2018-05-10 1:52 ` Michael Heerdegen
2018-05-10 17:08 ` Michael Heerdegen
2018-05-11 2:12 ` Eric Abrahamsen
2018-05-14 14:27 ` Michael Heerdegen
2018-05-14 16:57 ` Eric Abrahamsen
2018-05-14 23:16 ` Michael Heerdegen
2018-05-15 0:28 ` Eric Abrahamsen
2018-07-28 20:52 ` Eric Abrahamsen
2018-07-28 23:46 ` Michael Heerdegen
2018-07-28 23:59 ` Eric Abrahamsen
2018-07-29 0:09 ` Michael Heerdegen
2018-06-04 22:28 ` Eric Abrahamsen
2018-06-05 0:23 ` Michael Heerdegen
2018-06-06 21:04 ` Eric Abrahamsen [this message]
2018-06-06 21:58 ` Michael Heerdegen
2018-06-06 22:10 ` Eric Abrahamsen
2018-06-06 23:10 ` Eric Abrahamsen
2018-06-06 23:30 ` Michael Heerdegen
2018-06-07 0:49 ` Eric Abrahamsen
2018-06-07 1:13 ` Michael Heerdegen
2018-06-06 23:18 ` Michael Heerdegen
2018-06-07 13:59 ` Stefan Monnier
2018-06-07 16:51 ` Eric Abrahamsen
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=87wovbvd6y.fsf@ericabrahamsen.net \
--to=eric@ericabrahamsen.net \
--cc=emacs-devel@gnu.org \
/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.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).