Re: [stack] Point free (pointless) programming in ruby? (fwd)
John Carter <[email protected]>
| Newsgroups | gmane.comp.lang.concatenative |
|---|---|
| Message-ID | <[email protected]> |
On Tue, 13 Jan 2009, John Nowak wrote:
> Languages like ML and Haskell work better because they have curried
> functions.
I wonder if Curried Functions have the same effect as Curried Eggs
have on the digestive system?
Actually Currying works quite well in Ruby...
two_arg = lambda{|a,b| somefunc(a,b)}
b="Some concrete value"
one_arg = lambda{|a| two_arg.call(a,b)}
one_arg.call("Single parameter") is equivalent to
someFunc( "Single Parameter", "Some concrete value")
> Keep in mind that all existing concatenative languages make heavy use
> of stacks. Related languages like FP and FL make heavy use of lists.
> Trying to do pointfree programming in languages that don't do such
> things (Ruby, Python, Haskell, Scheme, etc) is going to be quite
> painful. For example, here's the Haskell example above in Joy:
Well, actually Ruby has Array's that behave (or can be made to behave)
in almost all respects like lists.
The obj.a.b.c.d.e form would be effectively identical to the
concantenative stack to stack functions if obj was an Array and each
method a, b, c, d, e was a non-destructive Array method returning an
Array.
Well, actually Rubies Duck Typing extends that in interesting
ways. See the Ruby Enumerable mixin for an example.
ie. Ruby is a superset of concatenative languages.
ie. If one restricts ones activities to a suitable concatenative
subset, the same interesting properties emerge.
The question then remains... What interesting idioms could one evolve
by playing in that subset.
John Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : [email protected]
New Zealand