Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Can't abort a loop with Print inside (V6)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83089] Re: Can't abort a loop with Print inside (V6)
  • From: Bill Rowe <readnewsciv at sbcglobal.net>
  • Date: Sat, 10 Nov 2007 03:42:15 -0500 (EST)

On 11/9/07 at 5:15 AM, frank1998 at gmail.com (Frank Hu) wrote:

>It seems in Version 6 one can't abort  a loop if there's a Print
>statement inside.  Try the following code

>For[i = 1, i < 1000, ++i, Print[i]]

>No matter doing it from the menu or with the keyboard shortcut, the
>abort action will be ignored.  Under 5.2, the code stops right away
>when I hit Cmd-.

>Sometime, trying to abort would even freeze the whole program,
>causing lost sessions.  I'm running 6.0.1.0 on Mac OS X
>10.4.10. Any suggestions of what's going on?  Is this a bug or
>a new feature?

It would be better described as a feature than a bug. But the
"feature" is really nothing more than improved performance of
version 6 compared to previous versions rather than an intent to
prevent stopping a loop using Cmd-.

For any software (assuming good performance) it will be always
possible to write a loop that runs so fast that it simply cannot
be halted using the key sequence. This is a result of only
having a simple Print statement in the loop rather than having a
more complex loop.

For example, the loop

Do[Pause[1];Print[n],{n,100}]

can easily be halted with the Cmd-. key shortcut.

OTOH,

Do[Print[n],{n,100}]

cannot be halted in the same manner.
--
To reply via email subtract one hundred and four


  • Prev by Date: Re: trying to "simplify" very large output
  • Next by Date: Re: Single most useful dynamic/interactive capability in Mathematica?
  • Previous by thread: Can't abort a loop with Print inside (V6)
  • Next by thread: Re: Re: Can't abort a loop with Print inside (V6)