From: Lyle Johnson Date: 2003-03-28T23:19:52+09:00 Subject: [Q] How far does a closure reach? I was trying to understand how Ruby's finalizers work, or, in this case, why they weren't working as I expected. I found a solution, short and sweet, at this Wiki page: http://www.rubygarden.org/ruby?ObjectsNotGetFinalized I want to make sure I understand *why* the finalizer in the first example doesn't work: class Test def initialize ObjectSpace.define_finalizer(self, Proc.new{ puts "finalizing" }) end end The Proc doesn't have any explicit reference to self, and that's what threw me at first. But am I correct that because the Proc acts as a closure, it has a "hidden" reference to self from the enclosing scope? If the answer to that question was "yes", then the follow-up question is "How far does the scope of a closure reach?". Does it more-or-less follow the same kinds of block-scoping rules as, say, C/C++?