----boundary-LibPST-iamunique-1604321728_-_-
Content-type: text/plain
Bob, Chris,
>> No. The translator does not even attempt to translate GOTOs.
>> > It is a relatively simple and mechanical exercise to
>> > translate structured IF-THEN-ELSE. WHILE, REPEAT, FOR
>> > statements into a form which only uses GOTOs. The converse is not.
>>
>> yes, I found that out for sure. In translating a goto
>> program into a no-goto program there's no substitute for a brain.
>>
>> Regards,
>> Bob
A long time ago I tried to translate a GOTO filled FORTRAN programe to
CP (see FilterRemez on Cpc). At first I thought that all it would take
was patience.
That accounted for about 1/3 of the GOTOs.
So then I tried the 'brain' technique, and used ingenuity.
That accounted for about a further 1/3 of the GOTOs.
The last 1/3 were just intractible.
But I did finally come up with a general purpose technique that, I
guess, could be automated. It does nothing to make the code
comprehensible, it has no pretensions to efficiency, but it did
allow me to produce a useful outcome. (I don't use it often, but
by coincidence I used it yesterday, and once in February!)
The technique is to assign things, at run time, into a PROCEDURE
valued variable. For an example see the routine
FilterRemex.StaticSpagetti. Could be useful when you need to
implement a general state-machine.
The core idea is the loop:
VAR
GotoLine : PROCEDURE;
...
REPEAT GotoLine UNTIL GotoLine = NIL;
GotoLine takes many different values. In each PROCEDURE that
GotoLine becomes there are 1, or several, different assignments
like
GotoLine := Line505;
Line505, for example, is a true procedure name.
To complete the circle of this correspondence this algorithm (Remez)
is discussed in Numerical Recipes. The authors acknowledge that
the results are 'Optimum', but they do not like or include it
because it is too complicated to code. They advocate a different
simpler approach whose results are 'nearly as good' (which means
'not as good'!).
>> If a Pascal [or other] program was littered with GOTOs chances are there
>> would be other serious problems with its design. If it were me I'd
>> exhaust all other possibilities before considering translating such a
>> beast.
Yes, but sometimes one is still left facing the beast!
Robert
ps - I wonder if this technique would also work with COME FROMs?
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************
--- BlackBox
--- send subject HELP or UNSUBSCRIBE to blackbox{([at]})nowhere.xy
----boundary-LibPST-iamunique-1604321728_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIFxwYXINClxwYXINCkJvYiwgQ2hyaXMsXHBhcg0K
XHBhcg0KPj4gIE5vLiBUaGUgdHJhbnNsYXRvciBkb2VzIG5vdCBldmVuIGF0dGVtcHQgdG8gdHJh
bnNsYXRlIEdPVE9zLlxwYXINClxwYXINCj4+ICA+IEl0IGlzIGEgcmVsYXRpdmVseSBzaW1wbGUg
YW5kIG1lY2hhbmljYWwgZXhlcmNpc2UgdG9ccGFyDQpccGFyDQo+PiAgPiB0cmFuc2xhdGUgc3Ry
dWN0dXJlZCBJRi1USEVOLUVMU0UuIFdISUxFLCBSRVBFQVQsIEZPUlxwYXINClxwYXINCj4+ICA+
IHN0YXRlbWVudHMgaW50byBhIGZvcm0gd2hpY2ggb25seSB1c2VzIEdPVE9zLiBUaGUgY29udmVy
c2UgaXMgbm90LlxwYXINCj4+IFxwYXINClxwYXINCj4+ICB5ZXMsIEkgZm91bmQgdGhhdCBvdXQg
Zm9yIHN1cmUuIEluIHRyYW5zbGF0aW5nIGEgZ290b1xwYXINClxwYXINCj4+ICBwcm9ncmFtIGlu
dG8gYSBuby1nb3RvIHByb2dyYW0gdGhlcmUncyBubyBzdWJzdGl0dXRlIGZ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mUgY29uZmlkZW50aWFsIHRvIHRoZSBp
bnRlbmRlZFxwYXINCnJlY2lwaWVudCBhbmQgbWF5IGFsc28gYmUgcHJpdmlsZWdlZC4gSWYgeW91
IGFyZSBub3QgdGhlIGludGVuZGVkXHBhcg0KcmVjaXBpZW50IHBsZWFzZSBkZWxldGUgaXQgZnJv
bSB5b3VyIHN5c3RlbSBhbmQgbm90aWZ5IHRoZSBzZW5kZXIuXHBhcg0KWW91IHNob3VsZCBub3Qg
Y29weSBpdCBvciB1c2UgaXQgZm9yIGFueSBwdXJwb3NlIG5vciBkaXNjbG9zZSBvclxwYXINCmRp
c3RyaWJ1dGUgaXRzIGNvbnRlbnRzIHRvIGFueSBvdGhlciBwZXJzb24uXHBhcg0KKioqKioqKioq
KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq
KipccGFyDQpccGFyDQotLS0gQmxhY2tCb3hccGFyDQotLS0gc2VuZCBzdWJqZWN0IEhFTFAgb3Ig
VU5TVUJTQ1JJQkUgdG8gYmxhY2tib3hAb2Jlcm9uLmNofX0ACmlzIGRpc2N1cw=
----boundary-LibPST-iamunique-1604321728_-_---
Received on Thu Oct 27 2005 - 10:06:32 UTC