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: Emanuel Berg
Subject: Re: side effects, list sharing [was: `append' vs. `nconc']
Date: Thu, 31 Dec 2015 20:00:30 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Drew Adams <drew.adams@oracle.com> writes:

> _Just don't use side effects_, at least those such
> as `nconc' that share list structure, is the right
> starting place, and is definitely the best rule of
> thumb. You will _never_ go wrong with it as your
> motto, in code you write.

As a rule of thumb it is too general to be useful, as
a motto I suppose it is OK.

> Lisp is Lisp. It is not Haskell or lambda calculus.

That's exactly right. There was a guy here, namely
Rusi, who spent much effort advocating FP. We'll see
if he jumps into the discussion.

> The two guidelines that Thomas listed are fine.
> But the most important use case for side effects using
> functions such as `nconc' has to do primarily with
> neither space nor time optimization: it is _sharing of
> list structure_ for combined effect.

Yeah, we understand that is what `nconc' do. I think
the reason Thomas said that is that was the direction
the discussion went because it all started with having
my configuration not having to copy the list as would
happen with `append'.

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?

Besides a possible time/space gain, I can only see
really creative/insane programmers doing that!

> This is Real Lisp (TM), and it is not for the
> faint-hearted. And yes, we can all be bitten
> occasionally by the gotchas, and we _all are_.
> And it can be difficult to track down the culprit
> code. Difficult or fun, depending on how much free
> time you have and how much you enjoy playing
> with Lisp.

Indeed, only I think it is the other way around:
I would get an heart attack instantly if I were to
think, argue, and code like the FP fanatics.

Math is another thing tho because math only has to
make sense and be correct, it doesn't have to work.
Programming has to work and if it makes sense all the
better :)

-- 
underground experts united
http://user.it.uu.se/~embe8573




reply via email to

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