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

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

Re: Easy to add with push but not to the end of a list


From: Heime
Subject: Re: Easy to add with push but not to the end of a list
Date: Tue, 29 Nov 2022 07:56:53 +0000

------- Original Message -------
On Tuesday, November 29th, 2022 at 5:23 AM, <tomas@tuxteam.de> wrote:


> On Mon, Nov 28, 2022 at 10:01:24PM +0000, Heime wrote:
> 
> > ------- Original Message -------
> > On Monday, November 28th, 2022 at 8:19 PM, Emanuel Berg incal@dataswamp.org 
> > wrote:
> > 
> > > Stefan Monnier via Users list for the GNU Emacs text editor wrote:
> > > 
> > > > > Although it is easy to add to a list using push, it
> > > > > currently looks hideous to be able to add to the end of
> > > > > a list.
> > > > 
> > > > That's because adding to the end of a Lisp list is
> > > > a bad idea.
> > 
> > The bad idea comment disregards necessity...
> 
> 
> Q "But I /want/ to hit this nail into the wall with a spoon!"
> 
> A "You can try. But please, do it in your living room. And
> oh, with your own spoon"
> 
> Programming is somewhere between engineering and craft. In
> these realms, you usually try to think about what tools are
> appropriate for a job.

Programming has got nothing to do with engineering or craft.  
 
> Singly linked lists are a tool. They are simple, lightweight,
> and appropriate for keeping things in sequence, and for adding
> things at the front. Not at the end.

Stefan mentioned using reverse to put it into another list.  If needed
the execution time would not be much different than actually place
new elements at end of list.
 
> Core library functions express idioms. They are expected to
> help people to find patterns on how to use tools appropriately
> (it's not much different from tools: a screwdriver has a
> handle, which spells "grip me here, please").
> 
> Adding a function to core (say `hsup') which suggests that
> it is as easy to push something at the end of a list would
> be misleading people to hold the screwdriver (or the knife!)
> at the wrong end and hurt themselves.

Nobody will get hurt.  Just inefficient for long lists or for
large number of calls.
 
> Cheers
> --
> t



reply via email to

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