Re: [fpc-devel] Fwd: While - Otherwise Statement
On Tuesday 13 October 2015 23:25:03 Michael Van Canneyt wrote: > > But the existence of such a continue block shows the fundamental issue on > > which a decision is needed. should (if a volunteer for a patch exists) > > every little "save one statement in your code helper" be added? Because > > there are thousands of them, and if you add them all the readability of > > code will go down, because you need to first learn them all. > > I think the answer to your question is a clear and loud "NO". > > The argument that we can refrain from using these new features does not > hold, because other people will be using it, and we will have to know all > of it to be able to understand their code. > None of these features will automagically make Object Pascal a popular > language. > > However, I seem to be one of the very few thinking this given the > enthousiasm with which people are discussing this. > We are at least two people. :-) > Soon I will be forced to emigrate to Javascript country. Or to MSElang? ;-) Martin ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
Michael Van Canneyt wrote: But the existence of such a continue block shows the fundamental issue on which a decision is needed. should (if a volunteer for a patch exists) every little "save one statement in your code helper" be added? Because there are thousands of them, and if you add them all the readability of code will go down, because you need to first learn them all. I think the answer to your question is a clear and loud "NO". The argument that we can refrain from using these new features does not hold, because other people will be using it, and we will have to know all of it to be able to understand their code. None of these features will automagically make Object Pascal a popular language. However, I seem to be one of the very few thinking this given the enthousiasm with which people are discussing this. For what it's worth, I agree with you. It's one thing restoring something like the "inline if" (or a functional equivalent) which was in ALGOL and is regularly used in most current languages, but doing something like adding a completely new flow control construct which has no significant precedent in other languages is much more difficult to defend. Soon I will be forced to emigrate to Javascript country. Despite all its drawbacks, it remains at least a simple language. a dozen keywords and you're done. No wonder Node.js is so popular. Compare that with the jungle we're making of it... :( At the same time, I think it's worth distinguishing three distinct cases that contribute to syntax complexity. The first is the case that you had in early ALGOL implementations, where there was limited support for external libraries and where every detail of control of- for example- file open mode had to be expressed as part of the language syntax. The second is the case where a language has a fairly verbose syntax, but where this is used to define a rich set of general-purpose flow-control and data-definition constructs. This is where Pascal is at. The third case is modern C++, Javascript and so on which grossly overload the limited ASCII character set and where abusing even the lowly parenthesis can have non-obvious effects. Then there's the issues they have with things like "static", and their use of "std::something" as quasi-directives. I'm still struggling with a mainframe emulator, originally written in Javascript, where around half of the complexity was due to the lack of any support for multithreading. I also think that the recent forking of the Scratch graphical language, where a significant proportion of the community has rejected MIT's attempts to reimplement it in Javascript, indicates that there's an increasing awareness that both the language and its typical implementations- i.e. embedded in a browser or as ActionScript in Flash- leave much to be desired. And Node.js is lipstick on a pig. -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
On 14 October 2015 at 07:28, Martin Schreiberwrote: > On Tuesday 13 October 2015 23:25:03 Michael Van Canneyt wrote: > > However, I seem to be one of the very few thinking this given the > > enthousiasm with which people are discussing this. > > > > We are at least two people. :-) > For what it's worth, with me that's at least 3. > > Soon I will be forced to emigrate to Javascript country. > > Or to MSElang? ;-) > Or Scala? :-P (Digressing a bit more in this vein, I've been feeling the pull of more functional languages lately, in particular Scala, which if you don't know is a functional OO hybrid language that targets the JVM. I actually wish something similar happened in the Object Pascal space. C# inspired F#. Java inspired Scala. Delphi/FPC inspired/inspires ...? Further aside, for those interested in more functional programming and Scala, watch this video: https://goo.gl/chdMlv In a different vein, there's also the Rust language which is another language seems well worth learning and brings new ideas to the table well above and beyond syntactic sugar But enough of that, hope that's not been too off topic!) Walter ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
Hi all, 14.10.2015 23:44, Walter Prins: On 14 October 2015 at 07:28, Martin Schreiber> wrote: On Tuesday 13 October 2015 23:25:03 Michael Van Canneyt wrote: > However, I seem to be one of the very few thinking this given the > enthousiasm with which people are discussing this. > We are at least two people. :-) For what it's worth, with me that's at least 3. Me too! Me too! That's 4 already :-) Thank you, Nikolai ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
Sven Barth wrote: The intrafunctional gotos not really. But the interfunctional ones (modeswitch nonlocalgoto in 2.7.1+) might mess with managed types ;) The compiler should give an error if you try to "goto" out of or into a frame than needs initialisation/finalisation. Jonas ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
On Mon, 12 Oct 2015, wkitt...@windstream.net wrote: On 10/12/2015 03:43 PM, Martin Frb wrote: 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. exactly my and others' points... "and" would be better but then one might just as easily use a goto to jump around that part if break was used to get out of the loop... anyway, it seems that no matter what the discussion, it won't make it into the compiler... that according to another post from a compiler dev ;) Maybe my remark was not clear. I'm not against this *functionality*. I merely pointed out that *the syntax using 'else'* is not going to make it because it breaks backwards compatibility. If another keyword is used: no problem. I don't understand why anyone would want this marginal functionality and thus (again) needlessly complicates the language, but hey, it's a (mostly) free world Alas, the monstrosity that Object Pascal syntax is becoming is less and less appealing by the day, it's simply frightening... Michael. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
Am 13.10.2015 08:36 schrieb "Jonas Maebe": > > Sven Barth wrote: >> >> The intrafunctional gotos not really. But the interfunctional ones >> (modeswitch nonlocalgoto in 2.7.1+) might mess with managed types ;) > > > The compiler should give an error if you try to "goto" out of or into a frame than needs initialisation/finalisation. Ah, ok, so we're already checking that. Good ^^ Then it's mostly the "bad karma" of goto I'd say ;) Regards, Sven ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
wkitt...@windstream.net wrote: On 10/13/2015 04:32 AM, Michael Van Canneyt wrote: On Mon, 12 Oct 2015, wkitt...@windstream.net wrote: On 10/12/2015 03:43 PM, Martin Frb wrote: 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. exactly my and others' points... "and" would be better but then one might just as easily use a goto to jump around that part if break was used to get out of the loop... anyway, it seems that no matter what the discussion, it won't make it into the compiler... that according to another post from a compiler dev ;) Maybe my remark was not clear. I'm not against this *functionality*. I merely pointed out that *the syntax using 'else'* is not going to make it because it breaks backwards compatibility. a... my bad... sorry 'bout that... i've been thinking about this, too... 'else' and 'otherwise' mean the same thing... what they seem to be looking for is 'aswell'... foo := 0; while foo < 100 do begin inc(foo); end; aswell begin dec(foo); end; either 'aswell' or 'aswellas'... while foo is less than 100 increment foo as well as decrement foo when it is no longer less than 100... If somebody really has to do this wouldn't "also" be a better choice to avoid (getting close to overloading "as"? :-/ -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
On 10/13/2015 04:32 AM, Michael Van Canneyt wrote: On Mon, 12 Oct 2015, wkitt...@windstream.net wrote: On 10/12/2015 03:43 PM, Martin Frb wrote: 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. exactly my and others' points... "and" would be better but then one might just as easily use a goto to jump around that part if break was used to get out of the loop... anyway, it seems that no matter what the discussion, it won't make it into the compiler... that according to another post from a compiler dev ;) Maybe my remark was not clear. I'm not against this *functionality*. I merely pointed out that *the syntax using 'else'* is not going to make it because it breaks backwards compatibility. a... my bad... sorry 'bout that... i've been thinking about this, too... 'else' and 'otherwise' mean the same thing... what they seem to be looking for is 'aswell'... foo := 0; while foo < 100 do begin inc(foo); end; aswell begin dec(foo); end; either 'aswell' or 'aswellas'... while foo is less than 100 increment foo as well as decrement foo when it is no longer less than 100... i don't see a need for it because in this case if one wants foo to only get to 99, then they should use 99 as their count... foo := 0; while foo < 99 do begin inc(foo); end; at the end of the loop, foo will equal 99... but it is also a very simple example... If another keyword is used: no problem. ok... I don't understand why anyone would want this marginal functionality and thus (again) needlessly complicates the language, but hey, it's a (mostly) free world Alas, the monstrosity that Object Pascal syntax is becoming is less and less appealing by the day, it's simply frightening... it seems that way... but it doesn't mean that we have to use it... we can stay with the traditional ways and means within whatever it becomes as long as they don't change with these undesirable extensions... -- NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list* unless private contact is specifically requested and granted. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Mon, 12 Oct 2015 22:34:03 -0300, Flávio Etrusco (flavio.etru...@gmail.com) wrote about "Re: [fpc-devel] Fwd: While - Otherwise Statement" (in
Re: [fpc-devel] Fwd: While - Otherwise Statement
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Mon, 12 Oct 2015 21:32:07 -0400, Wkitty42 (wkitt...@windstream.net) wrote about "Re: [fpc-devel] Fwd: While - Otherwise Statement" (in <561c5f17.4070...@windstream.net>): [snip] > that looks very much like what some would consider goto > statements... does the leave return to the top of the previous loop > or does it drop to the next statement in the previous loop? It leaves the loop at the END statement that matches the DO statement as labelled. So it goes to the next statement in the surrounding loop. >> If the label is omitted then the immediately containing loop is >> left. > > "immediately containing loop" meaning loop_3 if we're in loop_3? Correct. It's the same as break. > yup! and i did catch the THEH->THEN oops... no problems there O:) Ageing eyes, I'm afraid. When I remove my contact lenses at night I have very distorted corneas (keratoconus) and cannot easily distinguish an H from an N. ... :-( - -- Regards, Dave [RLU #314465] *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* david.w.n...@googlemail.com (David W Noon) *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* -BEGIN PGP SIGNATURE- Version: GnuPG v2 iEYEARECAAYFAlYdJV4ACgkQogYgcI4W/5QZKgCaA7lhDyhW/D0E+ATdBhrkzyIM YrsAmwYelE+svkFxHDZvKLP3AJ/HZ8DN =WNCc -END PGP SIGNATURE- ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
On 10/13/2015 1:32 AM, Michael Van Canneyt wrote: I don't understand why anyone would want this marginal functionality and thus (again) needlessly complicates the language, but hey, it's a (mostly) free world Alas, the monstrosity that Object Pascal syntax is becoming is less and less appealing by the day, it's simply frightening... +1 Ralf --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
On 10/13/2015 09:40 AM, Mark Morgan Lloyd wrote: wkitt...@windstream.net wrote: a... my bad... sorry 'bout that... i've been thinking about this, too... 'else' and 'otherwise' mean the same thing... what they seem to be looking for is 'aswell'... foo := 0; while foo < 100 do begin inc(foo); end; aswell begin dec(foo); end; either 'aswell' or 'aswellas'... while foo is less than 100 increment foo as well as decrement foo when it is no longer less than 100... If somebody really has to do this wouldn't "also" be a better choice to avoid (getting close to overloading "as"? :-/ it might... i don't know anything about "as" because i've never used it... what does it do? -- NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list* unless private contact is specifically requested and granted. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
wkitt...@windstream.net wrote: a... my bad... sorry 'bout that... i've been thinking about this, too... 'else' and 'otherwise' mean the same thing... what they seem to be looking for is 'aswell'... foo := 0; while foo < 100 do begin inc(foo); end; aswell begin dec(foo); end; either 'aswell' or 'aswellas'... while foo is less than 100 increment foo as well as decrement foo when it is no longer less than 100... I am not native English, but aswell to me implies "do both" and gives no order. So I would expect this (the aswell block) to be executed for each iteration too. like the perl continue block http://perldoc.perl.org/functions/continue.html btw, while I am not for it, the continue block appears much more useful than the "on-none-break" block. Though the continue block is not really ever needed, usually you can write the loop with the counter decrement at the top. But the existence of such a continue block shows the fundamental issue on which a decision is needed. should (if a volunteer for a patch exists) every little "save one statement in your code helper" be added? Because there are thousands of them, and if you add them all the readability of code will go down, because you need to first learn them all. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
Am 13.10.2015 19:21 schrieb: >> >> If somebody really has to do this wouldn't "also" be a better choice to avoid >> (getting close to overloading "as"? :-/ > > > it might... i don't know anything about "as" because i've never used it... what does it do? It's an operator for casting classes and interfaces in a safe way (which means that an exception is raised if the cast fails). See here: http://www.freepascal.org/docs-html/ref/refsu47.html#x141-15100012.8.7 Regards, Sven ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
On Tue, 13 Oct 2015, Martin Frb wrote: wkitt...@windstream.net wrote: a... my bad... sorry 'bout that... i've been thinking about this, too... 'else' and 'otherwise' mean the same thing... what they seem to be looking for is 'aswell'... foo := 0; while foo < 100 do begin inc(foo); end; aswell begin dec(foo); end; either 'aswell' or 'aswellas'... while foo is less than 100 increment foo as well as decrement foo when it is no longer less than 100... I am not native English, but aswell to me implies "do both" and gives no order. So I would expect this (the aswell block) to be executed for each iteration too. like the perl continue block http://perldoc.perl.org/functions/continue.html btw, while I am not for it, the continue block appears much more useful than the "on-none-break" block. Though the continue block is not really ever needed, usually you can write the loop with the counter decrement at the top. But the existence of such a continue block shows the fundamental issue on which a decision is needed. should (if a volunteer for a patch exists) every little "save one statement in your code helper" be added? Because there are thousands of them, and if you add them all the readability of code will go down, because you need to first learn them all. I think the answer to your question is a clear and loud "NO". The argument that we can refrain from using these new features does not hold, because other people will be using it, and we will have to know all of it to be able to understand their code. None of these features will automagically make Object Pascal a popular language. However, I seem to be one of the very few thinking this given the enthousiasm with which people are discussing this. Soon I will be forced to emigrate to Javascript country. Despite all its drawbacks, it remains at least a simple language. a dozen keywords and you're done. No wonder Node.js is so popular. Compare that with the jungle we're making of it... :( Michael. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
On Tue, Oct 13, 2015 at 5:25 PM, Michael Van Canneytwrote: > However, I seem to be one of the very few thinking this given the > enthousiasm with which people are discussing this. > Even Niklaus Wirth regrets about bloating languages: https://www.youtube.com/watch?v=BJIqHIYSDrk thanks, Dmitry ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
On Tue, 13 Oct 2015 23:25:03 +0200 (CEST) Michael Van Canneytwrote: >[...] > The argument that we can refrain from using these new features does not hold, > because other people will be using it, and we will have to know all of it to > be able to understand their code. And it costs precious time of documentation and tool writers, who are already lacking behind. And every new feature makes the compiler a bit slower, costing time of all users. Each new feature must present a solid case, why it is needed aka outweighs the downside. > None of these features will automagically make Object Pascal a popular > language. > > However, I seem to be one of the very few thinking this given the enthousiasm > with > which people are discussing this. Are you kidding? Some people are already forking FPC because of such things. > Soon I will be forced to emigrate to Javascript country. > Despite all its drawbacks, it remains at least a simple language. > a dozen keywords and you're done. No wonder Node.js is so popular. > Compare that with the jungle we're making of it... :( Well, then you should vote against this new functionality. Mattias ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
Am 11.10.2015 23:56 schrieb "Steve Smith": > > Am I being stupid? It's late here so... > > What's wrong with > > === code begin === > > while bool do >foo; > bar; > > or > > repeat >foo; > until bool; > > bar; > > === code end === You know... You got me there... Though at least for the while-loop it may have a use if one defines the then-clause as being executed only if the loop was entered once. Or - using a different keyword - if the loop was never executed. The repeat-loop however is always executed at least once, so there it's completely useless indeed... Regards, Sven ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
Am 12.10.2015 03:19 schrieb "Dmitry Boyarintsev": > > a bit off-topic, > > But has case-otherwise been in FPC from the start? > > I believe it came from GNU pascal ( http://www.gnu-pascal.de/gpc/otherwise.html) and never existed in Delphi world ( http://docwiki.embarcadero.com/RADStudio/XE3/en/Declarations_and_Statements#Case_Statements) ?! > I can see that FPC compiles case-otherwise for any syntax mode. It's from Extended ISO Pascal and I don't know for how long it exists in FPC already, but it does so definitely for some time. Regards, Sven ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
Am 12.10.2015 17:17 schrieb "Dmitry Boyarintsev": > About while-then. While the syntax is unlikely to break anything, it's inconsistent with if-statement. > where, if-then is executed when condition is true. > For while-then is executed then condition is false. > Thus, while-else or while-otherwise are better. However, both syntax would cause code incompatibility. It's less about consistency with if-then, but more about consistency from a human language point of view. "while true do this then that" reads more or less as well as "while true do this otherwise that" (though both carry a slightly different meaning) with the added benefit of the former not to break any existing code (as you had written yourself). Regards, Sven ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
On Mon, Oct 12, 2015 at 2:07 AM, Sven Barthwrote: > It's from Extended ISO Pascal and I don't know for how long it exists in > FPC already, but it does so definitely for some time. > Thanks! I've never thought to go and read the FP documentation on "case statement", assuming it works in turbo pascal/delphi compatible way. About while-then. While the syntax is unlikely to break anything, it's inconsistent with if-statement. where, if-then is executed when condition is true. For while-then is executed then condition is false. Thus, while-else or while-otherwise are better. However, both syntax would cause code incompatibility. thanks, Dmitry ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
On Mon, Oct 12, 2015 at 1:35 PM, Ralf Quintwrote: > > Either the while loop is executed or it isn't, depending in the > expression. I don't see an actual use case for any else/otherwise extension > to it... > You probably want to reread python while-else implementation. ( https://docs.python.org/2/reference/compound_stmts.html) "Else" becomes sort of "part of the loop". Thus if you break out of the loop, "else" would not be executed. However, if no break occurs "else" part would be executed. It might be a rare case where it's needed. (I cannot think of any), but to achieve exactly the same functionality in Pascal either of two options should be used. 1) make an extra check if break occurred. breakflag:=false; while cond do if someothercond then begin breakflag : =true; break; end; if not breakflag then while_else_code 2) use goto! :) label postElseLabel while cond do if someothercond then begin goto postElseLabel end; while_else_code :postElseLabel thanks, Dmitry ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
On 10/12/2015 10:18 AM, Michael Van Canneyt wrote: That is the meaning of "However, both syntax would cause code incompatibility." and is already in my very first reply to OP. So While... else or While .. Otherwise will never make it in the compiler. Thanks for that. This is s typical example of one of those things that just don't make any sense in the first place. Either the while loop is executed or it isn't, depending in the expression. I don't see an actual use case for any else/otherwise extension to it... Ralf --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
On 10/12/2015 10:47 AM, Dmitry Boyarintsev wrote: On Mon, Oct 12, 2015 at 1:35 PM, Ralf Quint> wrote: Either the while loop is executed or it isn't, depending in the expression. I don't see an actual use case for any else/otherwise extension to it... You probably want to reread python while-else implementation. (https://docs.python.org/2/reference/compound_stmts.html) Sorry, we are programming here in Pascal, not Python. I could give a rodent's posterior about what Python implements. People need to properly design their software, not just hacking away. Then they do not need to come up with whacko stop-gaps to fix what could have been done properly in the first place... Ralf --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
On Mon, Oct 12, 2015 at 1:54 PM, Ralf Quintwrote: > Sorry, we are programming here in Pascal, not Python. I could give a > rodent's posterior about what Python implements. > > People need to properly design their software, not just hacking away. Then > they do not need to come up with whacko stop-gaps to fix what could have > been done properly in the first place... > Well, from fpc-devel list perspective your only hope is that any new feature is added via MODESWITCH. Thus any existing unit would be kept clean. You would also be able to keep your libraries clean, by not allowing using of a certain modeswitches. However, if you look at the recent (for the past few months) discussions, you might spot that the number of requests for new features (from recent Delphi and other languages) is growing. Constantly. In this particular case it's even worse (actually it's better, from fpc-devel POV), since the patch has been provided. The next step would probably be controlled "break", where a user would be able to specify how many nested loops needed to broken from. thanks, Dmitry ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
On Mon, 12 Oct 2015, Max Nazhalov wrote: On 12.10.2015 17:17 schrieb "Dmitry Boyarintsev" wrote: About while-then. While the syntax is unlikely to break anything, it's inconsistent with if-statement. where, if-then is executed when condition is true. For while-then is executed then condition is false. Thus, while-else or while-otherwise are better. However, both syntax would cause code incompatibility. I doubt "while-else" is a variant, due to dangling "else". How will be compiled, e.g. if something then while not_done_yet do the_work else // obviously valid, and expected to be a part of "if-then-else" something_else_happened; That is the meaning of "However, both syntax would cause code incompatibility." and is already in my very first reply to OP. So While... else or While .. Otherwise will never make it in the compiler. Michael. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
Ralf Quint wrote: On 10/12/2015 10:18 AM, Michael Van Canneyt wrote: That is the meaning of "However, both syntax would cause code incompatibility." and is already in my very first reply to OP. So While... else or While .. Otherwise will never make it in the compiler. Thanks for that. This is s typical example of one of those things that just don't make any sense in the first place. Either the while loop is executed or it isn't, depending in the expression. I don't see an actual use case for any else/otherwise extension to it... The only possible use would be to specify a finalisation statement which was only executed if the while loop cycled at least once, or possibly one which was executed if the loop never cycled. -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
On 12/10/15 18:47, Dmitry Boyarintsev wrote: On Mon, Oct 12, 2015 at 1:35 PM, Ralf Quint> wrote: Either the while loop is executed or it isn't, depending in the expression. I don't see an actual use case for any else/otherwise extension to it... You probably want to reread python while-else implementation. (https://docs.python.org/2/reference/compound_stmts.html) "Else" becomes sort of "part of the loop". Thus if you break out of the loop, "else" would not be executed. However, if no break occurs "else" part would be executed. It might be a rare case where it's needed. (I cannot think of any), but to achieve exactly the same functionality in Pascal either of two options should be used. 1) make an extra check if break occurred. breakflag:=false; while cond do if someothercond then begin breakflag : =true; break; end; if not breakflag then while_else_code 2) use goto! :) label postElseLabel while cond do if someothercond then begin goto postElseLabel end; while_else_code :postElseLabel thanks, Dmitry I can't think of a use case either. And just because another language provides such a solution, does not imply that FPC should. As to achieving the functionality in FPC: if cond then while cond do foo else bar; should suffice; Breakflags and gotos not required! ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
Am 12.10.2015 20:02 schrieb "Dmitry Boyarintsev": > > On Mon, Oct 12, 2015 at 1:54 PM, Ralf Quint wrote: >> >> Sorry, we are programming here in Pascal, not Python. I could give a rodent's posterior about what Python implements. >> >> People need to properly design their software, not just hacking away. Then they do not need to come up with whacko stop-gaps to fix what could have been done properly in the first place... > > > Well, from fpc-devel list perspective your only hope is that any new feature is added via MODESWITCH. Thus any existing unit would be kept clean. You would also be able to keep your libraries clean, by not allowing using of a certain modeswitches. Since one point of this discussion is to implement in a way that it doesn't break anything, it wouldn't be implemented.behind a modeswitch probably. > However, if you look at the recent (for the past few months) discussions, you might spot that the number of requests for new features (from recent Delphi and other languages) is growing. Constantly. True... > In this particular case it's even worse (actually it's better, from fpc-devel POV), since the patch has been provided. However we did nowhere state that we'd incorporate the feature. I only said that I'd definitely look at it to check whether the work in principle is good. > The next step would probably be controlled "break", where a user would be able to specify how many nested loops needed to broken from. That would be more useful than the while-else though :P Regards, Sven ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
On 10/12/2015 01:47 PM, Dmitry Boyarintsev wrote: On Mon, Oct 12, 2015 at 1:35 PM, Ralf Quintwrote: Either the while loop is executed or it isn't, depending in the expression. I don't see an actual use case for any else/otherwise extension to it... You probably want to reread python while-else implementation. (https://docs.python.org/2/reference/compound_stmts.html) "Else" becomes sort of "part of the loop". Thus if you break out of the loop, "else" would not be executed. However, if no break occurs "else" part would be executed. that just doesn't make grammatical sense... foo := 0; while foo < 100 do inc(foo); else dec(foo); end so, if foo is less than 100 we inc(foo)... if foo is not less than 100 we dec(foo)... that's the only way that an "else" can be read... either the boolean is true or /else/ it is false... only if it is false can the else portion be executed... (#2) but then the question is does dec(foo) execute only once or does it execute as long as foo is greater than 100?? what i seem to see is pure laziness of a sort... folks too lazy to write an "if" or "if/else" statement and put the while inside... foo := 0; if foo < 100 then while foo < 100 do inc(foo); else dec(foo); OR depending on the answer of (#2) above... foo := 0; if foo < 100 then while foo < 100 do inc(foo); while foo > 100 do dec(foo); or maybe this is the actual intent? foo := 0; if foo < 100 then while foo < 100 do inc(foo); if foo > 100 then dec(foo); seems like a pretty tough way to have foo equal to 99, eh? ;) It might be a rare case where it's needed. (I cannot think of any), but to achieve exactly the same functionality in Pascal either of two options should be used. 1) make an extra check if break occurred. [...] 2) use goto! :) neither is needed at all in most cases and then not if they have proper logic in place ;) -- NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list* unless private contact is specifically requested and granted. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
In our previous episode, Sven Barth said: > world ( > http://docwiki.embarcadero.com/RADStudio/XE3/en/Declarations_and_Statements#Case_Statements) > ?! > > I can see that FPC compiles case-otherwise for any syntax mode. > > It's from Extended ISO Pascal and I don't know for how long it exists in > FPC already, but it does so definitely for some time. Afaik from when mode macpas was added (CodeWarrior) by Olle and Jonas. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
>> I can't think of a use case either. And just because another language >> provides such a solution, does not imply that FPC should. 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.. The only drawback is that "cond" is calculated twice instead of once before the actual loop body -- not all will be happy.. ;-) -- WBR, Max. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
[fpc-devel] Fwd: While - Otherwise Statement
> I can't think of a use case either. And just because another language > provides such a solution, does not imply that FPC should. 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.. --- WBR, Max. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
On 10/12/2015 02:02 PM, Dmitry Boyarintsev wrote: The next step would probably be controlled "break", where a user would be able to specify how many nested loops needed to broken from. ROTFLMAO! if you need or desire something like that then set a breakcounter and break... in the next outer block, check breakcounter to see if you need to break again... if so, dec(breakcounter) and break... then check it again in the next outer block... and so on and so on until breakcounter=0... why should the compiler have to do your logic work for you? ;) -- NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list* unless private contact is specifically requested and granted. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
On Mon, Oct 12, 2015 at 3:11 PM,wrote: > On 10/12/2015 02:02 PM, Dmitry Boyarintsev wrote: > >> >> The next step would probably be controlled "break", where a user would be >> able >> to specify how many nested loops needed to broken from. >> > > ROTFLMAO! if you need or desire something like that then set a > breakcounter and break... in the next outer block, check breakcounter to > see if you need to break again... if so, dec(breakcounter) and break... > then check it again in the next outer block... and so on and so on until > breakcounter=0... why should the compiler have to do your logic work for > you? ;) > How would you know if a nested loop finished properly or broke out? ...Just imagine yourself a 4 nested for loops and you need to break out from the 4th to the 1st? thanks, Dmitry ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
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. 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. 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
Re: [fpc-devel] Fwd: While - Otherwise Statement
On 10/12/2015 03:33 PM, Dmitry Boyarintsev wrote: On Mon, Oct 12, 2015 at 3:11 PM,> wrote: On 10/12/2015 02:02 PM, Dmitry Boyarintsev wrote: The next step would probably be controlled "break", where a user would be able to specify how many nested loops needed to broken from. ROTFLMAO! if you need or desire something like that then set a breakcounter and break... in the next outer block, check breakcounter to see if you need to break again... if so, dec(breakcounter) and break... then check it again in the next outer block... and so on and so on until breakcounter=0... why should the compiler have to do your logic work for you? ;) How would you know if a nested loop finished properly or broke out? ...Just imagine yourself a 4 nested for loops and you need to break out from the 4th to the 1st? by checking the value that caused the break ;) deity knows i've done it many times before back in the TP/BP 6&7 days... i did it exactly as described, too... we had to do it that way as there is/was no other way to do it ;) -- NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list* unless private contact is specifically requested and granted. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
On Mon, Oct 12, 2015 at 3:47 PM,wrote: > by checking the value that caused the break ;) deity knows i've done it > many times before back in the TP/BP 6&7 days... i did it exactly as > described, too... we had to do it that way as there is/was no other way to > do it ;) That's exactly the thing. You didn't have a cross-loop break, that's why you've to have some guaranteed values that would allow you to verify if a loop was broken or not. If it was broken then you'd set any additional conditions (if needed) to break out another loop and pass it above. In the end you end-up having additional break condition checks in each loop. Just by the fact, that a language doesn't provide you with any other means to do it less complex. I'd also need to note, that no other language, to my knowledge, have cross-loop breaks anyway :) Good-old language (Pascal / C /C++) still have goto though... but we won't use it, right? thanks, Dmitry ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
On 10/12/2015 11:33 AM, Sven Barth wrote: Am 12.10.2015 20:02 schrieb "Dmitry Boyarintsev">: > > On Mon, Oct 12, 2015 at 1:54 PM, Ralf Quint > wrote: >> >> Sorry, we are programming here in Pascal, not Python. I could give a rodent's posterior about what Python implements. >> >> People need to properly design their software, not just hacking away. Then they do not need to come up with whacko stop-gaps to fix what could have been done properly in the first place... > > > Well, from fpc-devel list perspective your only hope is that any new feature is added via MODESWITCH. Thus any existing unit would be kept clean. You would also be able to keep your libraries clean, by not allowing using of a certain modeswitches. Since one point of this discussion is to implement in a way that it doesn't break anything, it wouldn't be implemented.behind a modeswitch probably. > However, if you look at the recent (for the past few months) discussions, you might spot that the number of requests for new features (from recent Delphi and other languages) is growing. Constantly. True... > In this particular case it's even worse (actually it's better, from fpc-devel POV), since the patch has been provided. However we did nowhere state that we'd incorporate the feature. I only said that I'd definitely look at it to check whether the work in principle is good. > The next step would probably be controlled "break", where a user would be able to specify how many nested loops needed to broken from. That would be more useful than the while-else though :P Yes, I have seen a lot of those requests and pretty much none of them made any sense to me. As I already stated, it always seems to me that someone wants to have something implemented that they have seen in a different language, which might have a different approach to programming to begin with or they "think" they need a specific feature to get them out of a pickle they got themselves into because they are just hacking away instead of properly designing their programs. Neither of those case are IMHO valid to mess around with a working compiler. If someone is so fond of the features that Python/Haskell/Erland/jour> provides, then they should use that to solve their programming issues. They apparently don't understand how to use Pascal... Ralf --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
On 10/12/2015 03:43 PM, Martin Frb wrote: 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. exactly my and others' points... "and" would be better but then one might just as easily use a goto to jump around that part if break was used to get out of the loop... anyway, it seems that no matter what the discussion, it won't make it into the compiler... that according to another post from a compiler dev ;) -- NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list* unless private contact is specifically requested and granted. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
On 10/12/2015 04:10 PM, Dmitry Boyarintsev wrote: On Mon, Oct 12, 2015 at 3:47 PM,> wrote: by checking the value that caused the break ;) deity knows i've done it many times before back in the TP/BP 6&7 days... i did it exactly as described, too... we had to do it that way as there is/was no other way to do it ;) That's exactly the thing. You didn't have a cross-loop break, that's why you've to have some guaranteed values that would allow you to verify if a loop was broken or not. yeah... i implemented my needed logic for that type of scenario... just like any good programmer can/will/should do... If it was broken then you'd set any additional conditions (if needed) to break out another loop and pass it above. In the end you end-up having additional break condition checks in each loop. Just by the fact, that a language doesn't provide you with any other means to do it less complex. ok... so instead we'll have the compiler perform my business logic for me? no thanks... the compiler has enough to do already ;) I'd also need to note, that no other language, to my knowledge, have cross-loop breaks anyway :) Good-old language (Pascal / C /C++) still have goto though... but we won't use it, right? that's right... i think i may have used goto once in 30 years or however long it has been available in pascal... i started self-taught with basic... goto and gosub all over the place... tough as hades to follow the code and no apparent logical layout... i was ecstatic when a friend turned me on to pascal and asm... i dropped basic like a hot potato[e?] and never looked back... especially never looking back at goto ;) ;) ;) -- NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list* unless private contact is specifically requested and granted. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
Am 12.10.2015 21:43 schrieb "Martin Frb": >> 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. The optimizer might not be able to do anything if the expression is a function call that can not be inlined. Regards, Sven ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
On 10/12/2015 05:19 PM, Sven Barth wrote: Am 12.10.2015 22:48 schrieb>: > anyway, it seems that no matter what the discussion, it won't make it into the compiler... that according to another post from a compiler dev ;) I said that I'm not sure. it wasn't you that made that statement but if you are willing to add it, i guess maybe it will make it ;) Right now I'm considering that mostly as way for the author to learn about the ways to extend the compiler and what would be needed for a feature patch to be accepted. that's great! it can be a tough row to hoe learning what the proper workflow is when contributing to any project... Whether this specific feature would be added or not is a different topic. +1 -- NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list* unless private contact is specifically requested and granted. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
On 10/12/2015 06:15 PM, David W Noon wrote: On Mon, 12 Oct 2015 15:11:18 -0400, Wkitty42 (wkitt...@windstream.net) wrote about "Re: [fpc-devel] Fwd: While - Otherwise Statement" (in <561c05d6.4010...@windstream.net>): On 10/12/2015 02:02 PM, Dmitry Boyarintsev wrote: The next step would probably be controlled "break", where a user would be able to specify how many nested loops needed to broken from. ROTFLMAO! if you need or desire something like that then set a breakcounter and break... in the next outer block, check breakcounter to see if you need to break again... if so, dec(breakcounter) and break... then check it again in the next outer block... and so on and so on until breakcounter=0... why should the compiler have to do your logic work for you? ;) Hi Mark, hiya dave!! it has been a long time, my friend!! You might have seen me write things like this in the old OS2PROG echo of Fidonet some 20+ years ago. ... :-) oh yeah! that echo still exists, too... but it only contains monthly moderator postings these days... it is ready for you any time you want to join back in... nntp access is available via some systems but the dawg grows older with each passing year :? The only language I know that offers that level of control is PL/I, where the break statement is coded as LEAVE. It is handled by labelling the loop control statement and coding the required label in the LEAVE statement. For example: that looks very much like what some would consider goto statements... does the leave return to the top of the previous loop or does it drop to the next statement in the previous loop? If the label is omitted then the immediately containing loop is left. "immediately containing loop" meaning loop_3 if we're in loop_3? This allows any of the nested loops to be escaped, potentially all the way out. I guess the corresponding syntax in a Pascal-esque style would be: that does look interesting for breaks and i can see how it may be beneficial and save some bit of coding but then those of us who have been around a while know how to work our way back out when necessary, right? ;) If we're being strictly Pascal, the labels would need to be declared at the head of the procedure -- and if we're really strict they should be numeric. yup! and i did catch the THEH->THEN oops... no problems there O:) -- NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list* unless private contact is specifically requested and granted. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Mon, 12 Oct 2015 23:15:31 +0100, David W Noon (david.w.n...@googlemail.com) wrote about "Re: [fpc-devel] Fwd: While - - Otherwise Statement" (in <561c3103.1060...@googlemail.com>): [snip] > IF some_condition THEH IF another_condition THEH IF > some_other_condition THEH These should all end in "THEN", not "THEH". - -- Regards, Dave [RLU #314465] *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* david.w.n...@googlemail.com (David W Noon) *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* -BEGIN PGP SIGNATURE- Version: GnuPG v2 iEYEARECAAYFAlYcM7sACgkQogYgcI4W/5SQagCfV6i2NrBee3h76kegPVARLq5V j7sAoNNPDGBtwsEWqdrrRiLylwoJkH7k =ZVGL -END PGP SIGNATURE- ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
On Mon, Oct 12, 2015 at 7:15 PM, David W Noon <david.w.n...@googlemail.com> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On Mon, 12 Oct 2015 15:11:18 -0400, Wkitty42 (wkitt...@windstream.net) > wrote about "Re: [fpc-devel] Fwd: While - Otherwise Statement" (in > <561c05d6.4010...@windstream.net>): > >> On 10/12/2015 02:02 PM, Dmitry Boyarintsev wrote: >>> >>> The next step would probably be controlled "break", where a user >>> would be able to specify how many nested loops needed to broken >>> from. > > Hi Mark, > > You might have seen me write things like this in the old OS2PROG echo > of Fidonet some 20+ years ago. ... :-) > > The only language I know that offers that level of control is PL/I, > where the break statement is coded as LEAVE. It is handled by > labelling the loop control statement and coding the required label in > the LEAVE statement. For example: > >loop_1: DO i = 1 TO m; > loop_2 : DO j = 1 TO n; > loop_3: DO k = 1 TO p; >... >IF some_condition THEH > LEAVE loop_3;[...] If I'm not missing something, Java implements 'break' just like this. I'd like such enhancement, but right now is there any reason to avoid 'goto' besides the bad karma? Regards, Flávio ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Mon, 12 Oct 2015 15:11:18 -0400, Wkitty42 (wkitt...@windstream.net) wrote about "Re: [fpc-devel] Fwd: While - Otherwise Statement" (in <561c05d6.4010...@windstream.net>): > On 10/12/2015 02:02 PM, Dmitry Boyarintsev wrote: >> >> The next step would probably be controlled "break", where a user >> would be able to specify how many nested loops needed to broken >> from. > > ROTFLMAO! if you need or desire something like that then set a > breakcounter and break... in the next outer block, check > breakcounter to see if you need to break again... if so, > dec(breakcounter) and break... then check it again in the next > outer block... and so on and so on until breakcounter=0... why > should the compiler have to do your logic work for you? ;) Hi Mark, You might have seen me write things like this in the old OS2PROG echo of Fidonet some 20+ years ago. ... :-) The only language I know that offers that level of control is PL/I, where the break statement is coded as LEAVE. It is handled by labelling the loop control statement and coding the required label in the LEAVE statement. For example: loop_1: DO i = 1 TO m; loop_2 : DO j = 1 TO n; loop_3: DO k = 1 TO p; ... IF some_condition THEH LEAVE loop_3; ... IF another_condition THEH LEAVE loop_2; ... IF some_other_condition THEH LEAVE loop_1; ... END loop_3; END loop_2; END loop_1; If the label is omitted then the immediately containing loop is left. This allows any of the nested loops to be escaped, potentially all the way out. I guess the corresponding syntax in a Pascal-esque style would be: loop_1: FOR i := 1 TO m DO BEGIN loop_2: FOR j := 1 TO n DO BEGIN loop_3: FOR k := 1 TO p DO BEGIN ... IF (some_condition) THEN BREAK loop_1; ... IF (another_condition) THEN BREAK loop_2; ... IF (some_other_condition) THEN BREAK loop_3; END END END; If we're being strictly Pascal, the labels would need to be declared at the head of the procedure -- and if we're really strict they should be numeric. - -- Regards, Dave [RLU #314465] *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* david.w.n...@googlemail.com (David W Noon) *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* -BEGIN PGP SIGNATURE- Version: GnuPG v2 iEYEARECAAYFAlYcMQMACgkQogYgcI4W/5Sl3wCgtG87fG2aCEuxkVCUrBCmxwCm fSkAoNgXwMSNA/R4AKjDEZsNktglOqvF =m3vh -END PGP SIGNATURE- ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
Am 12.10.2015 22:48 schrieb: > anyway, it seems that no matter what the discussion, it won't make it into the compiler... that according to another post from a compiler dev ;) I said that I'm not sure. Right now I'm considering that mostly as way for the author to learn about the ways to extend the compiler and what would be needed for a feature patch to be accepted. Whether this specific feature would be added or not is a different topic. Regards, Sven ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
[fpc-devel] Fwd: While - Otherwise Statement
Hi everybody I add new feature to FPC compiler to simplify programming. this is While - Otherwise working like While - Else in python and has backwards compatibility. Examples Ex1: While (I<5) do begin Writeln(I); Dec(I); end otherwise writeln('otherwise'); Ex2: While (I<5) do begin Writeln(I); Dec(I); break; end otherwise writeln('otherwise'); Ex3: if (I<10) then While (I<5) do begin Writeln(I); Dec(I); break; end otherwise writeln('otherwise') else writeln('else'); I attached a svn diff file to email and I'm going to add For-Otherwise and more. please test it and let me know what you think. mohsen Index: ncgflw.pas === --- ncgflw.pas (revision 32016) +++ ncgflw.pas (working copy) @@ -132,7 +132,7 @@ procedure tcgwhilerepeatnode.pass_generate_code; var - lcont,lbreak,lloop, + lcont,lbreak,lloop,lotherwise, oldclabel,oldblabel : tasmlabel; truelabel,falselabel : tasmlabel; oldflowcontrol : tflowcontrol; @@ -143,6 +143,7 @@ current_asmdata.getjumplabel(lloop); current_asmdata.getjumplabel(lcont); current_asmdata.getjumplabel(lbreak); + current_asmdata.getjumplabel(lotherwise); { arrange continue and breaklabels: } oldflowcontrol:=flowcontrol; oldclabel:=current_procinfo.CurrContinueLabel; @@ -184,17 +185,21 @@ hlcg.a_label(current_asmdata.CurrAsmList,lcont); if lnf_checknegate in loopflags then begin - truelabel:=lbreak; + truelabel:=lotherwise; falselabel:=lloop; end else begin truelabel:=lloop; - falselabel:=lbreak; + falselabel:=lotherwise; end; secondpass(left); + hlcg.maketojumpboollabels(current_asmdata.CurrAsmList,left,truelabel,falselabel); + hlcg.a_label(current_asmdata.CurrAsmList,lotherwise); + if (Assigned(t1)) then begin + secondpass(t1); + end; - hlcg.maketojumpboollabels(current_asmdata.CurrAsmList,left,truelabel,falselabel); hlcg.a_label(current_asmdata.CurrAsmList,lbreak); sync_regvars(false); Index: nflw.pas === --- nflw.pas(revision 32016) +++ nflw.pas(working copy) @@ -71,8 +71,11 @@ function docompare(p: tnode): boolean; override; end; + { twhilerepeatnode } + twhilerepeatnode = class(tloopnode) constructor create(l,r:Tnode;tab,cn:boolean);virtual;reintroduce; + constructor create(l,r,e:Tnode;tab,cn:boolean);virtual;reintroduce; function pass_typecheck:tnode;override; function pass_1 : tnode;override; {$ifdef state_tracking} @@ -1046,7 +1049,7 @@ TWHILEREPEATNODE *} -constructor Twhilerepeatnode.create(l,r:Tnode;tab,cn:boolean); +constructor twhilerepeatnode.create(l, r: Tnode; tab, cn: boolean); begin inherited create(whilerepeatn,l,r,nil,nil); if tab then @@ -1055,6 +1058,15 @@ include(loopflags,lnf_checknegate); end; +constructor twhilerepeatnode.create(l, r, e: Tnode; tab, cn: boolean); +begin +inherited create(whilerepeatn,l,r,e,nil); + if tab then + include(loopflags, lnf_testatbegin); + if cn then + include(loopflags,lnf_checknegate); +end; + function twhilerepeatnode.pass_typecheck:tnode; var t:Tunarynode; Index: pstatmnt.pas === --- pstatmnt.pas(revision 32016) +++ pstatmnt.pas(working copy) @@ -328,7 +328,7 @@ function while_statement : tnode; var - p_e,p_a : tnode; + p_e,p_a,else_a : tnode; begin consume(_WHILE); @@ -335,7 +335,11 @@ p_e:=comp_expr(true,false); consume(_DO); p_a:=statement; - result:=cwhilerepeatnode.create(p_e,p_a,true,false); + if (try_to_consume(_OTHERWISE)) then + else_a := statement + else + else_a := nil; +Result := cwhilerepeatnode.Create(p_e, p_a, else_a, True, False); end; { a helper function which is used both by "with" and "for-in loop" nodes } ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
Am 11.10.2015 15:56 schrieb "MohsenTi": > > Hi everybody > > I add new feature to FPC compiler to simplify programming. > this is While - Otherwise working like While - Else in python and has backwards compatibility. Nice idea with the otherwise. I first thought that this would break case-statements that use otherwise instead of else, but then I remembered that the case-label-blocks can and IMHO should be terminated by ; anyway. At least problems can be easily circumvented. I don't know whether we'll add it to trunk, but I'll at least take a look at your code to give you feedback. Oh, and please provide simple tests for your feature that could be added to our testsuite (in tests/test or tests/tbs) in case we decide to incorporate it. Speaking of which: did you run the testsuite and compared the results to a run without modifications? (If you need help with running the testsuite or interpreting the results, please ask, I have yet to write a wiki page for that...) Regards, Sven ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
I create 2 test files depends on testsuite readme file and make testsuite with make full command and set TEST_FPC variable to fpc ppcx64 compiler. for-otherwise and while-otherwise diff file and test files attached to email. test result : Total = 6906 (75:6831) Total number of compilations = 4264 (60:4204) Successfully compiled = 3147 Successfully failed = 1057 Compilation failures = 55 Compilation that did not fail while they should = 5 Total number of runs = 2642 (15:2627) Successful runs = 2627 Failed runs = 15 Number units compiled = 135 Number program that should not be run = 367 Number of skipped tests = 404 Number of skipped graph tests = 10 Number of skipped interactive tests = 31 Number of skipped known bug tests = 6 Number of skipped tests for other versions = 4 Number of skipped tests for other cpus = 190 Number of skipped tests for other targets = 163 I checked failed ones but it seems they are not related to my changes. What you think? thanks a lot On Sun, Oct 11, 2015 at 6:44 PM, Sven Barthwrote: > Am 11.10.2015 15:56 schrieb "MohsenTi" : > > > > Hi everybody > > > > I add new feature to FPC compiler to simplify programming. > > this is While - Otherwise working like While - Else in python and has > backwards compatibility. > > Nice idea with the otherwise. I first thought that this would break > case-statements that use otherwise instead of else, but then I remembered > that the case-label-blocks can and IMHO should be terminated by ; anyway. > At least problems can be easily circumvented. > > I don't know whether we'll add it to trunk, but I'll at least take a look > at your code to give you feedback. > > Oh, and please provide simple tests for your feature that could be added > to our testsuite (in tests/test or tests/tbs) in case we decide to > incorporate it. > Speaking of which: did you run the testsuite and compared the results to a > run without modifications? > (If you need help with running the testsuite or interpreting the results, > please ask, I have yet to write a wiki page for that...) > > Regards, > Sven > > ___ > fpc-devel maillist - fpc-devel@lists.freepascal.org > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel > > Index: ncgflw.pas === --- ncgflw.pas (revision 32016) +++ ncgflw.pas (working copy) @@ -132,7 +132,7 @@ procedure tcgwhilerepeatnode.pass_generate_code; var - lcont,lbreak,lloop, + lcont,lbreak,lloop,lotherwise, oldclabel,oldblabel : tasmlabel; truelabel,falselabel : tasmlabel; oldflowcontrol : tflowcontrol; @@ -143,6 +143,7 @@ current_asmdata.getjumplabel(lloop); current_asmdata.getjumplabel(lcont); current_asmdata.getjumplabel(lbreak); + current_asmdata.getjumplabel(lotherwise); { arrange continue and breaklabels: } oldflowcontrol:=flowcontrol; oldclabel:=current_procinfo.CurrContinueLabel; @@ -184,17 +185,21 @@ hlcg.a_label(current_asmdata.CurrAsmList,lcont); if lnf_checknegate in loopflags then begin - truelabel:=lbreak; + truelabel:=lotherwise; falselabel:=lloop; end else begin truelabel:=lloop; - falselabel:=lbreak; + falselabel:=lotherwise; end; secondpass(left); + hlcg.maketojumpboollabels(current_asmdata.CurrAsmList,left,truelabel,falselabel); + hlcg.a_label(current_asmdata.CurrAsmList,lotherwise); + if (Assigned(t1)) then begin + secondpass(t1); + end; - hlcg.maketojumpboollabels(current_asmdata.CurrAsmList,left,truelabel,falselabel); hlcg.a_label(current_asmdata.CurrAsmList,lbreak); sync_regvars(false); @@ -413,7 +418,7 @@ procedure tcgfornode.pass_generate_code; var - l3,oldclabel,oldblabel : tasmlabel; + l3,lotherwise,oldclabel,oldblabel : tasmlabel; temptovalue : boolean; hop : topcg; hcond : topcmp; @@ -430,7 +435,7 @@ current_asmdata.getjumplabel(current_procinfo.CurrContinueLabel); current_asmdata.getjumplabel(current_procinfo.CurrBreakLabel); current_asmdata.getjumplabel(l3); - + current_asmdata.getjumplabel(lotherwise); { only calculate reference } opsize := def_cgsize(left.resultdef); count_var_is_signed:=is_signed(left.resultdef); @@ -794,6 +799,16 @@ tcgint(cmp_const.svalue),left.location,l3); end; + hlcg.a_label(current_asmdata.CurrAsmList,lotherwise); + + if (Assigned(e)) then + begin + oldexecutionweight:=cg.executionweight; + cg.executionweight:=cg.executionweight*8; +
Re: [fpc-devel] Fwd: While - Otherwise Statement
On 11/10/2015 16:14, Sven Barth wrote: Am 11.10.2015 15:56 schrieb "MohsenTi">: > > Hi everybody > > I add new feature to FPC compiler to simplify programming. > this is While - Otherwise working like While - Else in python and has backwards compatibility. Nice idea with the otherwise. I first thought that this would break case-statements that use otherwise instead of else, but then I remembered that the case-label-blocks can and IMHO should be terminated by ; anyway. At least problems can be easily circumvented. "should", but they do not have to, at least not the last one before the otherwise So if old code has case a of 1 : write; 2: while a > 1 do a := a -1 otherwise write; end that will break. (it can be fixed, but so could the if with while else. why not a new keyword? while bool do foo() afterwards [do] // or even "then" would make sense (from english reading perspective) bar(); ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
On 11/10/2015 22:33, Tomas Hajny wrote: On Sun, October 11, 2015 22:48, Sven Barth wrote: . . That "then" is a great idea! That would definitely not break anything and it would make sense indeed: === code begin === while bool do foo then bar; repeat foo; until bool then bar; === code end === I'm afraid that I got lost in this discussion, but what exactly would be the supposed semantic difference between the behaviour compared to situation when there was a semicolon instead of 'then' there? You mean compared to the otherwise solution? The following is currently valid code: case a of 1: write; 2: while a > 0 do dec(a) // no semicolon otherwise write('a was neither 1 nor 2'); end; This code would continue to compile, but it would change meaning/behaviour. So if somebody has code like that, in a million line project, which fails after otherwise was introduced, then it could be a long search for why it fails. (Easy to fix once found, but hard to find) Besides "then" makes more sense (as in reading it as english description). Both else/otherwise, to me read as: If the while block before was not executed at all. In otherwords while a > 0 do write otherwise halt; reads to me "halt" is an alternative to the "while". It gets executed if the while was never executde (a was already <= 0 when while was reached first) "then" in english may mean "after that" and that is what happens here. After the while do something. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
Am 11.10.2015 18:56 schrieb "MohsenTi": > I checked failed ones but it seems they are not related to my changes. It's best you compare the faillist files in tests/output/cpu-os from an unmodified and a modified run. This way you can find out if you had any changes in the testsuite. Also the testfiles /must/ start with a "t". I haven't yet looked at the code though (I'm a bit busy otherwise so it will take some time for me). Regards, Sven ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
Am 11.10.2015 18:34 schrieb "Martin Frb": > > On 11/10/2015 16:14, Sven Barth wrote: >> >> Am 11.10.2015 15:56 schrieb "MohsenTi" : >> > >> > Hi everybody >> > >> > I add new feature to FPC compiler to simplify programming. >> > this is While - Otherwise working like While - Else in python and has backwards compatibility. >> >> Nice idea with the otherwise. I first thought that this would break case-statements that use otherwise instead of else, but then I remembered that the case-label-blocks can and IMHO should be terminated by ; anyway. At least problems can be easily circumvented. > > "should", but they do not have to, at least not the last one before the otherwise I know and that's something I'm probably going to be wondering about for all eternity -.- > why not a new keyword? I'm not a fan of adding new keywords for something like this... > while bool do > foo() > afterwards [do] // or even "then" would make sense (from english reading perspective) > bar(); That "then" is a great idea! That would definitely not break anything and it would make sense indeed: === code begin === while bool do foo then bar; repeat foo; until bool then bar; === code end === Regards, Sven ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
On Sun, October 11, 2015 22:48, Sven Barth wrote: . . > That "then" is a great idea! That would definitely not break anything and > it would make sense indeed: > > === code begin === > while bool do > foo > then > bar; > > repeat > foo; > until bool then > bar; > === code end === I'm afraid that I got lost in this discussion, but what exactly would be the supposed semantic difference between the behaviour compared to situation when there was a semicolon instead of 'then' there? Tomas ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
On 11/10/15 21:48, Sven Barth wrote: That "then" is a great idea! That would definitely not break anything and it would make sense indeed: === code begin === while bool do foo then bar; repeat foo; until bool then bar; === code end === Regards, Sven Am I being stupid? It's late here so... What's wrong with === code begin === while bool do foo; bar; or repeat foo; until bool; bar; === code end === ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
On 11/10/15 22:52, Steve Smith wrote: On 11/10/15 21:48, Sven Barth wrote: That "then" is a great idea! That would definitely not break anything and it would make sense indeed: === code begin === while bool do foo then bar; repeat foo; until bool then bar; === code end === Regards, Sven Am I being stupid? It's late here so... What's wrong with === code begin === while bool do foo; bar; or repeat foo; until bool; bar; === code end === ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel Oops... Sorry Tomas! ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Fwd: While - Otherwise Statement
a bit off-topic, But has case-otherwise been in FPC from the start? I believe it came from GNU pascal ( http://www.gnu-pascal.de/gpc/otherwise.html) and never existed in Delphi world ( http://docwiki.embarcadero.com/RADStudio/XE3/en/Declarations_and_Statements#Case_Statements) ?! I can see that FPC compiles case-otherwise for any syntax mode. thanks, Dmitry ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel