Steven W McDougall writes:
 > 4. Regular expressions

 > It seems like an RE match should be atomic, because it hard to imagine
 > it executing sensibly if the target string changes during the match.
 > But then we have
 > 
 >      Thread1                 Thread2
 >      $a =~ s/.../.../e;      $a = 'foo';
 > 
 > s///e can execute arbitrary code, so if s// is atomic, then Thread2
 > could be blocked for an arbitrary length of time.

Which is why you probably shouldn't write things like that in threaded
programs.  But if it's not atomic, then what does it do?  Abort the
replacement if the string changes?  Replace whatever text happens to
be in the position where the match used to be?  I say it has to be
atomic to make any sense.  If that causes other threads to block for a
long time, that's the programmer's fault for writing poorly threaded
code.

-- 
Chris Madsen              http://www.trx.com      [EMAIL PROTECTED]
TRX Technology Services                                 (214) 346-4611

Reply via email to