Re: GOTO operator

php.internals

Frank M. Kromann

22 years ago
We were all newbies at some point and most of us (not including myself) learned how to handle the language, and so will the newbies of today, even if GOTO is a part of the language. I don't see a need to make this an ini-option. It is allready an option - use t or leave it alone. - Frank
> Hello, > > I think we should add an INI option: > > php_newbie true|false > > ;) > > -- > Best regards, > Jason mailto:jason@ionzoft.com > > Thursday, July 29, 2004, 8:54:34 PM, you wrote: > > AH> Sara Golemon wrote: > >>>do { > >>> .....code... > >>> if (something) break; > >>> ...code.... > >>>} while (0); > >>>...cleanup code... > >>> > >> > >> Are you suggesting a hack is better than the real thing? > >> > >> -Sara > AH> The "hack" is working. The manual says : > AH> " Advanced C users may be familiar with a different usage of the
do..while loop,
> AH> to allow stopping execution in the middle of code blocks, by
encapsulating them
> AH> with do..while (0), and using the break statement. The following
code fragment
> AH> demonstrates this:" (a similar code follows) > AH> " Don't worry if you don't understand this right away or at all. You
can code scripts
> AH> and even powerful scripts without using this 'feature'. " > AH> (the manual states that people can code powerful things without goto
hack).
> AH> Sara, if you need to have the goto, you know how to implement it
with do..while.
> AH> The average Joe may not need goto in some case but he will find that
it simplifies
> AH> his job (but making code clumsy, something what he does not
realize).
> AH> It is not because I don't like the power of goto, I would like not
to be given in the

Jevon Wright

22 years ago
Why not make it hard for users to use GOTO in the first place? Develop some wacky construct that you have to use instead... that way, it will scare off novice users, and expert programmers will HAVE to know what they're doing and know that they really need it before they have to implement it. It's along the lines of "make the most dangerous stuff the hardest to do". I'm not sure how, though... a huge language construct (goto_this_line_please)? Use numbers instead of labels? Relative jumping? Require extra messages? A weird symbolic construct? *shrug* On another note, if a GOTO was added, the ability to go " goto foo$bar " (dynamic goto) could add another gold star onto PHP's coolness. Jevon ----- Original Message ----- From: "Frank M. Kromann" <frank@kromann.info> To: <internals@lists.php.net> Sent: Friday, July 30, 2004 11:15 AM Subject: Re: [PHP-DEV] GOTO operator

Paul G

22 years ago
----- Original Message ----- From: "Jevon Wright" <jevon@jevon.org> To: "Frank M. Kromann" <frank@kromann.info>; <internals@lists.php.net> Sent: Friday, July 30, 2004 6:53 AM Subject: Re: [PHP-DEV] GOTO operator
> Why not make it hard for users to use GOTO in the first place?
how about a --with-more-rope (to hang yourself with) autoconf option? paul

Aidan Lister

22 years ago
> Develop some wacky construct that you have to use instead... that way, it > will scare off novice users, and expert programmers will HAVE to know what > they're doing and know that they really need it before they have to > implement it. It's along the lines of "make the most dangerous stuff the > hardest to do".
I think this is probably one of the best ideas...
> I'm not sure how, though... a huge language construct > (goto_this_line_please)? Use numbers instead of labels? Relative jumping? > Require extra messages? A weird symbolic construct? *shrug*
I'd just disable it by default, force them to compile --with-goto That definitely stops the novices, and allows experts to use it if they reallllly need it. Of course then portability then becomes a problem...

Bernard Fouché

22 years ago
Hi there. I'm one of the many readers of the list but not contributing myself since I've no knowledge of the internals of PHP. However I'd like to make the following comments about 'goto', addressed to people opposing its introduction in PHP: - If you consider the 'good way of writing code', whatever the language used, you often prefer to exit a function at the end of it, rather than having 'return's everywhere. Goto allows that for error processing as it was demonstrated by various examples in this ML. Sure you can always do the same with switch/case or if/then/else. But at that point you'll trade something easy to understand for some sort of orthodox-programming-by-the-rule harder to understand by someone maintaining the code later. My point here is that the design of a program is good or bad, with or without goto's and the people here can't decide that. - I do not understand the religious mission about having novice users oriented to what you think are the best programming rules. I've seen horrible PHP code without goto's and I've seen very nice C code with some goto's in it. If a programmer is a newbie, there are chances that his/her code won't be excellent, with or without goto's. The novice will be an experienced programmer when he/she will understand by him/herself why use or not use such or such design for a particular problem, and goto's are just a detail among many others. Again, you'll will have very little impact on programs quality by introducing or rejecting goto. You'll just make the situation harder for someone that wants it to get a better design, the exact opposite of what you want! - We are 20 years later than the time when BASIC was nearly the only language of easy access to non-programmers. The Grand Old Goto Fear may be dropped, no? - IMHO goto's ease the production of computer generated code. - IMHO The CLI interface will be used more and more. For instance I've dropped SH for scripts here, I want all script code written in PHP. Why? Because it is now easy to find people that knows PHP well, because they wrote code for applications running under Apache and PHP, so there is less for them to discover when moving to Linux programming, they keep the same programming language. And PHP CLI needs all the stuff you find in C or SH, including goto. In my opinion, add goto to PHP and let people figure themselves if they need to use it or not. My two cents bikeshed. Bernard

Derick Rethans

22 years ago
On Fri, 30 Jul 2004, Aidan Lister wrote:
> > Develop some wacky construct that you have to use instead... that way, it > > will scare off novice users, and expert programmers will HAVE to know what > > they're doing and know that they really need it before they have to > > implement it. It's along the lines of "make the most dangerous stuff the > > hardest to do". > > I think this is probably one of the best ideas... > > > I'm not sure how, though... a huge language construct > > (goto_this_line_please)? Use numbers instead of labels? Relative jumping? > > Require extra messages? A weird symbolic construct? *shrug* > > I'd just disable it by default, force them to compile --with-goto > > That definitely stops the novices, and allows experts to use it if they > reallllly need it. > > Of course then portability then becomes a problem...
So this is yet-another-bogus-idea ;-) Derick