One of the more controversial additions to PHP6 is the GOTO. Some have argued it flys in the face of many years good programming sense but there are valid use cases, when running performance critical operations such as parsing, where the overhead of making PHP user function calls becomes significant.
Anyway GOTO seems to have opened the gates to some more radical language modifications and recent discussion a revolved around adding a COMEFROM statement to PHP, which led to an initial patch being applied to the PHP6 CVS branch here.
Precedent for COMEFROM can be found in INTERCAL, a language which, for various reasons, never hit mainstream but aimed at being a better LISP, as this code listing illustrates.
Like GOTO, COMEFROM could lead to spagetti if used unwisely, so the initial implementation places a sensible restriction on it’s use: you can only COMEFROM a PHP script which is not the script where COMEFROM was used. An example if I have some include file like;
<?php
// login.php - the script we want to COMEFROM
function login($username, $password) {
$auth = new Auth();
return $auth->isValidUser($username, $password);
}
I can step into this with COMEFROM like;
<?php
// index.php
require_once 'login.php';
class MyAuth implements LoginHandler {
// Some other implementation providing the same interface
function login($username, $password) {
// authenticate against, say, an LDAP server
}
}
// Execute a COMEFROM, replacing use of Auth class with MyAuth
COMEFROM 'login.php:3' [
$auth = new MyAuth();
return $auth->isValidUser($username, $password);
]
if ( login($_POST['username'], $_POST['password'] )) {
echo "You are logged in<br />";
}
As the above code illustrates, this gives you the possibility to override the behaviour of code without having to physically alter it or worry about stuff like dynamic includes. What this trivial example doesn’t illustrate is some of the more advanced things COMEFROM enables, such as functional programming, macros and Ruby-like “blocks”, all of which make PHP significantly more dynamic. That said, at the moment, what I see as missing is a way to return back into the code you have COMEFROM, which would allow for stuff like an extremely fast AOP implementation - perhaps GOTO could be extended to support this?
Anyway - could this be the feature that drives demand for hosts to migrate to PHP?





March 31st, 2006 at 8:13 pm
I think you meant “open the gates of HELL”… and a flood of oni aliens will come down upon us.
sigh…
March 31st, 2006 at 8:13 pm
1st of April :D
March 31st, 2006 at 8:24 pm
Oh, it’s still 31 here, LOL
March 31st, 2006 at 9:22 pm
Nice one Harry :D
March 31st, 2006 at 10:12 pm
Wow, I’m impressed at the level of detail you went to for this joke. I was smirking at the very mention of comefrom but laughed outloud at: “INTERCAL, a language which, for various reasons never hit mainstream”.
Good one!!
April 1st, 2006 at 3:38 am
Finally! ;)
April 1st, 2006 at 4:40 am
Note to self: remember what time zone I’m in next time
April 1st, 2006 at 4:47 am
sorry harry, i’m not convinced…
goto? comefrom? wtf?? what are they doing to our language huh :(
April 1st, 2006 at 4:49 am
damn it… you got me :lol:
April 1st, 2006 at 5:18 am
By the way, i love this INTERCAL code. ;)
April 1st, 2006 at 12:23 pm
Damn, you got me! :) Definitely one of the better April jokes I’ve seen.
April 1st, 2006 at 3:00 pm
dammit, I have to start realizing today is april fools day I totally thought you were serious and I was remember my AS/400 RPG days of the goto and it was a nightmare, whew
ya got me :)
April 1st, 2006 at 3:20 pm
Never mind COMEFROM. Having looked at the INTERCAL code, I think it’s time we put the “Please” statement in PHP. Especially for debugging, as in “Please let this work!” :-) ROTFL, Harry, great post.
April 1st, 2006 at 3:57 pm
Except the GOTO part isn’t a joke - haven’t seen exactly how it’s going to work but it looks like it will be a way to jump between labels inside a switch statement .
April 1st, 2006 at 4:26 pm
that will be the next php egg,
[code]
[/code]
[code]
output: harry says hi
[/code]
April 1st, 2006 at 4:27 pm
sorry i’m used to the forum tags
April 1st, 2006 at 10:49 pm
Great news, when is the Gosub tag coming out, php 6.1?
April 2nd, 2006 at 7:27 am
[…] Dopo il GOTO php6 avrà anche un COMEFROM […]
April 2nd, 2006 at 6:41 pm
Ah you’re evil Harry - you got me here :(
April 2nd, 2006 at 10:05 pm
Ok this is confusing? are they really adding GOTO and COMEFROM ? or was this an april fools joke?
April 2nd, 2006 at 10:26 pm
@_theworks:
It is was a well-constructured April fools joke. :)
April 3rd, 2006 at 4:26 am
hehe, nice one
April 3rd, 2006 at 10:13 am
nice one… ;) you got me there!
April 3rd, 2006 at 10:30 am
when i first saw the post, i was seriouly missing the ‘caller’ property in the javascript Function object and thinking if COMEFROM was of the same nature. harry, nice one! :)
April 4th, 2006 at 4:15 am
GOTO sucks
April 4th, 2006 at 6:02 pm
Thank god
April 5th, 2006 at 2:37 am
[…] of Intercal causes temporary damage against which there is no saving throw. Thanks, man. » Permalink58 words in thispost […]
April 7th, 2006 at 12:04 pm
I remember in my first computer science class, unbeknownst to all, I wrote an entire program using goto’s and not a single function. Looking back, I was the first one to finish the perfectly working program, but then again was the first to receive an F. I thought I was sooo cool with my newfound statement, the GOTO.
May 11th, 2006 at 5:00 pm
[…] Firstly, the inclusion of a goto construct. What the fuck? When Harry Fuecks wrote about the inclusion of a COMEFROM statement on April 1 it was greeted with universal praise for being a truly excellent gag. Did somebody forget to tell Paul Hudson at LXF it was a joke? Or was it based on the actual inclusion of this archaic construct? […]
July 29th, 2008 at 7:31 pm
may be