News for hackers. Stuff that matters.
Re:F.el: Modern API for working with files and directories i... by fishbacon on Wednesday July 06, 2022 @05:08AM (#31998496)
When it comes to f and s. Yes. Definitely, I do not want them and I do not need them.

I like dash because it gives me the convenience of threading macros and anaphoric functions. Are there options for those in compat/emacs standard?

Re:F.el: Modern API for working with files and directories i... by bollu on Wednesday July 06, 2022 @06:38AM (#31999072)
What is an anaphoric function / macro? I've seen this term floating around and I don't know what it means!
Re:F.el: Modern API for working with files and directories i... by iib on Wednesday July 06, 2022 @07:19AM (#31999337)
Page 189 of Paul Graham's "On Lisp" [1] introduces for the first time such a function. At least that is what I remember, and also what Wiki [2] seems to say.

[1] http://ep.yimg.com/ty/cdn/paulgraham/onlisp.pdf

[2] https://en.wikipedia.org/wiki/Anaphoric_macro

Re:F.el: Modern API for working with files and directories i... by pmontra on Wednesday July 06, 2022 @11:02AM (#32002021)
Neither did I and so I searched for it and got prompted to post this offtopic reply (hopefully interesting for future debates on search engines.)

I looked for anaphoric functions elisp on both DDD and Google. I believe that DDD uses Bing so TL;DR: Bing is not good at searching stuff, only basic queries. After maybe a couple of years of DDD I intuitively knew that I would have had to ask that question to Google.

Re:F.el: Modern API for working with files and directories i... by daptaq on Wednesday July 06, 2022 @05:21AM (#31998573)
Dash is weird because it is both a list library and and bundles macros. Conventional Emacs Lisp does not use anaphoric macros, and to my knowledge the ideomacy their usage is generally contested.

Threading macros and stuff like if-let & co. have been available for a while and are backported by compat.

Re:F.el: Modern API for working with files and directories i... by fishbacon on Wednesday July 06, 2022 @06:32AM (#31999033)
Most of the time when I am just coding on my personal or small emacs lisp packages I really like the convenience of anaphoric functions.

I have never seen an example of if-let that made me understand it, but I see thread-first and thread-last, those may be useful.

Thanks!

Re:F.el: Modern API for working with files and directories i... by daptaq on Wednesday July 06, 2022 @03:52PM (#32005944)
> I have never seen an example of if-let that made me understand it, but I see thread-first and thread-last, those may be useful.

They are often useful when you have a computation that might fail at any step, sort of like with Maybe monads in Haskell. Eg. if I want to retrive a password from auth-source, it might be that no entry exists, or that the entry has no password entry. In that case I do:

    (if-let* ((auth (auth-source-search :host "domain.org"
                                        :create t))
              (func (plist-get (car auth) :secret))
              (pass (funcall func)))
        (use-to-login-to-some-service pass)
      (user-error "Cannot find password"))
Re:F.el: Modern API for working with files and directories i... by mickeyp on Wednesday July 06, 2022 @05:56AM (#31998788)
Emacs has `thread-first' and `thread-last'.
Re:F.el: Modern API for working with files and directories i... by bollu on Wednesday July 06, 2022 @06:39AM (#31999078)
What is an anaphoric function and why would I want it?