[ 
https://issues.apache.org/jira/browse/GROOVY-12220?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18105299#comment-18105299
 ] 

Aleks Tamarkin commented on GROOVY-12220:
-----------------------------------------

Thanks for the review!

You're exactly right - it's about the particular syntax of writing code left to 
right and top to bottom like reading English.
I am guessing that's why Groovy adds super useful methods to Strings and byte[] 
such as toURI() or encodeBase64(). Theres a lot of apis out there that still 
take the value as an argument and a pipeline operator can reverse that: 
method(value) vs value |> method. 
That being said... The chain of with() you mentioned is pretty cool and I'm 
super looking forward to Groovy 6 features!

> Pipeline Operator Support (possibly for groovy 6)
> -------------------------------------------------
>
>                 Key: GROOVY-12220
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12220
>             Project: Groovy
>          Issue Type: New Feature
>            Reporter: Aleks Tamarkin
>            Priority: Major
>
> Suggestion to add a functional pipline operator to Groovy
> Groovy already prioritized writing code left to right with awesome 
> improvements over java like `someString.toURL()` instead of `new 
> URL(someString)`
> A pipleine operator could make this even more universal
> Example implementation using xor `^`
> {code:java}
> class PipelineOperator {
>   static xor(Object self, Closure c) {
>     c(self)
>   }
> }
> class Foo { static foo(v) { v + 3 } }
> Closure example = { 
>    def x = { it ** 2 + it }
>    4 ^ x ^ { it / 2 } ^ (Foo.&foo)
> }
> use(PipelineOperator) {
>   example() // 4 -> 4 * 4 + 4 = 20 -> 20 / 2 = 10 -> 10 + 3 = 13
> }{code}
> Example in F# 
> [https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/functions/#pipelines]
> Thanks in advance for taking a look
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to