* Re: [Emacs-diffs] seq-let c856843: New macro seq-let, providing destructuring support to seq.el
[not found] ` <E1YoEpF-0005Ei-TR@vcs.savannah.gnu.org>
@ 2015-05-01 18:23 ` Stefan Monnier
2015-05-01 18:34 ` Nicolas Petton
2015-05-10 18:27 ` Nicolas Petton
0 siblings, 2 replies; 7+ messages in thread
From: Stefan Monnier @ 2015-05-01 18:23 UTC (permalink / raw)
To: emacs-devel; +Cc: Nicolas Petton
> New macro seq-let, providing destructuring support to seq.el
How 'bout adding support for `seq' to pcase instead?
I.e. add a (seq ...) pattern to pcase.
You can do that with `pcase-defmacro'.
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Emacs-diffs] seq-let c856843: New macro seq-let, providing destructuring support to seq.el
2015-05-01 18:23 ` [Emacs-diffs] seq-let c856843: New macro seq-let, providing destructuring support to seq.el Stefan Monnier
@ 2015-05-01 18:34 ` Nicolas Petton
2015-05-01 19:42 ` Bozhidar Batsov
2015-05-01 21:14 ` Stefan Monnier
2015-05-10 18:27 ` Nicolas Petton
1 sibling, 2 replies; 7+ messages in thread
From: Nicolas Petton @ 2015-05-01 18:34 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 376 bytes --]
Stefan Monnier writes:
>> New macro seq-let, providing destructuring support to seq.el
>
> How 'bout adding support for `seq' to pcase instead?
> I.e. add a (seq ...) pattern to pcase.
> You can do that with `pcase-defmacro'.
Wouldn't that be for a difference usage? If not, can you provide an
example?
Nico
--
Nicolas Petton
http://nicolas-petton.fr
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 512 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Emacs-diffs] seq-let c856843: New macro seq-let, providing destructuring support to seq.el
2015-05-01 18:34 ` Nicolas Petton
@ 2015-05-01 19:42 ` Bozhidar Batsov
2015-05-01 21:14 ` Stefan Monnier
1 sibling, 0 replies; 7+ messages in thread
From: Bozhidar Batsov @ 2015-05-01 19:42 UTC (permalink / raw)
To: Nicolas Petton; +Cc: Stefan Monnier, emacs-devel
[-- Attachment #1: Type: text/plain, Size: 492 bytes --]
seq-let seems pretty useful to me.
On 1 May 2015 at 21:34, Nicolas Petton <nicolas@petton.fr> wrote:
>
> Stefan Monnier writes:
>
> >> New macro seq-let, providing destructuring support to seq.el
> >
> > How 'bout adding support for `seq' to pcase instead?
> > I.e. add a (seq ...) pattern to pcase.
> > You can do that with `pcase-defmacro'.
>
> Wouldn't that be for a difference usage? If not, can you provide an
> example?
>
> Nico
> --
> Nicolas Petton
> http://nicolas-petton.fr
>
[-- Attachment #2: Type: text/html, Size: 1031 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Emacs-diffs] seq-let c856843: New macro seq-let, providing destructuring support to seq.el
2015-05-01 18:34 ` Nicolas Petton
2015-05-01 19:42 ` Bozhidar Batsov
@ 2015-05-01 21:14 ` Stefan Monnier
2015-05-01 21:35 ` Nicolas Petton
1 sibling, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2015-05-01 21:14 UTC (permalink / raw)
To: Nicolas Petton; +Cc: emacs-devel
> Wouldn't that be for a difference usage? If not, can you provide an
> example?
You could use it as in
(pcase-let (((seq a b) [1 2 3]))
(message "%s %s" a b))
which could return "1 2", tho that depends how you'd define the (seq
...) pattern, obviously.
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Emacs-diffs] seq-let c856843: New macro seq-let, providing destructuring support to seq.el
2015-05-01 21:14 ` Stefan Monnier
@ 2015-05-01 21:35 ` Nicolas Petton
2015-05-02 7:07 ` Stefan Monnier
0 siblings, 1 reply; 7+ messages in thread
From: Nicolas Petton @ 2015-05-01 21:35 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 633 bytes --]
Stefan Monnier writes:
>> Wouldn't that be for a difference usage? If not, can you provide an
>> example?
>
> You could use it as in
>
> (pcase-let (((seq a b) [1 2 3]))
> (message "%s %s" a b))
>
> which could return "1 2", tho that depends how you'd define the (seq
> ...) pattern, obviously.
I see, it would indeed makes sense to have it. I'll have a look at how
pcase works internally and how patterns can be defined.
I think having both would make sense though as `seq-let' is IMO simpler
to use. Maybe one could reuse code from the other.
Nico
--
Nicolas Petton
http://nicolas-petton.fr
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 512 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Emacs-diffs] seq-let c856843: New macro seq-let, providing destructuring support to seq.el
2015-05-01 21:35 ` Nicolas Petton
@ 2015-05-02 7:07 ` Stefan Monnier
0 siblings, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2015-05-02 7:07 UTC (permalink / raw)
To: Nicolas Petton; +Cc: emacs-devel
> I see, it would indeed makes sense to have it. I'll have a look at how
> pcase works internally and how patterns can be defined.
grep for pcase-defmacro: that should give you a good starting point.
> I think having both would make sense though as `seq-let' is IMO simpler
> to use. Maybe one could reuse code from the other.
I don't think the `seq' pcase pattern can be defined using seq-let, but
seq-let could easily be defined as a wrapper that expands to a pcase-let.
BTW, another advantage of defining a pcase pattern is that you could then
also do things like
(pcase-dolist ((seq a b c) my-things)
...)
-- Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Emacs-diffs] seq-let c856843: New macro seq-let, providing destructuring support to seq.el
2015-05-01 18:23 ` [Emacs-diffs] seq-let c856843: New macro seq-let, providing destructuring support to seq.el Stefan Monnier
2015-05-01 18:34 ` Nicolas Petton
@ 2015-05-10 18:27 ` Nicolas Petton
1 sibling, 0 replies; 7+ messages in thread
From: Nicolas Petton @ 2015-05-10 18:27 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 554 bytes --]
Stefan Monnier writes:
>> New macro seq-let, providing destructuring support to seq.el
>
> How 'bout adding support for `seq' to pcase instead?
> I.e. add a (seq ...) pattern to pcase.
> You can do that with `pcase-defmacro'.
I pushed in commit 387e1e1 another version that is based on pcase.
As old versions of Emacs don't provide `pcase-defmacro', I kept the old
version of seq-let for backward compatibility.
Stefan, could you review my changes, I'm quite new with pcase.
Nico
--
Nicolas Petton
http://nicolas-petton.fr
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 512 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-05-10 18:27 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20150501173408.20062.32100@vcs.savannah.gnu.org>
[not found] ` <E1YoEpF-0005Ei-TR@vcs.savannah.gnu.org>
2015-05-01 18:23 ` [Emacs-diffs] seq-let c856843: New macro seq-let, providing destructuring support to seq.el Stefan Monnier
2015-05-01 18:34 ` Nicolas Petton
2015-05-01 19:42 ` Bozhidar Batsov
2015-05-01 21:14 ` Stefan Monnier
2015-05-01 21:35 ` Nicolas Petton
2015-05-02 7:07 ` Stefan Monnier
2015-05-10 18:27 ` Nicolas Petton
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.