Re: [stack] Point free (pointless) programming in ruby? (fwd)

John Carter <[email protected]>
Newsgroups gmane.comp.lang.concatenative
Message-ID <[email protected]>
On Thu, 15 Jan 2009, John Nowak wrote:

> That is not currying. Unfortunately, this is something of a common
> misunderstanding.

You are right, sorry.

> Now, you *can* write a curried function in Ruby like so:
>
>    baz = lambda{|a| lambda{|b| lambda{|c| a + b + c}}}
>
> And call it as such:
>
>    baz.call(1).call(2).call(3)  # 6
>
> Unfortunately, it's quite painful.

Try an alternate syntax then...
irb
irb(main):001:0>  baz = lambda{|a| lambda{|b| lambda{|c| a + b + c}}}
=> #<Proc:0xb7d94ab0@(irb):1>
irb(main):002:0> baz[1]
=> #<Proc:0xb7d94ba0@(irb):1>
irb(main):003:0> baz[1][2]
=> #<Proc:0xb7d94c40@(irb):1>
irb(main):004:0> baz[1][2][3]
=> 6

> It's therefore a bit silly to claim one is a superset of the other.

Perhaps a better way of putting it would given the very flexible
multi-paradigm nature of Ruby, one can borrow the "Pointfree"
paradigm as well.

Will it be useful? Well, I suspect it might be.

I haven't seen anything yet that has given me the urge to rip Ruby out
as my main day to day programming workhorse. However there are parts
of the concatenative languages that make feel "ooh that has so much
promise... but not quite something I can convince my boss about".

Ruby doesn't quite comfortably replace the *sh languages yet.

One area that has been a bit hard to express is the *sh '|' pipelines.

I'm playing with the idea of pointfree in ruby as a nice paradigm to
do pipelined oneliners and more.



John Carter                             Phone : (64)(3) 358 6639
Tait Electronics                        Fax   : (64)(3) 359 4632
PO Box 1645 Christchurch                Email : [email protected]
New Zealand
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.