On Fri, 2 Jul 2004, Minero Aoki wrote:

> [ruby-dev:23784] URI()
>
>  TANAKA Akira proposed a new global method URI(), to construct an URI
>  object.  With this method, you can write HTTP GET program as below:
>
>    print URI("http://www.example.com/").read
>
>  This program is better than `open("http://....").read' because it
>  properly closes IO objects.
>
>  Here are some opinions:  (+ : approval, - : objection)
>
>    + There are similar methods such as Integer(), String(), etc.
>    + URI is a name, literal-like syntax seems good.
>    - URI.[] is better because URI() pollutes the global name space.
>    - String(obj) calls obj.to_s.  Integer(obj) calls obj.to_i.
>      But URI(obj) does not call obj.to_uri.
>      (Note that Complex(obj) does not call obj.to_complex, too.)
>    - A method name which begins with a capital looks bad.
>
>  This issue is still open.

why not

   URI::read :

     def URI.read uri
       begin
         u = parse "#{ uri }"
         u.read
       ensure
         u.close
       end
     end

   + like IO::read, YAML::load, etc.
   + no name space pollution
   + only requires ducktype string like parse

-a
--
===============================================================================
| EMAIL   :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE   :: 303.497.6469
| A flower falls, even though we love it;
| and a weed grows, even though we do not love it. 
|   --Dogen
===============================================================================