On Sat, 12 Nov 2005, Larry Wall wrote:

For example, this is guaranteed to have the side effect of running
out of memory before it starts to print anything:

   print **1...;

Speaking of which I wonder if it can be detected and cause an error to be emitted. Which is to say, if it is possible for the compiler to determine that a list is potentially infinite (i.e. no stopping mechanism, e.g. a last is present anywhere[*]) and being flattened at the same time.

Since there may be some convoluted and intricated way to stop it, of course there should also be a pragma to locally disable the feature, of course...


[*] Of course there may still be some code (boiling down to something) like

  last if 0;

and the list would still be infinite and exhaust memory like the above, but one cannot expect the compiler to be smart enough to detect (all) cases like that, as fundamentally I think it reduces to the halting problem.


Michele
--
Shit Happens!
- "the predator", Predator 2 (1990)

Reply via email to