On 12/10/2015 20:01, Max Nazhalov wrote:
I can't think of a use case either. And just because another language
provides such a solution, does not imply that FPC should.
+1

(despite my earlier contribution)

Discussion of the feature below, is regardless of it not being desirable (in any form)

  As to achieving
the functionality in FPC:

if cond then
    while cond do
      foo
else
    bar;
That's what I've thought about from the beginning of this discussion..
Actually the above does not represent what the actual feature request is about

The "else" is to be executed, after the while (even if the while looped ZERO times).
But it is to be skipped if the while exited via break (and only then).

For that reason "else" or "otherwise" are badly chosen keywords. Because they imply a different function.

<sarcasm on>

Further what is so special about the case "finishing a while loop without break (including 0 iterations)"? If that case deserves special attention then surely the following also need (and no one should want all that)

while cond
initialize // run before the 1st loop, if there is going to be at least one loop
  do  // each loop
  finalize // run after last loop, if there was at least one
finalizeThen // run after last loop, if there was at least one // only if no break finalizeCatch // run after last loop, if there was at least one // only if a break happened
  then // finish, without break; or zero loops
  catch // only on break
else // if there was no loop at all (condition was wrong, before first loop already)

There are all equally (none-) important. Have one have all.
<sarcasm off>

Better have none.

The only drawback is that "cond" is calculated twice instead of once
before the actual loop body -- not all will be happy.. ;-)

Thats an issue for the optimizer. no need to change the language.


_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to