[#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: Tanaka Akira <akr@...17n.org>
Date: 2003-11-18 15:11:34 UTC
List: ruby-core #1704
In article <20031117210516.GA25730@student.ei.uni-stuttgart.de>,
  Mauricio Fern疣dez <batsman.geo@yahoo.com> writes:

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

Unfortunately, options may vary depends on a kind of target:
URI::HTTP, URI::FTP and others.

Since open-uri is a delegator to open any kind of URIs and other
resources which have public `open' method, fixed set of options is not
suitable.  So, validity checking cannot be factored into single class.

> 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".

I feel OpenURI::OptXXX => ... is more lighter than proc {|e| ... }.
I feel :xxx => ... is more lighter than OpenURI::OptXXX.

I feel :xxx => ... style matches with Kernel#open.  However it tends
to have no error checking.

Maybe, implementing error checking with :xxx => ... style is a
solution.  But I'm not sure that unknown option should be cause
exception.

> More importantly :-) I find one argument (even though it's a proc)
> more pleasant to the eye than several key => val pairs.

I don't feel so.

> And you can save
> some typing if you want (proc {|e| e.progress_proc = ...}) without having
> to include OpenURI.

In this point of view, :xxx => ... is best (shortest).

Further, it will be more shorter with keyword argument on Ruby2, maybe.

> 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).

I meant that both are no problem.  So don't advocate such trick.
Such trick tends to cause trouble.

> 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.

Someday?  It's violates YAGNI.
-- 
Tanaka Akira


In This Thread

Prev Next