Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: Add variant of -each with -let binding #136

Open
Fuco1 opened this issue May 2, 2015 · 4 comments · May be fixed by #272
Open

FR: Add variant of -each with -let binding #136

Fuco1 opened this issue May 2, 2015 · 4 comments · May be fixed by #272
Labels
enhancement Suggestion to improve or extend existing behavior

Comments

@Fuco1
Copy link
Collaborator

Fuco1 commented May 2, 2015

Right now, we need

(-each '((a . b) (c . d))
  (-lambda ((first . second)) (code-using first second))

Could be

(-??? (first . second) '((a . b) (c . d))
  (code-using first second))

Similar like cl-dolist with destructuring.

Edit: for completeness, here's a version of hypothetical -dolist

(-dolist ((first . second) '((a . b) (c . d)))
  (code-using first second))
@Wilfred
Copy link
Contributor

Wilfred commented Sep 24, 2017

FWIW, I think using -each with -lambda is very readable already.

@Fuco1
Copy link
Collaborator Author

Fuco1 commented Sep 25, 2017

I guess I was looking for something like foreach in the traditional languages, i.e in Java you write for (Foo stuff : stuffs) but I can imagine doing destructuring on stuff. In php you can do the rather handy foreach ($stuffs as $key => $value) which would cover a lot of boring iteration over plists/alists in Elisp as well.

Maybe we could call it -foreach. Or maybe we just don't need it, dunno.

@Wilfred
Copy link
Contributor

Wilfred commented Sep 26, 2017

I suppose we could add a -dolist that supported destructuring?

@Fuco1 Fuco1 added the enhancement Suggestion to improve or extend existing behavior label Jul 26, 2018
@Fuco1 Fuco1 linked a pull request Jul 26, 2018 that will close this issue
@Fuco1
Copy link
Collaborator Author

Fuco1 commented Jul 26, 2018

I've implemented this in a pull request, not sure about the naming though. -dolist is natural choice but does not fit with the dash's use of -each for the same concept.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Suggestion to improve or extend existing behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants