develooper Front page | perl.perl5.porters | Postings from March 2000

Re: [ID 20000324.027] Conditionally evaluated subroutines

From:
Tom Christiansen
Date:
March 24, 2000 06:51
Subject:
Re: [ID 20000324.027] Conditionally evaluated subroutines
Message ID:
21999.953909453@chthon
>> 
>> He probably doesn't understand that eval{} is just do{} with exception
>> handling.   That is, it's a compile thing.
>> 

>Its not that I don't understand it -- I just thought that its strange
>behaviour.  Certainly not what I expected.  Thanks for the explanation
>Tom.

Similar to this is the way people get confused about

    if (1) {
	use Thing_One;
    } else { 
	use Thing_Two;
    }

Like a sub declaration, use is a compile-time declaration, so its
effect is unrelated to its placement.  it makes no difference to
the compiler what happens at run-time.  (Although you'd think that
the second block might be optimized away, that happens to late.)

--tom



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About