help-gnu-emacs
[Top][All Lists]
Advanced

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

RE: side effects, list sharing [was: `append' vs. `nconc']


From: Drew Adams
Subject: RE: side effects, list sharing [was: `append' vs. `nconc']
Date: Thu, 31 Dec 2015 11:15:09 -0800 (PST)

> But other then time/space optimization, what would you
> say is the reason not to play it safe/sane and just
> return stuff, new stuff if necessary, but instead
> modify them directly?

You will know it if you see it or when you really need it!

If you don't see a need for sharing list structure then
playing it safe/sane is the right approach.

If you are modifying someone else's code, and you see
structure-modifying code, that is, code that indicates
that list-sharing is going on, then you need to wake up
and take that into consideration.

Otherwise, there is no need to worry about it - just
play it safe/sane and Bob's your uncle.

If you just want to learn about such use cases, look
through existing Lisp code for uses of `setcar' and
company.  I can almost guarantee that they are not
used gratuitously.

And unless you see them used in a clearly local and
safe/encapsulated fashion, look around for what's
really going on, to see why that code uses list-sharing.



reply via email to

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