Checking function parameters in Phobos

Meta jared771 at gmail.com
Mon Nov 25 21:37:05 PST 2013


On Monday, 25 November 2013 at 08:52:14 UTC, Simen Kjærås wrote:
> @safe is only for memory safety, which this is not. I agree it 
> would be
> nice to mark assumeValidated as 'warning, may not do what it 
> claims',
> but @safe is not really the correct indicator of that.

What about a version flag, then, that can be passed to specify 
that the user wants assumeValidated() to run the validation 
functions as well?

> This is a known shortcoming for which I see no good workaround. 
> It would
> be possible to use std.traits.hasAliasing to see which types 
> can be
> safely .dup'ed and only allow those types, but this is not a 
> solution I
> like.

It's a hard problem. This is a case where a Unique!T type would 
be really useful.

> What else is new?
> - Better error messages for invalid constraints (testing if an 
> int is
>    null, a string is divisible by 3 or an array has a database
>    connection, e.g.)
> - Fixed a bug in opCast (I love that word - in Norwegian it 
> [oppkast]
>    means puke. ...anyways...) when converting to an 
> incompatible wrapped
>    value.
>
> --
>    Simen

Keep up the good work!


More information about the Digitalmars-d mailing list