as-> vs cut-like argument insertion Linus Björnstam (09 Jun 2020 07:10 UTC)
Re: as-> vs cut-like argument insertion John Cowan (09 Jun 2020 17:55 UTC)
Re: as-> vs cut-like argument insertion Adam Nelson (31 Aug 2020 16:45 UTC)

as-> vs cut-like argument insertion Linus Björnstam 09 Jun 2020 07:09 UTC

Hi!

First of all, thank you for taking the time to write this srfi! A threading macro was probably the first macro I wrote when I properly learned to write macros, and I use them daily.

Being a heavy user of srfi-26 (cut) as well, I went with a cut-like syntax, so instead of using as-> I could simply use <> and <...> as argument placeholders. Since we already have a common and standardised syntax for placeholders, why not use that? That allows for the extra benefits of being able to do (-> (list 1 2 3) (+ <...>)) -> 6.

My implementation of that can be found here:
https://hg.sr.ht/~bjoli/guile-threading-macros. Don't look too closely at the source. It is more or less the first non-trivial macro I wrote (back in 2010, I don't know why the copyright statement doesn't convey that. I should fix that).

It is implemented as syntax-rules, and should as such be portable.

I don't really mind this syntax, as it is less "magic", but since we already have a magic syntax, we could standardise on that. It complicates the implementation, but not by much. If you like the idea, you can take my code. I can release my copyright for it for inclusion in a srfi.
--
  Linus Björnstam