In article <AD4480A509455343AEFACCC231BA850F17C3CA / ukexchange>,
  Elliott Hughes <ehughes / bluearc.com> writes:

> that would let you use the 'natural' Ruby block syntax, but also let you
> have an arbitrary number of blocks. i think Matz made a good decision in
> 'limiting' us to one block parameter per method, because anything more would
> be terribly confusing (and suggest that the method in question doesn't Do
> One Thing).

I feel no problem with lambda.

Note that I tried to make matz support multiple blocks.  I don't give
up yet.

> the major change would be that OpenURI's work would move into UriOpener, and
> OpenURI.open_uri would now create a UriOpener instance, and invoke the
> open_uri on that instance.

I think resource locators should know "how to open it".  So open-uri
provides URI::HTTP#open and URI::FTP#open and make Kernel#open to
parse URI string and call its open method.  So I'm not sure that
introducing additional UriOpener object is suitable.

>> open("http://...", OpenURI::OptProgressProc => lambda {|s| ... })
>> 
>> OpenURI::OptProgressProc is a some constant of a symbol.
>
> that would be better than the kind of hash used in Ruby's telnet, for
> example. if there's one thing worse than an error that isn't detected until
> run-time, it's an error that isn't even detected at run-time!

Another error checking idea:

Even if the style open("http://...", :progress_proc => lambda { ... })
is used, it is possible to implement some checking method
OpenURI.check_options(hash) using a set of options such as:

OpenURI::Options = {
  :proxy => true,
  :progress_proc => true,
  :content_length_proc => true,
  ...
}

It makes possible to use simple symbol keys with error checking with
inserting a single line call to OpenURI.check_options.  Also new
options can be added by another resource locator implementation with
only one line as: OpenURI::Options[:new_option] = true
-- 
Tanaka Akira