Hi!

so do we even want the toString() method?

IMHO we should drop toString from Closure.

There is one case which *may* cause problems:

function doSomething ($callback) {
  if (!is_callable ($callback)) {
    throw new Exception (...);
  }

  // special treatment
  if ($callback == 'default') {
    ...
  } else {
    ...
  }
}

Here, the comparison of $callback with 'default' will yield a notice
that $callback couldn't be converted. The comparison will fail
correctly, of course, but it could cause some confusion. The correct
way of comparing would obviously be using ===, that won't cause these
hickups.

Personally, I don't care whether a object-to-string cast is present or
not.

I don't think Closure can be meaningfully exported. Can we prohibit it?

Unfortunately, currently not, see the var_export code.

I think we can make working clone there - just copy all data, etc.

Perhaps. But I'd recommend this should be postponed, as there are quite
a few subtleties regarding semantics of bound variables involved. Should
there seem to be a strong need for cloning closures by the community,
this can always be implemented in a future PHP version. IMHO.

Regards,
Christian

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to