Hi,

to be honest, I don't think this idea of using global methods as
independend function objects with state on their own makes sense. And
the more complicated your hacks get, the more I'm sure that you're
trying to
force a procedural technique on an OOP language.

First of all, if you're programming object oriented, then all your
methods should belong to a specific class (other than Object). And if
that's the case, dynamic values are simply stored in instance variables:

#--------------------------------------
class Hallo
  attr_writer :hello_str

  def initialize
    @hello_str = 'Hallo world!'
  end

  def hello str = nil
    puts str || @hello_str
  end
end

h = Hallo.new
h.hello 'Hi'   # 'Hi'
h.hello        # 'Hallo world!'
h.hello_str = 'Hallo Welt!'
h.hello        # 'Hallo Welt!'
#--------------------------------------

However, your idea *is* possible. You could define your own Function 
class that takes a proc and calls it using the predefined default 
values. But then you'd basically have to write your own variant of 
Ruby's method calling logic. The information about the parameter types 
(required, optional, other) of a proc is accessible via Proc#parameters.

-- 
Posted via http://www.ruby-forum.com/.