scotfl.ca

September, 2007

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.

Posted on 17 September 2007 in Uncategorized

Comments Off