Hi --

On Mon, 18 Aug 2003, [iso-8859-1] Ged Byrne wrote:

> So @implVersion is an entirely different variable to
> @@implVersion.
>
> In Net/HTTP @implVersion is only assigned in one
> place:

Do you mean @newimpl?

>
>     def HTTP.setimplversion( obj )
>       f = @@newimpl
>       obj.instance_eval { @newimpl = f }
>     end
>
> I cannot find anywhere in the code that is calling
> .setimplversion, yet changing the declaration of
> @@newimpl is reflected in @newimpl.
>
> Could anybody explain how this is working?

The object obj is having its instance variable @newimpl set (via
the temp variable f) to the current value of @@newimpl.  That's
accomplished with instance_eval, which puts the @newimpl = f
statement in the evaluation context of obj (so @newimpl is an
instance variable of obj).

So elsewhere, the value of @newimpl for a given object can be
used in conditional tests, for example:

      unless @newimpl
        res.value
        return res, res.body
      end


David

-- 
David Alan Black
home: dblack / superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav