in reply to Re: Concurrent lexical scopes?
in thread Concurrent lexical scopes?

Hi broquaint, I've just downloaded the code from Sub::Lexical and done some tests of my own, and it seems to me that your subs now have local scope:

#!/usr/bin/perl -w use strict; use lib '.'; use Sub::Lexical; my sub testsub { print "testsub 1 called\n"; } my sub outersub { print "outersub called\n"; testsub(); } for (1) { my sub testsub { print "testsub 2 called\n"; } testsub(); outersub(); }

This outputs:

testsub 2 called outersub called testsub 2 called

While it probably SHOULD give:

testsub 2 called outersub called testsub 1 called
Because the first testsub() declaration is in lexical scope for outersub()

This could be considered a feature, if you just rename your module to Sub::Local... :-)

-- Joost downtime n. The period during which a system is error-free and immune from user input.

Replies are listed 'Best First'.
Re: Re: Re: Concurrent lexical scopes?
by broquaint (Abbot) on Jun 12, 2002 at 11:41 UTC
    Ack, you're completely right. In my haste to get a working solution I somehow overlooked the fact that local() != my(), I think the happy part of my brain was muffling the common sense part with a chloroform soaked cloth ;-) So I shall be going back to munging the variable names and also including a hopefully unique enough id within the name. Thanks for the input Joost!
    HTH

    _________
    broquaint