> On May 7, 2019, at 1:29 PM, zeRusski <vladilen.ko...@gmail.com> wrote:
> 
> It just names the threaded value. Did I overlook anything?
> 
> That's right, nothing fancy. Think let-binding the threaded value at that 
> point. #:with id ~ would achieve the same thing, so as it is now #:as is 
> redundant. With #:do both #:with and #:as are redundant, really.
>  
> Let me point out that if ~> specified an identifier (as suggested in my first 
> response) you could co-mingle two threaded computations, keeping separate 
> concerns that don’t matter as opposed to bundling them up in structs or lists 
> or whatever you have to do if you have only one. At first I thought #:as 
> would you let you do so, but that’s not correct.
> 
> Ok, this one I don't quite understand. My first thought went as far as to 
> weave multiple computations where each #:as would capture continuations and 
> macro would keep these "threads" separate, but now I'm thinking you mean this:
> 
> (~> 1 #:as ~a
>     ;; now ~a is being threaded
>     (add1 ~a)                           ;=> 2
>     2 #:as ~b
>     ;; now ~b is being threaded
>     (add1 ~b)                           ;=> 3
>     ;; simply use whatever ~a was last
>     (+ ~a ~b)                           ;=> 5
>     #:as ~a
>     ;; continue to thread ~a
>     (add1 ~a)                           ;=> 3
>     (list ~a ~b))
> ;; => (list 3 5)

Think: 

(~> (x 0)
      (add1 x) 
      (sin 
            (~> (y  1)
                  (sub1 y] 
                  (+ x y)))
      (* pi x))

This looks equally simple and is equally easy to read. If you wish to emphasize 
the “hole variable” make sure its name has a certain shape, say ~x. 
But now the threading has precise syntactic boundaries, and the implementation 
gets away without any assignments (which I assume #:as uses). 

— Matthias

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/227C9002-72D0-45DD-939A-9D55F4833403%40felleisen.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to