From: Eric Hodel Date: 2011-07-10T10:16:25+09:00 Subject: [ruby-core:37942] Re: [Ruby 1.9 - Feature #5010][Open] Add Slop(-like) in stdlib and deprecate current OptionParser API On Jul 9, 2011, at 4:19 PM, Rodrigo Rosenfeld Rosas wrote: > Em 09-07-2011 20:13, Nobuyoshi Nakada escreveu: >> At Sun, 10 Jul 2011 08:01:58 +0900, >> Rodrigo Rosenfeld Rosas wrote in [ruby-core:37936]: >>> This is the equivalent in Slop: >>> >>>
>>> require 'slop'
>>> 
>>> opts = Slop.parse do
>>>   banner "Usage: example.rb [options]"
>>>   on :v, :verbose, "Run verbosely", :default =>  true
>>> end
>>> 
>>> p opts.to_hash
>>> 
>> Hidden instance_eval is cause of confusion. It's a way >> OptionParser has thrown away. > > Sorry, Nobu, I didn't get it. Could you explain it better? I think Nobu means that formerly OptionParser used instance_eval like slop does inside the parse method. This was changed due to confusion of scoping and methods available inside and outside the instance_eval. I'd prefer not to have hidden instance_eval for option parsing. It's too often that I like to refer to items in a scope the execution environment doesn't have.