unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: "Linus Björnstam" <linus.internet@fastmail.se>
Cc: guile-user@gnu.org
Subject: Re: Threading / Pipe Macro (Chris Vine, Mark H Weaver)
Date: Tue, 09 Jul 2019 12:52:27 +0200	[thread overview]
Message-ID: <dbc97dc9-157c-443e-bbe3-bedad2c3f4f8@www.fastmail.com> (raw)
In-Reply-To: <20190709105823.1dc3a70b1674d5761d8d1e5c@gmail.com>

My macro is was based on the  |> pipeline from f# and on the cut macro. I then changed the syntax after seing the pipeline macro in rackjure, which is based on clojure's macros. In the beginning I wanted to do destructuring as well to allow to destructure lists and passed it as numbered arguments and such. I had a syntax-case version that did all that, but I never used that, so I wrote a syntax-rules macro instead so that I could bring it with me if I ever switched schemes (from chez). I switched to chicken and then guile and brought the macro with me. 

If you want to use it, I also provide a right-inserting macro as well: (~>> ...). The license is more or less "just don't remove this copyright notice from the source", so feel free :D

-- 
  Linus Björnstam

On Tue, 9 Jul 2019, at 11:58, Chris Vine wrote:
> On Tue, 09 Jul 2019 11:40:02 +0200
> Linus Björnstam <linus.internet@fastmail.se> wrote:
> > Sorry, I didn't see that macro. I was referring to my macro that Erik
> > linked to [1], which is a syntax rules macro that also allows for <>
> > argument placeholders:
> > 
> > (~> 1 1+ (/ 10 <>) iota (+ <...>)) => 10
> > 
> > It defaults to left insert, so
> > 
> > (~> 10 (/ 2)) => 5
> > 
> > but also (like the syntax rules macro i posted) also supports functions without parents as you can see in the first example.
> > 
> > That's what I get for trying to.follow the discussion in an unthreaded mobile app :)
> > 
> > [1]: https://bitbucket.org/bjoli/guile-threading-macros/src/default/
> 
> I thought your module/library was impressive.  My little macro (as it
> now turns out, defective in hygiene, although it has served me well for
> some time) was something I use frequently because I like the pipeline
> idiom.  It inserts to the right only, because that is what I am used
> to: it sort-of imitates the reverse application of a partially applied
> curried function.  I think your module is based on clojure macros,
> about which I know little.
>



      reply	other threads:[~2019-07-09 10:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.1204.1562538418.2685.guile-user@gnu.org>
2019-07-08 21:10 ` Threading / Pipe Macro (Chris Vine, Mark H Weaver) Zelphir Kaltstahl
2019-07-08 23:00   ` Chris Vine
2019-07-09  6:04     ` Linus Björnstam
     [not found]     ` <c95c3aa9-bd06-4a17-9392-e6256b362144@www.fastmail.com>
2019-07-09  9:26       ` Chris Vine
2019-07-09  9:40         ` Linus Björnstam
2019-07-09  9:58           ` Chris Vine
2019-07-09 10:52             ` Linus Björnstam [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dbc97dc9-157c-443e-bbe3-bedad2c3f4f8@www.fastmail.com \
    --to=linus.internet@fastmail.se \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).