Hello,

This looks like a nice tool!
Looking at your samples made me think about a few interesting details
about Ruby.  To start the discussion, below is your posted (a.rb)
sample:

On Wed, 01 Jun 2005 00:20:25 +0900, Ara.T.Howard <Ara.T.Howard / noaa.gov>  
wrote:

>      def method(*a)
>        pa =
>          parseargs(a) {
>            required_argument :a
>            optional_argument :b => 2
>          }
>
>        puts "#{ pa.a }#{ pa.b }"
>      end
>
>      method 4
>
>    ~ > ruby sample/a.rb
>
>      42

This looks like a fairly reasonable API, but one thing really struck
me was that your variables needed to be referenced with the pa
instance.  This is understandable, but I kind of feel that if I were
to use this API a lot I would really rather have parseargs just go
ahead and set the variables in the current method's binding.  Thus I
can just reference a and b without the need to use pa.

I was going to post a patch to your code, but decided it might be
better to flesh out this idea.  Below is some sample code that will
display how I implemented a simple example of how you could remove the
need to reference pa.

------
def parse_data_hash(data, bd = binding)
   data.each do |k,v|
     vid = v.object_id
     eval("#{k.to_s} = ObjectSpace._id2ref(#{vid})", bd)
   end
end

def parse_test(data_hash)
   parse_data_hash(data_hash)
   puts local_variables.join(",")

   puts "Explicit binding passed"
   parse_data_hash(data_hash, binding)
   puts local_variables
   local_variables.each do |k|
     print "#{k} => "
     eval("print #{k}.inspect")
     puts
   end
end

parse_test({:a => [1,2,3], :b => "hello"})
------

Writing this brought out a few really interesting details about Ruby
that I would like to discuss.

1) I had to use ObjectSpace._id2ref in order to achieve the ability to
set variable a to the passed Array.  I did not like using this method,
even without the warning not to use it found in the "Ruby in a
Nutshell" book.  Interestingly this warning is not found in the RDoc
and ri generated description.  Is there a better way to do this?

2) In parse_data_hash I attempted to make passing the binding
optional.  As you see in the parse_test that does not work, because it
is assigning the binding to the binding of the parse_data_hash method
and not from its' caller.

2.1 ) eval currently makes passing the binding optional.  Is there a
way to do this in Ruby or is this something only available to the
internal implementation?

2.2) I was thinking it might be interesting if you could get the
binding of the caller from calling "caller".  Of course, having this
ability opens your self up to a lot of dangerous usages and possibly
some powerful usages too.  One usage would be a way to get the binding
of the caller for parse_data_hash.  I am wondering if this is a bad
idea and if any other languages allow you to do this?

2.3) Does anyone have an example of how you can use eval with a Proc
object instead of an binding?  The docs say you can do this, but does
not provide an example and my test below does not work either..

----
p = Proc.new { x = "Hello" }
eval("puts x", p)
t.rb:1: undefined local variable or method `x' for main:Object (NameError)
         from t.rb:1
----


I have some other fuzzy ideas about the binding and method objects,
but I better save that for another day when I can unfuzz them.
Although, one quick idea is if it would be possible in the future to
save the binding to disk or send it to another Ruby process?


Cheers,
Zev Blut