Mercurial > octave-nkf
comparison doc/interpreter/stmt.txi @ 6501:68f3125f6e27
[project @ 2007-04-05 20:53:40 by jwe]
author | jwe |
---|---|
date | Thu, 05 Apr 2007 20:53:40 +0000 |
parents | b2ce28713791 |
children | f80cc454860d |
comparison
equal
deleted
inserted
replaced
6500:3ea308b4b37e | 6501:68f3125f6e27 |
---|---|
191 | 191 |
192 @noindent | 192 @noindent |
193 using the indentation to show how Octave groups the statements. | 193 using the indentation to show how Octave groups the statements. |
194 @xref{Functions and Scripts}. | 194 @xref{Functions and Scripts}. |
195 | 195 |
196 @DOCSTRING(warn_assign_as_truth_value) | |
197 | |
198 @node The switch Statement | 196 @node The switch Statement |
199 @section The @code{switch} Statement | 197 @section The @code{switch} Statement |
200 @cindex @code{switch} statement | 198 @cindex @code{switch} statement |
201 @cindex @code{case} statement | 199 @cindex @code{case} statement |
202 @cindex @code{otherwise} statement | 200 @cindex @code{otherwise} statement |
290 the labels are integer constants. Perhaps a future variation on this | 288 the labels are integer constants. Perhaps a future variation on this |
291 could detect all constant integer labels and improve performance by | 289 could detect all constant integer labels and improve performance by |
292 using a jump table. | 290 using a jump table. |
293 @end itemize | 291 @end itemize |
294 | 292 |
295 @DOCSTRING(warn_variable_switch_label) | |
296 | |
297 @node The while Statement | 293 @node The while Statement |
298 @section The @code{while} Statement | 294 @section The @code{while} Statement |
299 @cindex @code{while} statement | 295 @cindex @code{while} statement |
300 @cindex @code{endwhile} statement | 296 @cindex @code{endwhile} statement |
301 @cindex loop | 297 @cindex loop |
360 reaches 11. | 356 reaches 11. |
361 | 357 |
362 A newline is not required between the condition and the | 358 A newline is not required between the condition and the |
363 body; but using one makes the program clearer unless the body is very | 359 body; but using one makes the program clearer unless the body is very |
364 simple. | 360 simple. |
365 | |
366 @xref{The if Statement}, for a description of the variable | |
367 @code{warn_assign_as_truth_value}. | |
368 | 361 |
369 @node The do-until Statement | 362 @node The do-until Statement |
370 @section The @code{do-until} Statement | 363 @section The @code{do-until} Statement |
371 @cindex @code{do-until} statement | 364 @cindex @code{do-until} statement |
372 | 365 |
410 @end example | 403 @end example |
411 | 404 |
412 A newline is not required between the @code{do} keyword and the | 405 A newline is not required between the @code{do} keyword and the |
413 body; but using one makes the program clearer unless the body is very | 406 body; but using one makes the program clearer unless the body is very |
414 simple. | 407 simple. |
415 | |
416 @xref{The if Statement}, for a description of the variable | |
417 @code{warn_assign_as_truth_value}. | |
418 | 408 |
419 @node The for Statement | 409 @node The for Statement |
420 @section The @code{for} Statement | 410 @section The @code{for} Statement |
421 @cindex @code{for} statement | 411 @cindex @code{for} statement |
422 @cindex @code{endfor} statement | 412 @cindex @code{endfor} statement |
665 Octave expressions or commands. The statements in @var{cleanup} are | 655 Octave expressions or commands. The statements in @var{cleanup} are |
666 guaranteed to be executed regardless of how control exits @var{body}. | 656 guaranteed to be executed regardless of how control exits @var{body}. |
667 | 657 |
668 This is useful to protect temporary changes to global variables from | 658 This is useful to protect temporary changes to global variables from |
669 possible errors. For example, the following code will always restore | 659 possible errors. For example, the following code will always restore |
670 the original value of the built-in variable @code{warn_fortran_indexing} | 660 the original value of the global variable @code{frobnositcate} |
671 even if an error occurs while performing the indexing operation. | 661 even if an error occurs while performing the indexing operation. |
672 | 662 |
673 @example | 663 @example |
674 @group | 664 @group |
675 save_warn_fortran_indexing = warn_fortran_indexing; | 665 save_frobnosticate = frobnosticate; |
676 unwind_protect | 666 unwind_protect |
677 warn_fortran_indexing = 1; | 667 frobnosticate = true; |
678 elt = a (idx) | 668 @dots{} |
679 unwind_protect_cleanup | 669 unwind_protect_cleanup |
680 warn_fortran_indexing = save_warn_fortran_indexing; | 670 frobnosticate = save_frobnosticate; |
681 end_unwind_protect | 671 end_unwind_protect |
682 @end group | 672 @end group |
683 @end example | 673 @end example |
684 | 674 |
685 Without @code{unwind_protect}, the value of @var{warn_fortran_indexing} | 675 Without @code{unwind_protect}, the value of @var{frobnosticate} |
686 would not be restored if an error occurs while performing the indexing | 676 would not be restored if an error occurs while performing the indexing |
687 operation because evaluation would stop at the point of the error and | 677 operation because evaluation would stop at the point of the error and |
688 the statement to restore the value would not be executed. | 678 the statement to restore the value would not be executed. |
689 | 679 |
690 @node The try Statement | 680 @node The try Statement |