DIP 1003 Formal Review

Eugene Wissner via Digitalmars-d digitalmars-d at puremagic.com
Tue May 16 12:23:28 PDT 2017


On Tuesday, 16 May 2017 at 19:18:43 UTC, Ola Fosheim Grøstad 
wrote:
> On Tuesday, 16 May 2017 at 18:57:37 UTC, H. S. Teoh wrote:
>> this ugly verbosity, but imagine how much better it would be 
>> if we could write something like this instead:
>>
>> 	int foo(T, U)(T t, U u)
>> 	if (sigConstraints!T && sigConstraints!U)
>> 	in (t > 0 && u < 10)
>> 	out(foo > 1 && foo < 5 )
>> 	{
>> 		// function body here
>> 	}
>>
>> This is just tentative example syntax, of course.
>
> Why not just use the terminology the rest of the world has 
> landed on?
>
> int foo(T, U)(T t, U u)
> if (sigConstraints!T && sigConstraints!U)
> requires(t > 0 && u < 10)
> ensures(foo > 1 && foo < 5 )
> {
>    // function body here
> }
>
> Or is there some value in being cryptic?

What about error messages. With asserts I get the line where the 
assert failed. Can I get an information which condition failed 
(sorry for the question, I don't know how it works in other 
languages)?


More information about the Digitalmars-d mailing list