HP Prime speed vs TI-Nspire CX
|
11-09-2016, 08:44 AM
Post: #21
|
|||
|
|||
RE: HP Prime speed vs TI-Nspire CX
I use a construct like the following for most programs that do real work.
J=1 While (J Ne 0) DO Case j=1 Then.... j = x End j=2 Then.... j = y End j=3 Then.... j=z End End Sort of a pseudo-hp50g code. It allows an arbitrary state machine to be written in Structured Programming. (I don't remember the Prime commands as I no longer use the Prime; trying to update it's memory fried a rather expensive desktop and the Prime was banished.) Without GOTOs, error handling is hard. Most modern languages do have enough constructs to make GOTOs irrelevant. They are not needed for looping or branching. They are really only useful when one needs to jump across contexts without unwinding the whole context (mostly in error handling.) |
|||
11-09-2016, 12:01 PM
Post: #22
|
|||
|
|||
RE: HP Prime speed vs TI-Nspire CX
(11-09-2016 06:48 AM)cyrille de brébisson Wrote: Hello, Hello, I have doubts if I understood correctly, but in Fortran 90 onwards one can do the following: Code: 0| outa: DO Marcelo |
|||
11-09-2016, 01:00 PM
(This post was last modified: 11-09-2016 01:13 PM by toml_12953.)
Post: #23
|
|||
|
|||
RE: HP Prime speed vs TI-Nspire CX
(11-09-2016 08:44 AM)ttw Wrote: Without GOTOs, error handling is hard. In ANSI (ISO) BASIC, error handling is done this way: WHEN EXCEPTION IN <code block> USE <error handling code> END WHEN Contrived simple example: square root error Code: DO No need for GOTO even in error handling. Tom L Tom L Cui bono? |
|||
11-09-2016, 01:35 PM
(This post was last modified: 11-09-2016 01:36 PM by Adriweb.)
Post: #24
|
|||
|
|||
RE: HP Prime speed vs TI-Nspire CX
(11-09-2016 06:48 AM)cyrille de brébisson Wrote: BUT, 90% of my goto use is to exit multiple loops at once, which you can not do in C (or other programming languages)... HOWEVER, you CAN do it in PPL using the BREAK(n) and CONTINUE(n) function!!!! As far as I know, PPL is the ONLY language that has such constructs!!! PHP has this too, and I'm sure others I'm not so familiar with or don't know at all. TI-Planet.org co-administrator |
|||
11-09-2016, 08:00 PM
Post: #25
|
|||
|
|||
RE: HP Prime speed vs TI-Nspire CX
For resurrecting old BASIC listings (if only to see what they do before a rewrite) most labels could be restricted to the same procedure... Most old listings with lots of GOTO's made little use of procedures.
When I have used GOTO for error handling, I have never needed the context to be preserved: If engine==off and restart()==off goto Failure; ... Failure: Reboot();//or Halt(); Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
11-10-2016, 07:05 PM
Post: #26
|
|||
|
|||
RE: HP Prime speed vs TI-Nspire CX
(11-09-2016 01:35 PM)Adriweb Wrote:(11-09-2016 06:48 AM)cyrille de brébisson Wrote: HOWEVER, you CAN do it in PPL using the BREAK(n) and CONTINUE(n) function!!!! As far as I know, PPL is the ONLY language that has such constructs!!! As does bash. Whenever I use goto to exit a heavily nested C loop, I always add a comment like // break(4) |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 10 Guest(s)