[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] * lisp/subr.el (string-suffix-p): New function.
From: |
Lars Magne Ingebrigtsen |
Subject: |
Re: [PATCH] * lisp/subr.el (string-suffix-p): New function. |
Date: |
Sat, 23 Nov 2013 18:03:10 +0100 |
User-agent: |
Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3.50 (gnu/linux) |
Bozhidar Batsov <address@hidden> writes:
> You can't really favour this:
>
> (mapconcat 'identity '(s1 s2 s3) separator)
>
> over:
>
> (defun string-join (separator &rest strings)
> (mapconcat 'identity strings separator))
>
> (string-join separator s1 s2 s3)
Well, that's a very odd use case.
You normally have a list of strings that you want to join.
So it's either
(mapconcat 'identity list separator)
or
(apply 'string-join separator list)
which seems awfully odd. I agree that getting rid of the function
parameter would sometimes make for tidier code -- at work we have a
(txt:concat* separator list) function which is nice (in Common Lisp),
but it doesn't really seem worth it just to get rid of the function
parameter if you already have mapconcat...
If you have a few strings, then using
(concat s1 " foo " s2 " bar " s2)
seems more a more likely use case.
As for the Perl-ey chop/chomp functions, I can't (off the top of my
head) remember having much use for those functions in Emacs. And I've
done my share of process/protocol parsing.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
- Re: [PATCH] * lisp/subr.el (string-suffix-p): New function., (continued)
- Re: [PATCH] * lisp/subr.el (string-suffix-p): New function., Thien-Thi Nguyen, 2013/11/22
- Re: [PATCH] * lisp/subr.el (string-suffix-p): New function., Bozhidar Batsov, 2013/11/22
- Re: [PATCH] * lisp/subr.el (string-suffix-p): New function., Lars Magne Ingebrigtsen, 2013/11/22
- Re: [PATCH] * lisp/subr.el (string-suffix-p): New function., Bozhidar Batsov, 2013/11/22
- Re: [PATCH] * lisp/subr.el (string-suffix-p): New function., Stefan Monnier, 2013/11/22
- Re: [PATCH] * lisp/subr.el (string-suffix-p): New function., Bozhidar Batsov, 2013/11/22
- Re: [PATCH] * lisp/subr.el (string-suffix-p): New function., Stefan Monnier, 2013/11/22
- Re: [PATCH] * lisp/subr.el (string-suffix-p): New function., Josh, 2013/11/23
- Re: [PATCH] * lisp/subr.el (string-suffix-p): New function., Stefan Monnier, 2013/11/23
- Re: [PATCH] * lisp/subr.el (string-suffix-p): New function., Stephen J. Turnbull, 2013/11/23
- Re: [PATCH] * lisp/subr.el (string-suffix-p): New function.,
Lars Magne Ingebrigtsen <=
Re: [PATCH] * lisp/subr.el (string-suffix-p): New function., Jarek Czekalski, 2013/11/22