Issue #15799 has been updated by Eregon (Benoit Daloze).


matz (Yukihiro Matsumoto) wrote:
> Unlike JavaScript and Python (Lisp-1 like languages), Ruby is a Lisp-2 like language, in which methods and variable have separated namespaces. In Lisp-1 like languages, `f1 = function; f1()` calls `function` (single namespace).
> 
> In a Lisp-2 like language, ordinary (Elixir like) pipeline operator does not work, because it's harder to retrieve a method object in the language.

Could you give an example of why it doesn't work and why Lisp-2/Lisp-1 is problematic?

I think the current distinction used for no-receiver no-arguments calls (i.e., vcall) like `foo` works:
if there is a local variable `foo` then use that, if not, call a method named `foo`.

We have the method operator now, so we could do this if we wanted pipeline expressions to be actual call-able objects (which makes it easier to understand and functional):

```ruby
"42" |> Kernel.:Integer |> Math.:sqrt |> -> x { x * 2 }
```

Also, this is what many proposed and feel intuitive. Would it be problematic, why?
```ruby
"42" |> Integer(exception: false) |> Math.sqrt
```
We could simply have different semantics for the expressions on the RHS of `|>`, so they are considered curried method calls, no?

----------------------------------------
Feature #15799: pipeline operator
https://bugs.ruby-lang.org/issues/15799#change-78967

* Author: nobu (Nobuyoshi Nakada)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
Implemented the pipeline operator `|>`, a topic of "ruby committers vs the world" in RubyKaigi 2019.
Also a casual idea of rightward assignment.

```ruby
1.. |> take 10 |> map {|e| e*2} |> (x)
p x #=> [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
```

https://github.com/nobu/ruby/tree/feature/pipeline




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>