[Top][All Lists]

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

bug#33998: 27.0.50; cl-delete does not delete the first list element

From: Drew Adams
Subject: bug#33998: 27.0.50; cl-delete does not delete the first list element
Date: Tue, 8 Jan 2019 10:22:42 -0800 (PST)

> > > > > So, cumbersome as it is, you should always use:
> > > >                                ^^^^^^^^^^^^^
> > > > > (setq seq (cl-delete thing seq))
> > > >
> > > > FWIW, this is not really true.
> > > >
> > > > `cl-delete' deletes THING from the
> > > > _value_ of SEQ.  You might or you
> > > > might not want variable SEQ to have
> > > > the updated value.
> > >
> > > But this is what he wanted, so what's
> > > the point in making this more confusing
> > > than it needs to be?
> >
> > It's enough to suggest that he might want
> > to do that, and point to the manual for
> > explanation.  It's the "always" that's
> > misleading.
> Actually, as I've subsequently demonstrated
> the leeway given to cl-delete by the CL spec
> is such that it is quite a good idea to *always*
> use the (setq SEQ (cl-delete THING SEQ)) idiom,
> because you have no control on what cl-delete
> does with SEQ. You might indeed not want it
> changed but it may change, and not in ways
> you can predict.

No.  This has nothing to do with CL or the
CL spec or the implementation of `cl-delete'.

Again, you should set the variable to the value
returned by `cl-delete' only if that's what you
want - only if you want the variable to point
to the result of the operation instead of what
it pointed to previously.

This is so, regardless of what the result of
that operation might be - regardless of how
`cl-delete' is implemented or even what it
might do.

It's about the difference between a variable
and its value.  `cl-delete' can only act on
the value, not on the variable (it never sees
the variable).  Only other code can decide
whether the variable should be set to the
return value of `cl-delete'.  If yes, then
`setq'; if no, then no `set'`.

Pretty simple, really.

reply via email to

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