From: Charles Comstock Date: 2004-05-04T18:49:04+09:00 Subject: Re: IO::write Yukihiro Matsumoto wrote: > Hi, > > In message "IO::write" > on 04/05/04, Charles Comstock writes: > > |Why is there only an IO::read, and no equivalent IO::write that takes a > |filename, a string to write, and an optional offset in the file to start > |writing at? Or better yet an IO::write(filename[,offset])= string to > |write to file. I don't know it seems useful to me for quickly writing a > |response out to a file anyone else? > > IO::read is a equivalent of > > IO::open(path, "r"){|f| f.read(*args)} > > But IO::write that is > > IO::open(path, "w"){|f| f.write(*args)} > > is, for my eyes, useless for most of the cases. Besides that, I don't > feel it is intuitive that IO::write to "open, then write once, then > close". Even if we decide to implement the method, we should prepare > better name. > > matz. > > The example listed is exactly the use case that I have littered about my code quite liberally in one of my applications. Often it's not the best approach to an application but sometimes it's nice to have quick file records of application state. I suggested write because of the orthagonality between it and read. Perhaps IO::save or IO::serialize. Save might be interesting as you could alias load to do the same as read. Would save/load be a more appropriate name? Charles Comstock