Jump to content

PHP 6 has...


Aureole

Recommended Posts

PHP 6 has... goto. ;D

 

Now I don't claim to know much about programming in general but I do get around. Message/bulletin boards, news groups etc. etc. and from the thousands of posts/topics/articles I have read over the last 3 Years... people really seem to hate goto.

 

I'm not saying if it's good or bad, I've never used it as I only know some PHP just wondering what other people think...

 

I saw a discussion on them adding it on another PHP forum and people were going crazy, it was one heated debate. :D

Link to comment
Share on other sites

Hmmm...I don't think I like the break label thing either; I hope they don't implement it.

 

I will concede that there may be rare occasions where it might be useful, although I myself have never thought, "Hey I could really use a break label right now."

 

The problem is that you can't prevent programmers from using it where it's not appropriate, which will lead to abusing the use of the construct and sloppy code will follow anyways.

Link to comment
Share on other sites

There is no reason to use goto.  Ever.

It would be cool to be able to use goto in PHP. Just for the fun of it. :P

Speaking of PHP functions that have to do with line numbers.. I wander if there is one that outputs the current line number? Could be useful for debugging.

Link to comment
Share on other sites

The last question is easy. Yes there is -

 

Magic constants

PHP provides a large number of predefined constants to any script which it runs. Many of these constants, however, are created by various extensions, and will only be present when those extensions are available, either via dynamic loading or because they have been compiled in.

 

There are five magical constants that change depending on where they are used. For example, the value of __LINE__ depends on the line that it's used on in your script. These special constants are case-insensitive and are as follows:

 

 

Table 13.1. A few "magical" PHP constants

 

Name Description

__LINE__ The current line number of the file.

 

... 

 

 

Link to comment
Share on other sites

It would be cool to be able to use goto in PHP. Just for the fun of it. :P

 

I don't know.  The way you go on about optimizing and not using white space because it's a waste of bytes, I would have thought you'd have been against a text string (the label) that doesn't perform any calculations.

 

:D

Link to comment
Share on other sites

It would be cool to be able to use goto in PHP. Just for the fun of it. :P

 

I don't know.  The way you go on about optimizing and not using white space because it's a waste of bytes, I would have thought you'd have been against a text string (the label) that doesn't perform any calculations.

 

:D

I just meant for fun lol not for a live website.
Link to comment
Share on other sites

Well from what I hear, goto would make it much easier to perform error checking and to write parsers. On my travels around the 'net that's the only good thing I've heard about it.

 

A parser is just a FSM that returns tokens based on syntax rules.  They're already very easy to write.

 

I really can't see how error checking would be made any easier:

  if($bad_thing_happened){
    goto err_label;
  }

  // hundreds of lines of code

err_label:
  echo "An error occured!";

vs.

  if($bad_thing_happened){
    // throwing an exception
    // calling a error handler function
    // etc.
  }

Link to comment
Share on other sites

PHP 6 has... goto. ;D
Nobody contradicted that statement, and everybody seems to have been replying as if it is true, so I did the same.

 

I was under the impression that nearly everyone had contradicted that statement, since the possible implimentation will be different to the goto of other languages and wouldn't be called goto.

Link to comment
Share on other sites

PHP 6 has... goto. ;D
Nobody contradicted that statement, and everybody seems to have been replying as if it is true, so I did the same.

 

I was under the impression that nearly everyone had contradicted that statement, since the possible implimentation will be different to the goto of other languages and wouldn't be called goto.

Really? Then please quote the posts that do so. I haven't seen anybody contradict his statement of there being a goto function in PHP 6. All I've seen here is people saying that they don't like goto.
Link to comment
Share on other sites

Indeed it does not. However, i feel that something from the official php website DOES constitute proof that goto is not currently planned for implementation.

 

Furthermore, i've not actually seen anyone explicitly agree that php has goto. You say people have been postin 'as if it is true'. However, it appears to me that only you have been posting 'as if it is true'

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.