--- Trans <transfire / gmail.com> wrote:

> 
> Austin Ziegler wrote:
> >
> > I'm not wanting to extrapolate. Consider me the
> conservative here,
> > Trans. Convince me that this is really useful and
> important.
> 
> It's all relative Austin. How *really useful and important*
> is
> anything? Most things can be done in some other way. But this
> much is
> certain, there are things you CAN'T do b/c of this --or at
> least not
> wihtout jumping through some magical hoops like defining a
> method
> grabing the UnboundMethod, converting to_proc and undefining
> the method
> (which I have done). But as to the example I was trying to
> show here...
> here's something a little bit more real-to-life, though still
> off the
> top of my head.
> 
>   dir = File.dirname(__FILE__)
> 
>   m = module.new do
> 
>     make_dir_method = lambda { |which, path|
>       class_eval {
>         define_method( "#{which}dir" ) { |name|
>           dir = File.dirname(path)
>           name = File.basename(path)
>           File.join(dir,which,name)
>         }
>       }
>     }
> 
>     make_dir_method('lib',dir)
>     make_dir_method('var',dir)
>     make_dir_method('bin',dir)
> 
>   end

Trans, I thought the discussion was the need for a non-closure
block/lambda.  The above has very little to do with closure
blocks/lambdas vs. non-closure blocks/lambdas.  All you're
asking for in the above is for a ()-like operator that
correlates to #call.  I too would like that especially when the
lambda takes a block (only in v1.9).  When it doesn't take a
block, you can easily get similar syntax by using the []
operator on a Proc:

     make_dir_method['lib',dir]
     make_dir_method['var',dir]
     make_dir_method['bin',dir]

Another option is to simply allow the [] operator to take a
block.



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com