From: Mathieu Bouchard Date: 2006-08-06T00:03:16+09:00 Subject: Re: [ ruby-Bugs-5293 ] "ri File.open" is misleading --8323328-1214459040-1154789498=:32276 Content-Type: MULTIPART/MIXED; BOUNDARY="8323328-1214459040-1154789498=:32276" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323328-1214459040-1154789498=:32276 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-1; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Content-ID: On Fri, 4 Aug 2006, noreply@rubyforge.org wrote: > $ ri1.9 File.open > Nothing known about File.open > okay, i know that File extends IO, so how about IO.open? Why wouldn't ri redirect to IO.open in case of missing documentation or=20 non-reimplementated class-method ? > IO.open(fd, mode_string=3D"r" ) =3D> io > IO.open(fd, mode_string=3D"r" ) {|io| block } =3D> obj This suggests that File.new is overriding IO.new, because IO.new really only take integer arguments (filehandle numbers). > With no associated block, +open+ is a synonym for +IO::new+. This means that if File.new is overridden then File.open needs to because= =20 else it'll call IO.open which will call non-overridden IO.new. To describe= =20 a "covariant" behaviour it should be documented as synonym for self.new,=20 if it works that way. Actually, it does not work that way, e.g.: class Vile File.open( fileName, aModeString=3D"r" ) {| file | block = } -> nil > File.open( fileName [, aModeNum [ aPermNum ] ] ) {| file = | block } -> nil > With no associated block, open is a synonym for File.new . If the > optional code block is given, it will be passed file as an argument, > and the file will automatically be closed when the block terminates. > In this instance, File.open returns nil. This is also wrong, as File.open(){} returns the return value of the=20 block. _ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard - t=E9l:+1.514.383.3801 - http://artengine.ca/matju | Freelance Digital Arts Engineer, Montr=E9al QC Canada --8323328-1214459040-1154789498=:32276-- --8323328-1214459040-1154789498=:32276--