develooper Front page | perl.perl5.porters | Postings from February 2003

Re: Did the assertion patch/feature submission get overlooked?

Salvador Fandiño
February 17, 2003 14:23
Re: Did the assertion patch/feature submission get overlooked?
Message ID:
Hi, wrote:

> I'd appreciate some documentation and tests for the new facilities.

Two new test scripts will follow soon but about the documentation I 
think that it would be far better if somebody with a better English 
prose than me could volunteer for the job.

 > Is there any particular reason to have the code of
 > assertions::activate in a separate package from assertions?

To be able to have two different 'import' methods as both packages are
'use' based.

 > :Other issue is what happens to lexicals declared inside assertion args.
 > [...]
 > :Alternative behavior would be to open a new scope for the assertion
 > :args, this could be easily done expanding assertion calls to
 > :
 > :     asserting and assertion(@args)
 > I think this would be the simplest way to guarantee that perl won't
 > try to look up a different variable depending whether assertions are
 > enabled or not.

With the current implementation it doesn't happen either, declarations
are not ignored. i.e.:

   no assertions;
   i_am_an_assertion(my $b=45);

is equivalent to

   no assertions;
   my $b;

I have been trying to implement the other proposed behavior (creating a 
new scope for assertion args) but it is not as easy as I
thought because sub calls are resolved as assertions too late and
lexicals happen to be already allocated.

Maybe somebody with a better knowledge of the perl parser than me
should look at this part, but I really doubt that adding a new scope
could be done without important changes to the parser.


   - Salva Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About