Hi! > 1) contracts in doc-commetns https://wiki.php.net/rfc/dbc > > /** > * @requires ($a >= 0) > */ > function foo($a) { > }
We've spent several years rejecting annotations because no information can be in comments, not even a little bit, not even a tiny. Now we'd have full-blown running code in comments? How would this code be debugged/profiled/interpreted by tools? Writing PHP parser is not easy right now, but this would turn it into nightmare (what if you have a comment inside @requires? etc.) > 2) contracts as part of the language https://wiki.php.net/rfc/dbc2 > > function foo($a) > require($a >= 0) > { > } This is a step better but still we have the similar issues with readability, to which reuse of 'require' is added. > 3) contracts in annotations > > <<requires($a >= 0)>> > function foo($a) { > } That one actually looks better to me, but: I'm not sure how annotation syntax is supposed to support expressions or closures, yet more - how it is supposed to share the scope with the function. I.e., if you define annotation class/method/function/data structure/whatever it is, what it is supposed to receive? Is it some special form of annotation for this purpose only (meh)? Oh, and <<>> syntax is *ugly* ;) -- Stas Malyshev smalys...@gmail.com -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php