Threading / Pipe Macro

2019-07-07 Thread Zelphir Kaltstahl
Hi Guile Users! I recently looked at some online course about Elixir and saw an elegant use of pipes (the operator `|>` in Elixir). Then I remembered, that in Racket there are so called threading macros, which seem to accomplish the same: https://github.com/lexi-lambda/threading/blob/master/threa

Re: Threading / Pipe Macro

2019-07-07 Thread Chris Vine
On Sun, 7 Jul 2019 12:42:03 +0200 Zelphir Kaltstahl wrote: > Hi Guile Users! > > I recently looked at some online course about Elixir and saw an elegant > use of pipes (the operator `|>` in Elixir). Then I remembered, that in > Racket there are so called threading macros, which seem to accomplish

Re: Threading / Pipe Macro

2019-07-07 Thread Chris Vine
On Sun, 7 Jul 2019 19:32:59 +0100 Chris Vine wrote: [snip] Text munge by the editor This: (list (loop (car rest) (cdrrest)))]) ^ should be: (list (lo

Re: Threading / Pipe Macro

2019-07-07 Thread Mark H Weaver
Hi Chris, Chris Vine writes: > I have a pipeline macro which sort-of mimics ML's |> pipeline operator > which I use a lot: > > (define-syntax -> > (lambda (x) > (syntax-case x () > [(k exp0 . exps) >(let* ([reversed (reverse (cons (syntax->datum #'exp0) >

Re: Threading / Pipe Macro

2019-07-07 Thread Chris Vine
On Sun, 07 Jul 2019 15:30:36 -0400 Mark H Weaver wrote: > Hi Chris, > > Chris Vine writes: > > > I have a pipeline macro which sort-of mimics ML's |> pipeline operator > > which I use a lot: > > > > (define-syntax -> > > (lambda (x) > > (syntax-case x () > > [(k exp0 . exps) > >

Re: Threading / Pipe Macro

2019-07-07 Thread Chris Vine
On Sun, 7 Jul 2019 21:16:13 +0100 Chris Vine wrote: > I need to think more about this and/or reproduce this later. > > This is with guile-2.2.6 by the way. OK, I did set up the test of your macro incorrectly (the one using syntax-rules): tested properly, as you say it produces [t=global-t] in

Re: Threading / Pipe Macro

2019-07-07 Thread Mark H Weaver
Hi Chris, Here's a complete, unedited transcript with Guile 2.2.6: --8<---cut here---start->8--- mhw@jojen ~$ guile GNU Guile 2.2.6 Copyright (C) 1995-2019 Free Software Foundation, Inc. Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'. This

Re: Threading / Pipe Macro

2019-07-07 Thread Mark H Weaver
Hi Chris, Chris Vine writes: > My version was hygienic when used in functions, but not when used as a > macro in a macro. The word "hygienic" should not be used to describe your original macro. It would be more accurate to say that although your original version was unhygienic, in practice it wo

Re: Threading / Pipe Macro

2019-07-07 Thread Chris Vine
On Sun, 07 Jul 2019 18:24:32 -0400 Mark H Weaver wrote: > Hi Chris, > > Here's a complete, unedited transcript with Guile 2.2.6: > > --8<---cut here---start->8--- > mhw@jojen ~$ guile > GNU Guile 2.2.6 > Copyright (C) 1995-2019 Free Software Foundation, Inc. >

Re: Threading / Pipe Macro

2019-07-07 Thread Erik Edrosa
On 7/7/19 6:42 AM, Zelphir Kaltstahl wrote: > > (1) Does something already exist? > This project was posted not too long ago on this mailing list. https://bitbucket.org/bjoli/guile-threading-macros/src/default/ - Erik

Re: Threading / Pipe Macro

2019-07-07 Thread Mark H Weaver
Hello again, Chris Vine writes: > My version was hygienic when used in functions, but not when used as a > macro in a macro. Not to belabor the point, but I wanted to mention that the unhygienic '->' macro may fail when used in procedures, even when '->' is never used in the definition of anothe