Re: [PHP] Re: goto label

2003-12-10 Thread Bogdan Stancescu
Robert Cummings wrote:
On Tue, 2003-12-09 at 08:14, Bogdan Stancescu wrote:

Sorry if my message sounded melodramatic or something, I remembered the 
frustration feeling so strongly from your message that I wanted to 
reinforce the other people's messages with a personal testimonial if 
you wish.
U, I rarely use the goto statement, and I do not advocate it for
regular everyday coding. I do know the difference between well
structured code and otherwise. What I did say, is that goto label has
it's uses, and sometimes it IS the best solution. Just because someone
tells you something is bad, doesn't mean to say it is always bad. It's
like someone saying salt is bad for you, and so you never take salt
again and die from salt deficiency. People really need to change their
mindset about being sheeple (yes sheep people) and blindly following
preached dogma.
My message was in reply to the one in which you said you were 
disappointed PHP doesn't feature goto. *That* is what I was replying to. 
And the understatement in my reply was that PHP does good by not 
allowing goto statements because that way it coerces even unexperienced 
programmers into sane code. And there are quite a few unexperienced 
programmers using PHP out there, trust you me. Your reply's quite 
transparent understatement is calling me and everybody who doesn't agree 
with you sheep people. That's a tad curious, if not offensive.

I don't mind your message sounding melodramatic, but it doesn't explain
in any way why goto shouldn't be used. It just asserts that you found
May I point you to the last few lines in my message you're replying to, 
quoted at the top of this message for your convenience. I will highlight 
the key words in there for you here, so it's easier to follow: I wanted 
to reinforce the other people's messages with a personal testimonial.

Cheers,
Bogdan
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: goto label

2003-12-10 Thread Robert Cummings
On Wed, 2003-12-10 at 07:10, Bogdan Stancescu wrote:
 
 May I point you to the last few lines in my message you're replying to, 
 quoted at the top of this message for your convenience. I will highlight 
 the key words in there for you here, so it's easier to follow: I wanted 
 to reinforce the other people's messages with a personal testimonial.

Yes, and you responded to my post, not one of the other people with whom
you agreed, and so the ball was in my court to respond to your so called
testimonial. Suffice to say, when an email for an Internet pyramid
scheme comes into my inbox full of testimonials I don't go jumping on
the bandwagon. At any rate, I didn't think your testimonial lent
credibility to the argument at hand, and so I pointed out why.

HAND,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: goto label

2003-12-09 Thread Bogdan Stancescu
Justin Patrin wrote:
Robert Cummings wrote:

Goto line number is a very broken way of coding. Goto label is a
very useful and structured way of coding especially when creating fast
FSMs for parsing. I was a little disappointed a few months ago when I
found that PHP didn't support  the goto label syntax since it would have
provided the most elegant solution.
goto anywhere is broken. For instance, goto-ing out of loops and 
functions, or into one function from another causes untold grief to the 
language developer and makes it very hard to read the code. Then there's 
using goto into and out of class functions, which is even worse.

In truth, goto has no place in a higher level programming language. 
Anything that can be done with goto can be done without it and (IMHO) 
more elegantly.
Robert, I know your grief, been there, I know how it feels. I started my 
childhood with BASIC, which was /the/ GOTO programming language, 
learned Turbo Pascal when I was a teenager, and continued to use GOTO's 
(Pascal discourages but doesn't disallow GOTO's, so I was still able to 
cheat when there was a need for it). Well, later on when I started 
finding out how major projects are being developed, what structured 
programming really means and so on, I felt the way you feel now: 
cheated. Why in God's name is GOTO bad? It's SO useful! They're mad! 
Well, it simply isn't true -- the problem is that you have to change 
your mindset about programming, try to really structure the way you see 
a program, break it into efficient stand-alone functions, group those in 
classes, etc, and you'll see that there *is* no need for GOTO, ever. You 
do need to break out of loops, you do need to short a loop when a 
condition is met, you do need to break out of switches, if branches and 
the lot - but those tools you have in PHP. GOTO is not needed and 
harmful. Even simply learning to program without GOTO will coerce you 
into saner code.

Sorry if my message sounded melodramatic or something, I remembered the 
frustration feeling so strongly from your message that I wanted to 
reinforce the other people's messages with a personal testimonial if 
you wish.

Bogdan

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: goto label

2003-12-09 Thread John Nichel
Justin Patrin wrote:

Nitin wrote:

Hi all,

I was wondering, if there's any way to achieve 'goto label:' using PHP

Thanx for ur time

Nitin


goto is a very old and broken way of coding. If you ever find yourself 
in need of a goto, you should re-evaluate how you're doing things. If 
you're having trouble finding out how to do it better, just ask here. :-)

Right, use GOSUB instead.  ;)

--
By-Tor.com
It's all about the Rush
http://www.by-tor.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: goto label

2003-12-09 Thread Robert Cummings
On Tue, 2003-12-09 at 08:14, Bogdan Stancescu wrote:
 
 Robert, I know your grief, been there, I know how it feels. I started my 
 childhood with BASIC, which was /the/ GOTO programming language, 
 learned Turbo Pascal when I was a teenager, and continued to use GOTO's 
 (Pascal discourages but doesn't disallow GOTO's, so I was still able to 
 cheat when there was a need for it). Well, later on when I started 
 finding out how major projects are being developed, what structured 
 programming really means and so on, I felt the way you feel now: 
 cheated. Why in God's name is GOTO bad? It's SO useful! They're mad! 
 Well, it simply isn't true -- the problem is that you have to change 
 your mindset about programming, try to really structure the way you see 
 a program, break it into efficient stand-alone functions, group those in 
 classes, etc, and you'll see that there *is* no need for GOTO, ever. You 
 do need to break out of loops, you do need to short a loop when a 
 condition is met, you do need to break out of switches, if branches and 
 the lot - but those tools you have in PHP. GOTO is not needed and 
 harmful. Even simply learning to program without GOTO will coerce you 
 into saner code.
 
 Sorry if my message sounded melodramatic or something, I remembered the 
 frustration feeling so strongly from your message that I wanted to 
 reinforce the other people's messages with a personal testimonial if 
 you wish.

U, I rarely use the goto statement, and I do not advocate it for
regular everyday coding. I do know the difference between well
structured code and otherwise. What I did say, is that goto label has
it's uses, and sometimes it IS the best solution. Just because someone
tells you something is bad, doesn't mean to say it is always bad. It's
like someone saying salt is bad for you, and so you never take salt
again and die from salt deficiency. People really need to change their
mindset about being sheeple (yes sheep people) and blindly following
preached dogma.

I don't mind your message sounding melodramatic, but it doesn't explain
in any way why goto shouldn't be used. It just asserts that you found
out how major projects are done, which IMHO doesn't lend support to why
one shouldn't use the goto statement. In actual fact it makes me think
you are missing a few points. For instance properly structured
programming is often about the functions, objects, and methods, not
about the code within a function that performs the logic. For this
reason the use of goto statements within a given function that
facilitates faster cleaner code is sometimes the best solution not to
mention its contents can be considered a black box by the user of the
function. Also your response seems to indicate that you think I am a
newbie coder, well that would be a bit of an oversight. I've been coding
for over 10 years (some hobby, some academic, and some professional)
using many different styles (functional, procedural, and OOP) and so I
am plenty aware of design paradigms, re-usability, and clarity. I also
have extensive experience refactoring old spaghetti code.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: goto label

2003-12-09 Thread Justin Patrin
Robert Cummings wrote:

On Tue, 2003-12-09 at 08:14, Bogdan Stancescu wrote:

Robert, I know your grief, been there, I know how it feels. I started my 
childhood with BASIC, which was /the/ GOTO programming language, 
learned Turbo Pascal when I was a teenager, and continued to use GOTO's 
(Pascal discourages but doesn't disallow GOTO's, so I was still able to 
cheat when there was a need for it). Well, later on when I started 
finding out how major projects are being developed, what structured 
programming really means and so on, I felt the way you feel now: 
cheated. Why in God's name is GOTO bad? It's SO useful! They're mad! 
Well, it simply isn't true -- the problem is that you have to change 
your mindset about programming, try to really structure the way you see 
a program, break it into efficient stand-alone functions, group those in 
classes, etc, and you'll see that there *is* no need for GOTO, ever. You 
do need to break out of loops, you do need to short a loop when a 
condition is met, you do need to break out of switches, if branches and 
the lot - but those tools you have in PHP. GOTO is not needed and 
harmful. Even simply learning to program without GOTO will coerce you 
into saner code.

Sorry if my message sounded melodramatic or something, I remembered the 
frustration feeling so strongly from your message that I wanted to 
reinforce the other people's messages with a personal testimonial if 
you wish.


U, I rarely use the goto statement, and I do not advocate it for
regular everyday coding. I do know the difference between well
structured code and otherwise. What I did say, is that goto label has
it's uses, and sometimes it IS the best solution. Just because someone
tells you something is bad, doesn't mean to say it is always bad. It's
like someone saying salt is bad for you, and so you never take salt
again and die from salt deficiency. People really need to change their
mindset about being sheeple (yes sheep people) and blindly following
preached dogma.
I don't mind your message sounding melodramatic, but it doesn't explain
in any way why goto shouldn't be used. It just asserts that you found
out how major projects are done, which IMHO doesn't lend support to why
one shouldn't use the goto statement. In actual fact it makes me think
you are missing a few points. For instance properly structured
programming is often about the functions, objects, and methods, not
about the code within a function that performs the logic. For this
reason the use of goto statements within a given function that
facilitates faster cleaner code is sometimes the best solution not to
mention its contents can be considered a black box by the user of the
function. Also your response seems to indicate that you think I am a
newbie coder, well that would be a bit of an oversight. I've been coding
for over 10 years (some hobby, some academic, and some professional)
using many different styles (functional, procedural, and OOP) and so I
am plenty aware of design paradigms, re-usability, and clarity. I also
have extensive experience refactoring old spaghetti code.
Cheers,
Rob.
While goto may be useful and even elegant for experienced programmers 
(although I see no reason to use it myself with well structured 
programs...there's always break), its inclusion in a language causes 
some programmers (newbies and those who don't yet understand clarity, 
etc.) to make habits which are harmful. It allows them shortcuts which 
get things done, but often lead to bugs and hard to read code.

opinion
Personally, I don't think goto should ever be used. Well structured 
programs can always be written to not need a goto and always just as 
elegantly. It may take restructuring of code, but it can always be done, 
and in the end the result is clearer.

You say that a funciton is a black box and while this is true for the 
user of a function, the maintainer of the code still has to deal with 
the contents of the function. If you wrote and understand it, then fine. 
The problem comes when others have to understand your code. Yes, a 
single goto isn't all that bad, especially when it is used right, but is 
it easier to screw up a code with a goto than a more structured 
statement, such as break.
/opinion

--
paperCrane Justin Patrin
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: goto label

2003-12-09 Thread Robert Cummings
On Tue, 2003-12-09 at 17:45, Justin Patrin wrote:

 While goto may be useful and even elegant for experienced programmers 
 (although I see no reason to use it myself with well structured 
 programs...there's always break), its inclusion in a language causes 
 some programmers (newbies and those who don't yet understand clarity, 
 etc.) to make habits which are harmful. It allows them shortcuts which 
 get things done, but often lead to bugs and hard to read code.

This is a good point that I do agree with. But experience comes with
knowledge about the tools, and goto is just another tool.

 opinion
 Personally, I don't think goto should ever be used. Well structured 
 programs can always be written to not need a goto and always just as 
 elegantly. It may take restructuring of code, but it can always be done, 
 and in the end the result is clearer.

The result is not always cleaner. Consider code with fairly complex
considtional branching (parsers are often in this category). Contrast 20
break statements and conditional re-entry variable to properly flow
through the code to the end of the  function where cleanup is performed
versus the same conditional branching complexity, with a single goto
cleanup;. True one could put the cleanup in a function of it's own, but
then the usage of the function is just as unwieldy since it must be
populated with the data structures to cleanup. Alternatively an object
could be used, but now the code is spread out when it would have been
more clear in a single function with a label.

 
 You say that a funciton is a black box and while this is true for the 
 user of a function, the maintainer of the code still has to deal with 
 the contents of the function. If you wrote and understand it, then fine. 
 The problem comes when others have to understand your code. Yes, a 
 single goto isn't all that bad, especially when it is used right, but is 
 it easier to screw up a code with a goto than a more structured 
 statement, such as break.
 /opinion

I agree that when one writes code, they should always give consideration
to the person who must follow in their footsteps, but I still assert
that sometimes the code is easier to follow for the person who reads it
later when a goto is used than when multiple state variables are used to
manage flow control.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: goto label

2003-12-08 Thread Robert Cummings
On Tue, 2003-12-09 at 00:32, Justin Patrin wrote:
 Nitin wrote:
 
  Hi all,
  
  I was wondering, if there's any way to achieve 'goto label:' using PHP
  
  Thanx for ur time
  
  Nitin
 
 goto is a very old and broken way of coding. If you ever find yourself 
 in need of a goto, you should re-evaluate how you're doing things. If 
 you're having trouble finding out how to do it better, just ask here. :-)

Goto line number is a very broken way of coding. Goto label is a
very useful and structured way of coding especially when creating fast
FSMs for parsing. I was a little disappointed a few months ago when I
found that PHP didn't support  the goto label syntax since it would have
provided the most elegant solution.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: goto label

2003-12-08 Thread Justin Patrin
Robert Cummings wrote:

On Tue, 2003-12-09 at 00:32, Justin Patrin wrote:

Nitin wrote:


Hi all,

I was wondering, if there's any way to achieve 'goto label:' using PHP

Thanx for ur time

Nitin
goto is a very old and broken way of coding. If you ever find yourself 
in need of a goto, you should re-evaluate how you're doing things. If 
you're having trouble finding out how to do it better, just ask here. :-)


Goto line number is a very broken way of coding. Goto label is a
very useful and structured way of coding especially when creating fast
FSMs for parsing. I was a little disappointed a few months ago when I
found that PHP didn't support  the goto label syntax since it would have
provided the most elegant solution.
Cheers,
Rob.
goto anywhere is broken. For instance, goto-ing out of loops and 
functions, or into one function from another causes untold grief to the 
language developer and makes it very hard to read the code. Then there's 
using goto into and out of class functions, which is even worse.

In truth, goto has no place in a higher level programming language. 
Anything that can be done with goto can be done without it and (IMHO) 
more elegantly.

--
paperCrane Justin Patrin
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: goto label

2003-12-08 Thread Robert Cummings
On Tue, 2003-12-09 at 00:51, Justin Patrin wrote:
 Robert Cummings wrote:
  
  Goto line number is a very broken way of coding. Goto label is a
  very useful and structured way of coding especially when creating fast
  FSMs for parsing. I was a little disappointed a few months ago when I
  found that PHP didn't support  the goto label syntax since it would have
  provided the most elegant solution.
  
  Cheers,
  Rob.
 
 goto anywhere is broken. For instance, goto-ing out of loops and 
 functions, or into one function from another causes untold grief to the 
 language developer and makes it very hard to read the code. Then there's 
 using goto into and out of class functions, which is even worse.

As I said that all depends on how it is used. Anyone can write
unreadable code regardless of whether the language supports the goto
statement. Also since PHP is strongly based on C, you'll notice that the
C language does not allow cross function jumping via goto. Goto must
jump to a label defined in the same function, so your second argument in
this case is invalid. As someone who has implemented my own language, I
can tell you I had absolutely no grief implementing a goto label
system.

 In truth, goto has no place in a higher level programming language. 

This is your opinion, please feel free to qualify it.

 Anything that can be done with goto can be done without it and (IMHO) 
 more elegantly.

Yes anything that can be done with goto can be done without, but the
whether it is more elegant strongly depends on what your goal is and how
that goal can be achieved. Here's something you should do to properly
open your eyes to the utility of the goto label statement.

cd /YOUR_PHP_INSTALLATION_SOURCE/
grep -rE 'goto [_[:alnum:]]+;' *

In my installation alone there are 1522 instances of goto used. And
really I don't consider PHP that much higher level a language than C,
although it does provide plenty of high level functions.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php