[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Threading / Pipe Macro (Chris Vine, Mark H Weaver)

From: Linus Björnstam
Subject: Re: Threading / Pipe Macro (Chris Vine, Mark H Weaver)
Date: Tue, 09 Jul 2019 12:52:27 +0200
User-agent: Cyrus-JMAP/3.1.6-731-g19d3b16-fmstable-20190627v1

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 <address@hidden> 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]:
> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]