On Fri, Aug 10, 2001 at 01:08:12AM +0300, raptor wrote:
> didn't thought of that :")), but what will broke if the var is
> copied/aliased every time not just the first time ...
> 
> I mean the call to closure make a new instance of the sub()  every time
> isn't it ?!?
> !!!!! I see the closures get bound every-time , but non closures only the
> first time !!!!!
> But still can figure out ...if I'm thinking correctly .
> 
> - closure makes a new instance of of itself and get the latest value of
> outer-lexical variable in its private space.
> - there is no reason why normal sub() can get/alias! this value every time,
> this doens't broke the closure behaviour (i.e. normal sub() doesn't need to
> make its own private copy but use the outer-scope-lexical  ) or I'm wrong
> again.

This really is more of a Perl topic.

Many people mistake anonymous subs and closures.  The two are orthoginal:
anonymous subs can be closures, named subs and be closures, anonymous subs
might not be closures, named subs likewise.  It all depends on if named
lexical variables are in scope when the sub is defined.

--James

Reply via email to