scotfl.ca

Functional vs Message-Passing Notation

$welcome = implode(‘ ‘, array_slice(explode(‘ ‘, $welcome), 0, 19));

vs.

$welcome = $welcome.explode(' ').slice(0, 19).implode(' ');

In my opinion the message-passing (or ‘chaining’ as the javascript crowd likes to call it) notation is much clearer. The lack of pervasive OO is yet another one of the niggling little details that makes me dislike PHP so much.

And yes, I know I should have a preg_replace() first to normalize the whitespace, but I think the example is already cumbersome enough to prove my point.

This entry was posted on 17 September 2007 at 09:06 and is filed under Uncategorized. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Comments are closed.