Issue #6284 has been updated by alexeymuranov (Alexey Muranov).


phluid61 (Matthew Kerwin) wrote:
> I agree that (f ??? g)(x) is g(f(x)) is more intuitive from a purely
>  programmatic point of view.  It is "natural" for the operations to be
>  applied left to right, exactly like method chaining.
>

When functions are applied from left to right, the argument is usually (if not always) on the left.  The form (x)(fg)=((x)f)g may look awkward (though i personally used it in a math paper), so i think usually the "exponential" notation is preferred: x^(fg) = (x^f)^g, where x^f corresponds to f(x) in usual notation.

With method chaining, IMO, the "main argument" of a method is the receiver, and it is on the left.  `Lambda`s and `Proc`s are not chained in the same way as method calls.
----------------------------------------
Feature #6284: Add composition for procs
https://bugs.ruby-lang.org/issues/6284#change-32739

Author: pabloh (Pablo Herrero)
Status: Feedback
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: 
Target version: 2.0.0


=begin
It would be nice to be able to compose procs like functions in functional programming languages:

    to_camel = :capitalize.to_proc
    add_header = ->val {"Title: " + val}

    format_as_title = add_header << to_camel << :strip

instead of:

    format_as_title = lambda {|val| "Title: " + val.strip.capitalize }


It's pretty easy to implement in pure ruby:

  class Proc
    def << block
      proc { |*args| self.call( block.to_proc.call(*args) ) }
    end
  end
=end


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