4tH won't have a GOTO

35 views
Skip to first unread message

The Beez

unread,
Mar 14, 2023, 2:12:02 PM3/14/23
to 4tH-compiler
Hi 4tH-ers!

You may have followed the "GOTO" discussion in c.l.f.  https://groups.google.com/g/comp.lang.forth/c/zx3RBNWK5XI/m/SUynwBF8AwAJ

It's interesting since so many implementation ideas are going around. And I have to admit - I've contemplated this many times.

And still, even if viable ideas come to pass, I won't add these to 4tH. The reason for that is not that I'm too lazy to implement them, but because they do not concur with the design objectives.

Ever wondered why you cannot access the data stack directly (which you can in Forth, given a little effort)? First, you can break 4tH. Second, it's a very dirty way of programming. You really shouldn't do that. Be happy I allow you to access the TIB ;-)

Yes, there are occasions where GOTO is the more elegant solution. But those occasions are rare. More often, it's a VERY BAD idea.

So. That's why there won't be a GOTO in 4tH. Personally - I've never missed it. Somewhere in TEONW.4PP I used a THROW to fall back to a higher level - but that's just about the only instance where I could have used a GOTO. And I'm doing 4tH for almost 30 years now. 

Most probably, whatever problem you have, there is a way to solve it without resorting to GOTO. It may not be as "elegant", but it will work. The same goes for BREAK and CONTINUE. It may seem neat at first glance, but do you really need it?

Prove it to me - and I may go for it ;-)

Hans Bezemer

p da

unread,
Jan 29, 2024, 5:05:30 PMJan 29
to 4tH-compiler
El martes, 14 de marzo de 2023 a las 19:12:02 UTC+1, The Beez escribió:

So. That's why there won't be a GOTO in 4tH. Personally - I've never missed it. Somewhere in TEONW.4PP I used a THROW to fall back to a higher level - but that's just about the only instance where I could have used a GOTO. And I'm doing 4tH for almost 30 years now. 

Most probably, whatever problem you have, there is a way to solve it without resorting to GOTO. It may not be as "elegant", but it will work. The same goes for BREAK and CONTINUE. It may seem neat at first glance, but do you really need it?


you already have GOTO, it only happens to have another name (UNTIL, LOOP, +LOOP...)   ;-)
 
Reply all
Reply to author
Forward
0 new messages