Is Perl *that* good?

Roy Smith roy at panix.com
Tue Apr 27 19:43:45 EDT 2004


Carl Banks <imbosol at aerojockey.invalid> wrote:
> Hmm.  The reason this hasn't been done is that it makes the match
> method non-reentrant.  For example, suppose you call some functions in
> between the matching and use of the matched object, like this:
> 
>     if myregex.match(line):
>         xyz = (subprocess(line[myregex.lastm.end():]) 
>                + myregex.lastm.group(1))
> 
> And suppose subprocess goes on to use the same regexp.  By the time
> subprocess returns, myregex.lastm could have been overwritten.  This
> is not a far-fetched example at all; one could easily encounter this
> problem when writing, say, a recursive descent parser.

I don't see that this is any worse than any other stateful object.  If 
you change the state of the object, you can't expect to get the same 
data from it as you did before.



More information about the Python-list mailing list