>>>>> "TS" == Tolkin, Steve <[EMAIL PROTECTED]> writes:

  TS> OK, My comments below apply to this and Uri's similar comments.
  TS> I should have said: this infinite loop is easy to detect because:
  TS> 1. the pattern is constant
  TS> 2. the data (here $_) is not modified in the loop

  TS> Both points are obvious to a person.
  TS> In this simple and important special case 
  TS> it is also easy for most compilers (of languages other
  TS> than Perl).

do tell. i would like to see compilers that detect and warn about
infinite loops. 

  TS> In principle quite complex code can be analyzed to determine
  TS> accurately that the data is not modified.

that is done for optimization passes. perl doesn't do that level of
optimization.

  TS> I conclude that the Perl compiler has either 
  TS> * chosen to not do this kind of analysis, or 
  TS> * any such analysis is not connected to the error mechanism.

this analysis is akin to what optimizers must do. and if you follow the
parrot list you will have seen threads on skipping optimization in cases
where side effects (sub/method calls) are found as you can't tell if
they will affect the code/data in the section you are optimizing.

this analysis can be very complex and slow to run. i know of no compiler
that checks for infinite loops (even simple ones) as it is not their
baliwick. 

but bring this up on p5p and see if they listen or laugh at you. :)

uri

-- 
Uri Guttman  ------  [EMAIL PROTECTED]  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to