Trans wrote:

>>Musing on this, you know what'd be really great? Support for >
> 
> partial function application! I suppose this could already be
> 
>>emulated (or, more aptly, evamulated), but it could be a really >
> 
> useful feature. Those pesky side-effects just get in the way
> 
>>but I'm sure that could be overcome :)
> 
> 
> Forgive me but I have no idea what you are talking about. If you are
> being serious, what is partial function application? What would the
> advantages be? Would the advantage offset the disadvatages it may
> create elsewhere? If you were not, then please don't afford yourself as
> so funny.

Oh, I was serious. Partial function application (also referred to as
'macro binding' and 'currying') means that given a certain function 
(or method), e.g.

def fun(x, y, z)
  q = x + y + z
end

If this function is invoked with a partial argument list, e.g.

fun 1, 2

Then, instead of throwing some sort of an error, the call would 
produce a new function where the given arguments are bound. 
Essentially, the previous call would yield:

def fun(z)
  q = 1 + 2 + z
end

So these calls would be equal:

fun(1, 2, 3)          # => 6
((fun 1, 2) 3)        # => 6
fun(1, 2)(3)          # => 6
x = fun(1, 2); x(3)   # => 6
        
The only problem would be handling the destructive updates, i.e. what 
would happen if one tried to curry this with x:

def fun(x, y, z)
  x = x + y + z
end

x can't be directly substituted since it's assigned to. It'd have to 
be translated to 'xx = x + y + z' or something. 

This probably isn't something most Rubyists, at least initially, would
be excited about but it's quite useful. I think it'd be possible to 
implement as a library but it'd obviously be fairly slow. Of course 
there's always Haskell :)

> I believe it was Richard Feynman who said, though I paraphrase, "Never
> underestimate the power of a new notation."
> 
> T

E