unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* cl-pushnew and other functions
@ 2012-06-29  4:38 John Wiegley
  2012-06-29 16:53 ` Stefan Monnier
  0 siblings, 1 reply; 10+ messages in thread
From: John Wiegley @ 2012-06-29  4:38 UTC (permalink / raw)
  To: emacs-devel

Why are we moving toward a "cl-" prefix for Common Lisp macros?  Why can we
not have function like pushnew in the global namespace?  I think Emacs Lisp
authors can benefit from a lot of these macro and functions, but I think it's
very unfortunate if code is going to start getting littered with "cl-"
prefixes for such common uses.  Are we going to have cl-dolist and cl-incf,
etc?

I think the basic function in CL should just be considered part of the Emacs
Lisp language, the same way that we have dolist in subr.el now.

John



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: cl-pushnew and other functions
  2012-06-29  4:38 cl-pushnew and other functions John Wiegley
@ 2012-06-29 16:53 ` Stefan Monnier
  2012-06-29 20:36   ` PJ Weisberg
  2012-06-29 22:17   ` John Wiegley
  0 siblings, 2 replies; 10+ messages in thread
From: Stefan Monnier @ 2012-06-29 16:53 UTC (permalink / raw)
  To: emacs-devel

> I think the basic function in CL should just be considered part of the Emacs
> Lisp language,

We simply disagree.  But at least now you can use all cl-* functions
(like cl-remove-if) in Elisp packages bundled with Emacs (tho we don't
want to preload cl-lib, so those functions cannot be used in preloaded
files).

> the same way that we have dolist in subr.el now.

Actually dolist and cl-dolist are not the same.


        Stefan



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: cl-pushnew and other functions
  2012-06-29 16:53 ` Stefan Monnier
@ 2012-06-29 20:36   ` PJ Weisberg
  2012-06-29 22:17   ` John Wiegley
  1 sibling, 0 replies; 10+ messages in thread
From: PJ Weisberg @ 2012-06-29 20:36 UTC (permalink / raw)
  Cc: emacs-devel

On Fri, Jun 29, 2012 at 9:53 AM, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:
>> I think the basic function in CL should just be considered part of the Emacs
>> Lisp language,
>
> We simply disagree.  But at least now you can use all cl-* functions
> (like cl-remove-if) in Elisp packages bundled with Emacs (tho we don't
> want to preload cl-lib, so those functions cannot be used in preloaded
> files).

And for packages *not* bundled with Emacs, you can always put

(with-no-warnings
  (require 'cl))

at the top of every file just out of obstinacy.  :-)

-PJ

Gehm's Corollary to Clark's Law: Any technology distinguishable from
magic is insufficiently advanced.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: cl-pushnew and other functions
  2012-06-29 16:53 ` Stefan Monnier
  2012-06-29 20:36   ` PJ Weisberg
@ 2012-06-29 22:17   ` John Wiegley
  2012-06-30  4:16     ` Stefan Monnier
  1 sibling, 1 reply; 10+ messages in thread
From: John Wiegley @ 2012-06-29 22:17 UTC (permalink / raw)
  To: emacs-devel

>>>>> Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

>> I think the basic function in CL should just be considered part of the
>> Emacs Lisp language,

> We simply disagree.

Why do we disagree?

John



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: cl-pushnew and other functions
  2012-06-29 22:17   ` John Wiegley
@ 2012-06-30  4:16     ` Stefan Monnier
  2012-06-30  5:44       ` Helmut Eller
                         ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Stefan Monnier @ 2012-06-30  4:16 UTC (permalink / raw)
  To: emacs-devel

>>> I think the basic function in CL should just be considered part of the
>>> Emacs Lisp language,
>> We simply disagree.
> Why do we disagree?

Because I don't want to simply adopt all those Common-Lisp-isms into
Elisp.  A big reason for that is that Elisp is not compiled
aggressively, so some design choices in Common-Lisp would be too costly
in Elisp.

Other reasons is that I do not agree with some of Common-Lisp's design
choices (question of taste).  For a recent example, define-setf-expander
is ugly and inefficient, so the new "core setf" does not fully
support it.  Other example: why have `case' when you can have `pcase'?


        Stefan



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: cl-pushnew and other functions
  2012-06-30  4:16     ` Stefan Monnier
@ 2012-06-30  5:44       ` Helmut Eller
  2012-07-02  3:50       ` John Wiegley
  2012-07-04  5:04       ` John Wiegley
  2 siblings, 0 replies; 10+ messages in thread
From: Helmut Eller @ 2012-06-30  5:44 UTC (permalink / raw)
  To: emacs-devel

* Stefan Monnier [2012-06-30 04:16] writes:

>>>> I think the basic function in CL should just be considered part of the
>>>> Emacs Lisp language,
>>> We simply disagree.
>> Why do we disagree?
>
> Because I don't want to simply adopt all those Common-Lisp-isms into
> Elisp.  A big reason for that is that Elisp is not compiled
> aggressively, so some design choices in Common-Lisp would be too costly
> in Elisp.
>
> Other reasons is that I do not agree with some of Common-Lisp's design
> choices (question of taste).  For a recent example, define-setf-expander
> is ugly and inefficient, so the new "core setf" does not fully
> support it.  Other example: why have `case' when you can have `pcase'?

Because the XEmacs has it.

Helmut




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: cl-pushnew and other functions
  2012-06-30  4:16     ` Stefan Monnier
  2012-06-30  5:44       ` Helmut Eller
@ 2012-07-02  3:50       ` John Wiegley
  2012-07-02  7:25         ` Andreas Schwab
  2012-07-04  5:04       ` John Wiegley
  2 siblings, 1 reply; 10+ messages in thread
From: John Wiegley @ 2012-07-02  3:50 UTC (permalink / raw)
  To: emacs-devel

>>>>> Stefan Monnier <monnier@iro.umontreal.ca> writes:

>>>> I think the basic function in CL should just be considered part of the
>>>> Emacs Lisp language,
>>> We simply disagree.
>> Why do we disagree?

> Because I don't want to simply adopt all those Common-Lisp-isms into Elisp.
> A big reason for that is that Elisp is not compiled aggressively, so some
> design choices in Common-Lisp would be too costly in Elisp.

Well, maybe we disagree less than we think we do. :)

If something is ugly, surprising, or has semantics outside what a veteran
Elisper would expect, I think cl- is just fine -- even called-for.

What I really prefer not to see are the everyday staples getting an ugly
prefix, cluttering up mah code.  For example: push, incf, loop,
destructuring-bind (which is already too long), etc.

> Other reasons is that I do not agree with some of Common-Lisp's design
> choices (question of taste).  For a recent example, define-setf-expander is
> ugly and inefficient, so the new "core setf" does not fully support it.

Yeah, I'm totally fine with this.  If there's a callable thing called "setf"
that does what I expect 95% of the time, call me a happy camper.

I'm not advocating CL puritanism in Emacs, by no means.  I just want count-if
and remove-if to be usable, by those names, in code I intend to contribute.
I've rewritten those functions too many times to count now because they aren't
macros.  Enough!

Some CL stuff is also just better than any other equivalent we have in core.
I know loop is a macro, so we can already use it in contributed code (can't
I?), but look how well it aids readability in a use I found for it today

Before:

    (defun gnus-harvest-bbdb-complete-stub (stub)
      (delete
       nil
       (mapcar
        #'(lambda (record)
            (let ((nets (bbdb-record-mail record)))
              (and nets
                   (format "%s <%s>" (bbdb-record-name record)
                           (car nets)))))
        (bbdb-search (bbdb-records) stub nil stub))))

After:

    (defun gnus-harvest-bbdb-complete-stub (stub)
      (loop for record in (bbdb-search (bbdb-records) stub nil stub)
            for nets = (bbdb-record-mail record)
            when nets
            collect (format "%s <%s>" (bbdb-record-name record) (car nets))))

I breathed a sigh of relief there, just reading that again.

John



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: cl-pushnew and other functions
  2012-07-02  3:50       ` John Wiegley
@ 2012-07-02  7:25         ` Andreas Schwab
  0 siblings, 0 replies; 10+ messages in thread
From: Andreas Schwab @ 2012-07-02  7:25 UTC (permalink / raw)
  To: emacs-devel

"John Wiegley" <johnw@newartisans.com> writes:

> Before:
>
>     (defun gnus-harvest-bbdb-complete-stub (stub)
>       (delete
>        nil
>        (mapcar
>         #'(lambda (record)
>             (let ((nets (bbdb-record-mail record)))
>               (and nets
>                    (format "%s <%s>" (bbdb-record-name record)
>                            (car nets)))))
>         (bbdb-search (bbdb-records) stub nil stub))))
>
> After:
>
>     (defun gnus-harvest-bbdb-complete-stub (stub)
>       (loop for record in (bbdb-search (bbdb-records) stub nil stub)
>             for nets = (bbdb-record-mail record)
>             when nets
>             collect (format "%s <%s>" (bbdb-record-name record) (car nets))))
>
> I breathed a sigh of relief there, just reading that again.

I find the latter rather un-lispy.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: cl-pushnew and other functions
  2012-06-30  4:16     ` Stefan Monnier
  2012-06-30  5:44       ` Helmut Eller
  2012-07-02  3:50       ` John Wiegley
@ 2012-07-04  5:04       ` John Wiegley
  2012-07-04 12:31         ` Stefan Monnier
  2 siblings, 1 reply; 10+ messages in thread
From: John Wiegley @ 2012-07-04  5:04 UTC (permalink / raw)
  To: emacs-devel

>>>>> Stefan Monnier <monnier@iro.umontreal.ca> writes:

> Because I don't want to simply adopt all those Common-Lisp-isms into Elisp.
> A big reason for that is that Elisp is not compiled aggressively, so some
> design choices in Common-Lisp would be too costly in Elisp.

Is it considered kosher yet to use cl.el's defun*?  I *really* miss keyword
arguments in Elisp.

John



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: cl-pushnew and other functions
  2012-07-04  5:04       ` John Wiegley
@ 2012-07-04 12:31         ` Stefan Monnier
  0 siblings, 0 replies; 10+ messages in thread
From: Stefan Monnier @ 2012-07-04 12:31 UTC (permalink / raw)
  To: emacs-devel

>> Because I don't want to simply adopt all those Common-Lisp-isms into Elisp.
>> A big reason for that is that Elisp is not compiled aggressively, so some
>> design choices in Common-Lisp would be too costly in Elisp.
> Is it considered kosher yet to use cl.el's defun*?  I *really* miss keyword
> arguments in Elisp.

It's been accepted for a long time now (grep shows it's already in use),
tho I recommend you use the cl-defun name instead, so you only need to
require `cl-lib'.


        Stefan



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-07-04 12:31 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-29  4:38 cl-pushnew and other functions John Wiegley
2012-06-29 16:53 ` Stefan Monnier
2012-06-29 20:36   ` PJ Weisberg
2012-06-29 22:17   ` John Wiegley
2012-06-30  4:16     ` Stefan Monnier
2012-06-30  5:44       ` Helmut Eller
2012-07-02  3:50       ` John Wiegley
2012-07-02  7:25         ` Andreas Schwab
2012-07-04  5:04       ` John Wiegley
2012-07-04 12:31         ` Stefan Monnier

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).