On Sun, Nov 16, 2003 at 07:51:42PM +0900, Tanaka Akira wrote:
> In article <AD4480A509455343AEFACCC231BA850F17C358 / ukexchange>,
>   Elliott Hughes <ehughes / bluearc.com> writes:
> 
> > I know static checking isn't really Ruby's thing, but avoiding weirdness
> > like parameters that are hashtables full of uncheckable parameters has to be
> > a good thing! 
> 
> If the benefit of that is parameter checking, how about this style:
> 
> open("http://...", OpenURI::OptProgressProc => lambda {|s| ... })
>

What about

open("http://...", ... current options ..., 
     proc { |extconf|
		extconf.progress_proc = proc {  }
		extconf.foo = ...
	 }
)

?

extconf would be an object of type OpenURI::Options or so.

This scheme is AFAIK backwards compatible, extensible (just add accessors
to OpenURI::Options), can detect wrong parameters and ensures open won't
be given non-existent arguments. You don't have to remember the order of
arguments nor to put nil for those not needed.  Moreover, the validity
of the arguments _as a whole_ can easily be factored into a method of
OpenURI::Options.

Are there any other criteria to be taken into account?

On the downside, proc { ... } is a bit ugly (too bad there can only be
an implicit block in Ruby), but it is hard to avoid...

-- 
 _           _                             
| |__   __ _| |_ ___ _ __ ___   __ _ _ __  
| '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ 
| |_) | (_| | |_\__ \ | | | | | (_| | | | |
|_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|
	Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

We come to bury DOS, not to praise it.
	-- Paul Vojta, vojta / math.berkeley.edu