Hi Stas,

On Mon, Feb 9, 2015 at 8:11 AM, Stanislav Malyshev <smalys...@gmail.com>
wrote:

> > Following our conversation, I tried to imagine how DbC should look like
> in
> > PHP from user perspective. Finally, I was influenced by the semantic
> > proposed in D, and syntax proposed for Java. So, these are my initial
> > thoughts:
> >
> > For php it may look like the following:
> >
> > function foo()
> >     requre(<input-assert-expression>)
> >     ensure(<output-assert-expression>)
> > {
> >   ...
> > }
>
> Why not do it simpler?
>
> function foo() {
> // require
> assert(<input-assert-expression>);
> ...
> // ensure
> assert(<output-assert-expression>);
> }
>
> I'm oversimplifying a bit, but in general, why we need more places to
> have code in the function than the actual code of the function? It would
> be harder to parse, to read, to maintain, to debug, to profile, etc. and
> I'm not sure what exactly it provides that can't be done by plain
> regular code inside the function.
>
> If we're concerned about the costs of assert, we could make special
> provision in the compiler for zero-cost asserts. It doesn't require
> moving code out of the function.


Interesting idea. I like it.
The only draw back I can see now is that this may make post/pre condition
retrieving
harder for automatic documentation.  We may think of solution for this.

Regards,

--
Yasuo Ohgaki
yohg...@ohgaki.net

Reply via email to