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

[feature] anaphoric cl-callf(*) #352

Open
yyoncho opened this issue Dec 20, 2020 · 6 comments
Open

[feature] anaphoric cl-callf(*) #352

yyoncho opened this issue Dec 20, 2020 · 6 comments
Labels
discussion enhancement Suggestion to improve or extend existing behavior

Comments

@yyoncho
Copy link
Contributor

yyoncho commented Dec 20, 2020

here it is what you can do now:

(let ((ht (make-hash-table :test 'equal)))
  (cl-callf (lambda (s) (concat "FOO" s)) (gethash "BAR" ht))
  (cl-callf (lambda (s) (concat "-FOO2" s)) (gethash "BAR" ht))
  ht)

here it is what it can be with dash:

(let ((ht (make-hash-table :test 'equal)))
  (--callf (concat "FOO" it) (gethash "BAR" ht))
  (--callf (concat "-FOO2" it) (gethash "BAR" ht))
  ht)
@yyoncho
Copy link
Contributor Author

yyoncho commented Dec 20, 2020

FTR the lambda has to be more complex otherwise

(let ((ht (make-hash-table :test 'equal)))
  (cl-callf concat (gethash "BAR" ht) "FOO")
  (cl-callf concat (gethash "BAR" ht) "FOO")
  ht)

would work too.

@alphapapa
Copy link

I guess you mean "anaphoric." ;)

Yes, this would be a useful macro.

@yyoncho yyoncho changed the title [feature] anamorphic cl-callf(*) [feature] anaphoric cl-callf(*) Dec 20, 2020
@yyoncho
Copy link
Contributor Author

yyoncho commented Dec 20, 2020

I guess you mean "anaphoric." ;)

Yes, fixed :)

@basil-conto
Copy link
Collaborator

FTR the lambda has to be more complex otherwise [...] would work too.

Yes, or you could use cl-callf2.

here it is what it can be with dash:

Sorry, I fail to see the relation between CL macros and a list processing library whose whole motto is "no CL needed".

The anaphoric macros that Dash provides are indeed handy and efficient shorthands, but that doesn't make Dash a library that provides anaphoras for everything under the sun.

@yyoncho
Copy link
Contributor Author

yyoncho commented Dec 20, 2020

Sorry, I fail to see the relation between CL

There is no relation, I used CL as an example. AFAICS macro can be implemented without CL dep.

list processing library

There are ->, ->>, -doto, etc which are not related to list processing but they are pretty much clojure ports. In this case, --callf is the equivalent to the swap!(disregarding the fact that elisp's places are not exactly equivalent to clojure's atoms). Having them will help with "no CL needed".

The anaphoric macros that Dash provides are indeed handy and efficient shorthands, but that doesn't make Dash a library that provides anaphoras for everything under the sun

I guess it is fine to reject the feature request.

@basil-conto
Copy link
Collaborator

AFAICS macro can be implemented without CL dep.

You mean by using gv.el? That would require Emacs >= 24.3.

There are ->, ->>, -doto, etc which are not related to list processing but they are pretty much clojure ports.

I never said I was a fan of those. ;)

I guess it is fine to reject the feature request.

I'm not going to because it's up to the maintainers.

It's just that to me, wrapping generalised variables in anaphora sounds both out of scope of efficient and pure list processing, and like it could potentially be a can of worms or slippery slope.

@basil-conto basil-conto added discussion enhancement Suggestion to improve or extend existing behavior labels Jan 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion enhancement Suggestion to improve or extend existing behavior
Projects
None yet
Development

No branches or pull requests

3 participants