Post Reply 
STRINGFROMID and gradians
09-21-2018, 09:44 AM
Post: #21
RE: STRINGFROMID and gradians
Hello,

"I wouldn't mind an HPPL GOTO statement! Even C has GOTO and it would make translating programs to HPPL easier in some cases."

Unfortunately, this will not happen, at least not anytime soon.

Not because I do not like gotos or anything like that (I have done enough Basic or ASM to know their worth), but because GOTO are actually VERY dificult to implement in a language which has scopes, local variables and the like...

However, since you are talking about goto C, if you look at "non messy code" (ie, code that is reasonably clean) and look at the GOTO usage, you will see that >80% of them are there to cover a single situation. The exit of the inside of a double (or deeper) loop.
Something along the lines of:
for all elements in a list
for all elements in a sub-list
if something, then do it and stop searching (goto end)
end:;

in C, you either have to create boolean and set them in the inner loop and test it in the outer loop, or do a GOTO...
However, in HPPL, you have the EXIT(n) construct which does exactly that for you (CONTINUE(n) is also available)
So, most uses of GOTO are already covered in a much cleaner way...

This does not mean that a GOTO would not be nice, but the lesser need of the functionality makes the implementation investment not really worth it...

Cyrille

Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP.
Find all posts by this user
Quote this message in a reply
09-21-2018, 02:44 PM
Post: #22
RE: STRINGFROMID and gradians
One point to remember though is that if you then surround those two FOR loops with a third FOR loop, your EXIT(2) will now be taking you to the wrong place - the middle, not the end -, if I am not mistaken...

Whereas a GOTO end; - you can see exactly where you are going to, without having to count lots of ENDFOR's, making the code arguably more readable and needing less edits.

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
09-21-2018, 04:49 PM
Post: #23
RE: STRINGFROMID and gradians
(09-21-2018 02:44 PM)StephenG1CMZ Wrote:  One point to remember though is that if you then surround those two FOR loops with a third FOR loop, your EXIT(2) will now be taking you to the wrong place - the middle, not the end -, if I am not mistaken...

Whereas a GOTO end; - you can see exactly where you are going to, without having to count lots of ENDFOR's, making the code arguably more readable and needing less edits.
Problem with EXIT(2)?
There's no difference compared to the formal loop exit.
The execution continues after the loop END;
What is your problem?
Please, explain.
Find all posts by this user
Quote this message in a reply
09-21-2018, 05:47 PM (This post was last modified: 09-22-2018 07:28 AM by StephenG1CMZ.)
Post: #24
RE: STRINGFROMID and gradians
Maybe I'm wrong - I don't use EXIT often.

But
Code:

For i from 1 to 9
For j from 1 to 9
 EXIT(2)
End
End
Here:
Msgbox("ok")
I would expect to reach Here OK.

Now surround that working code with an additional for loop:

For newloop from 1 to 9
For i from 1 to 9
For j from 1 to 9
EXIT(2)
End
End
MSGBOX("are we there yet? Why not")
End
Here: MSGBOX("ok we have failed")

Simply surrounding previously working code with a trival for loop breaks the working code, unless you hunt through all your code fixing exits (in this example 1 extra for means changing 1 exit(2) to exit(3), I think, though I haven't debugged all the code to be certain).

Now, replace exit(2) or exit (3) with goto here:

Now, you don't have to edit all those exits every time you write a for loop.
Your code will reach here whether you have two for loops, or have written a third ok.

It could be I have misunderstood how EXIT works, but a GOTO looks like MUCH less effort.
Update: In PPL its BREAK or CONTINUE, apparrently, not EXIT - Thanks Cyberangel.

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
09-21-2018, 09:04 PM
Post: #25
RE: STRINGFROMID and gradians
CONTINUE & BREAK
Find all posts by this user
Quote this message in a reply
09-22-2018, 02:37 PM (This post was last modified: 09-22-2018 02:41 PM by Tyann.)
Post: #26
RE: STRINGFROMID and gradians
(09-21-2018 05:47 PM)StephenG1CMZ Wrote:  Maybe I'm wrong - I don't use EXIT often.

But
Code:

For i from 1 to 9
For j from 1 to 9
 EXIT(2)
End
End
Here:
Msgbox("ok")
I would expect to reach Here OK.

Now surround that working code with an additional for loop:

For newloop from 1 to 9
For i from 1 to 9
For j from 1 to 9
EXIT(2)
End
End
MSGBOX("are we there yet? Why not")
End
Here: MSGBOX("ok we have failed")

Simply surrounding previously working code with a trival for loop breaks the working code, unless you hunt through all your code fixing exits (in this example 1 extra for means changing 1 exit(2) to exit(3), I think, though I haven't debugged all the code to be certain).

Now, replace exit(2) or exit (3) with goto here:

Now, you don't have to edit all those exits every time you write a for loop.
Your code will reach here whether you have two for loops, or have written a third ok.

It could be I have misunderstood how EXIT works, but a GOTO looks like MUCH less effort.
Update: In PPL its BREAK or CONTINUE, apparrently, not EXIT - Thanks Cyberangel.

Bonjour
Dans ce cas il peut-être utile d'utiliser une variable, il suffira de modifier la valeur de cette variable plutôt que tous les BREAK.
De plus vous pourrez si vous avez plusieurs points de sortie les repérer grâce à un commentaire.


Hello
In this case it may be useful to use a variable, it will be enough to modify the value of this variable rather than all the BREAKs.
Moreover you will be able if you have several points of exit to locate them thanks to a comment.

exemple :

Code:

Local  A:=1,B:=2;
FOR i FROM 1 TO 10
 FOR j FROM 1 TO 20

    IF 'condition1' THEN BREAK(A) END;
    IF 'condition2' THEN BREAK(B) END; 
 END;//for j
 // sortie A

END;//for i
// sortie B

Sorry for my english
Find all posts by this user
Quote this message in a reply
09-26-2018, 03:17 PM
Post: #27
RE: STRINGFROMID and gradians
(09-19-2018 08:12 AM)Tim Wessman Wrote:  Note that these string names are NOT final and guaranteed to be supported long term. For example, in the "modes" group there are a bunch of spreadsheet items that need to be moved.

Once that happens, the string name will have changed. The upside will be that we'll be close to allowing users will then be able to make new language translations or modifications to existing ones. Smile

That sounds quite useful...
If you are taking suggestions for new languages to support, in England, Polish is a significant minority language - but that might change if/when the uk leaves the EU.

Er, can these planned language modifications be selected whilst in Exam mode? Smile

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
09-27-2018, 12:17 AM
Post: #28
RE: STRINGFROMID and gradians
Unfortunately not, however if a translation was advanced enough to be reviewed it could potentially pulled in as supported. Until then, not really due to the potentially for abuse. Sad

TW

Although I work for HP, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 18 Guest(s)