[#1711] Re: open-uri patch, added progress_proc hook — "T. Onoma" <transami@...>

Tanaka Akira:

22 messages 2003/11/19
[#1737] Re: open-uri patch, added progress_proc hook — Mathieu Bouchard <matju@...> 2003/11/23

[#1739] Re: open-uri patch, added progress_proc hook — Mathieu Bouchard <matju@...> 2003/11/23

[#1740] Re: open-uri patch, added progress_proc hook — "T. Onoma" <transami@...> 2003/11/23

On Sunday 23 November 2003 08:26 pm, Mathieu Bouchard wrote:

[#1741] Re: open-uri patch, added progress_proc hook — Mathieu Bouchard <matju@...> 2003/11/23

[#1718] Re: open-uri patch, added progress_proc hook — Elliott Hughes <ehughes@...>

22 messages 2003/11/21
[#1722] Re: open-uri patch, added progress_proc hook — Tanaka Akira <akr@...17n.org> 2003/11/22

In article <AD4480A509455343AEFACCC231BA850F17C434@ukexchange>,

[#1724] Re: open-uri patch, added progress_proc hook — "T. Onoma" <transami@...> 2003/11/22

On Saturday 22 November 2003 04:34 pm, Tanaka Akira wrote:

[#1726] Re: open-uri patch, added progress_proc hook — Tanaka Akira <akr@...17n.org> 2003/11/23

In article <200311221024.05642.transami@runbox.com>,

[#1731] Re: open-uri patch, added progress_proc hook — "T. Onoma" <transami@...> 2003/11/23

On Sunday 23 November 2003 02:24 am, Tanaka Akira wrote:

[#1732] Re: open-uri patch, added progress_proc hook — Tanaka Akira <akr@...17n.org> 2003/11/23

In article <200311230325.21687.transami@runbox.com>,

[#1733] Re: open-uri patch, added progress_proc hook — "T. Onoma" <transami@...> 2003/11/23

On Sunday 23 November 2003 03:10 pm, Tanaka Akira wrote:

[#1750] Re: open-uri patch, added progress_proc hook — Tanaka Akira <akr@...17n.org> 2003/11/24

In article <200311230648.41003.transami@runbox.com>,

[#1759] Re: open-uri patch, added progress_proc hook — Sean E Russell <ser@...> 2003/11/24

On Monday 24 November 2003 03:19, Tanaka Akira wrote:

[#1762] Re: open-uri patch, added progress_proc hook — "Nathaniel Talbott" <nathaniel@...> 2003/11/24

Sean E Russell [mailto:ser@germane-software.com] wrote:

[#1753] gc_sweep under 1.8 ... not syck.so — Richard Kilmer <rich@...>

We still encountered a gc_sweep in our use of Ruby 1.8 on Linux (v8).

16 messages 2003/11/24
[#1754] Re: gc_sweep under 1.8 ... not syck.so — ts <decoux@...> 2003/11/24

>>>>> "R" == Richard Kilmer <rich@infoether.com> writes:

[#1757] Re: gc_sweep under 1.8 ... not syck.so — Richard Kilmer <rich@...> 2003/11/24

Yes, there are several (Ruby) threads working during this gc_sweep.

[#1758] Re: gc_sweep under 1.8 ... not syck.so — ts <decoux@...> 2003/11/24

>>>>> "R" == Richard Kilmer <rich@infoether.com> writes:

[#1763] Re: gc_sweep under 1.8 ... not syck.so — Richard Kilmer <rich@...> 2003/11/24

of course this effects 300 machines ;-)

[#1755] Re: Controlled block variables — Jamis Buck <jgb3@...>

On Mon, 2003-11-24 at 02:04, T. Onoma wrote:

26 messages 2003/11/24
[#1756] Re: Controlled block variables — "T. Onoma" <transami@...> 2003/11/24

On Monday 24 November 2003 05:22 pm, Jamis Buck wrote:

[#1760] Re: Controlled block variables — Sean E Russell <ser@...> 2003/11/24

On Monday 24 November 2003 11:51, T. Onoma wrote:

[#1761] Re: Controlled block variables — "T. Onoma" <transami@...> 2003/11/24

On Monday 24 November 2003 06:40 pm, Sean E Russell wrote:

Re: open-uri patch, added progress_proc hook

From: Mauricio Fern疣dez <batsman.geo@...>
Date: 2003-11-17 21:05:36 UTC
List: ruby-core #1700
On Mon, Nov 17, 2003 at 11:44:44AM +0900, Tanaka Akira wrote:
> In article <20031116142119.GA18339@student.ei.uni-stuttgart.de>,
>   Mauricio Fern疣dez <batsman.geo@yahoo.com> writes:
> 
> > 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.
> 
> What's an advantage over mine?

IMHO
the validity of the arguments _as a whole_ can easily be factored into
a method of OpenURI::Options.

Also, the foo= instance methods of OpenURI can perform the checks you'd
have to do in open otherwise.
If the options become more "intelligent" at some point in the future,
it would be nice to have them in a full-blown object.
This seems to advocate for something like

options = Options.new
options.progress_proc = proc { }
...
open("http://...", ..., options)

but I believe the "impedance mismatch" is too high in that case; I
find... feel the proc{|e| e.xxx=...} idiom is "lighter".

More importantly :-) I find one argument (even though it's a proc)
more pleasant to the eye than several key => val pairs. And you can save
some typing if you want (proc {|e| e.progress_proc = ...}) without having
to include OpenURI.

> Both detects typos on option names.  However exception class is different:
> extconf.typo raises NoMethodError and OpenURI::OptTypo raises NameError.

class OpenURI
	class Options
		def method_missing(meth, *args)
			# any behavior you like here, including raise NameError
		end
	end
end

it won't catch all typos unless you use undef_method (but that's not
a problem), but OpenURI::id wouldn't be caught either (this is more than
a mere typo, though).

Summarizing: putting the options in an object gives you more power
you might someday find useful. The proc idiom provides not too heavy a
way to do so.

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

C is quirky, flawed, and an enormous success
	-- Dennis M. Ritchie

In This Thread