Hacker News new | ask | show | jobs
by jdc 1685 days ago
Would it be fair to say you don't want to write this?

  z = ->(x) { x + 1 }

  z.call(y)
1 comments

I don't see why there is this distinction where lambdas have to be called differently than functions.
Ruby doesn't have functions. It only has methods. That blocks in MRI happen to be implemented without reifying an object is an optimisation. You can only ever obtain a reference to said block by reifying it into a Proc instance.

Letting you obtain some kind of raw reference to a block that isn't a method on an object would make blocks unlike every other value in Ruby.

> I don't see why there is this distinction where lambdas have to be called differently than functions.

Ruby doesn't have functions; things that look like bare (non-method) function calls in other languages are just method calls on self.

So procs/lambdas can't be called the same as, or differently from, functions—they are the closest thing Ruby has to functions to start with.