On 13 Jul 2005, at 06:43, Jay Cotton wrote:

> I've been following this thread as well as why's post (and the  
> comments) at:
>
> http://redhanded.hobix.com/inspect/ 
> stuffingYourHandDownTheDisposal.html
>
> and I'm left confused about 2 things:
>
> 1) What sort of scope does begin..end introduce? In the comments to  
> his post, why writes "Variables declared inside a begin..end or  
> inside a block are block local, they perish with the close of the  
> block." But my own experience seems to contradict why's statement.  
> This program does not throw an error:
>
> #!/usr/local/bin/ruby
> begin
> x = 1
> end
> p x

begin does not create a new scope.  why made a mistake here.

> 2) Why are people getting different results when they run the  
> CustObj garbage collection code? When I run it, Object 1 never gets  
> collected by GC, even after exiting the begin..end scope.
>
> Can anybody help me understand?

The GC is very finicky, so you may or may not get the same behavior  
as other people do.  That's part of the nature of Ruby's conservative  
GC.

-- 
Eric Hodel - drbrain / segment7.net - http://segment7.net
FEC2 57F1 D465 EB15 5D6E  7C11 332A 551C 796C 9F04