On Tue, 2003-11-04 at 10:29, Austin Ziegler wrote:
> On Tue, 4 Nov 2003 04:37:19 +0900, Dmitry Borodaenko wrote:
> > On Mon, Nov 03, 2003 at 11:40:48PM +0900, Austin Ziegler wrote:
> [snip]
> > You've missed the question in the beginning of this thread:
> > 
> >   For starters, how would one move a small file, treated as
> >   StringIO, to another location? With Tempfile, you just do
> >   Tempfile#local_path, and move away. But it's not so straight
> >   forward with StringIO.
> > 
> > Obviously, asker _wants_ his own file handling.
> 
> I didn't miss that. What's wrong, though, is that the CGI library is
> returning different values for parameters based on the total size of
> the data.

Is it really returning "different values for parameters"?

A Tempfile is a File which is an IO. 
And a StringIO is an IO.

So this module is returning an IO object, and all the methods of an IO
object are always available.

If you think of how this would be implemented in a strictly-typed
language like Java or C++, the return type would be "IO". If the user
then manually downcasted the object to type Tempfile or File or StringIO
then they would be asking for trouble. Isn't this "downcasting"
implicitly what you are doing when trying to treat the returned object
as a File or StringIO?

Yes, dealing with the returned value as an IO object might be
"suboptimal", but as I said in ny original posting, if you sneak around
accessing what are essentially private implementation details of a
library in order to improve your apps' performance then you can expect
problems.

Note: I'm not familiar with cgi.rb; just basing this argument on what I
have seen of the API on this thread. Sorry if I'm off-course.

Regards,


Simon