Checking function parameters in Phobos

Jonathan M Davis jmdavisProg at gmx.com
Wed Nov 20 23:46:40 PST 2013


On Thursday, November 21, 2013 08:36:37 Jacob Carlborg wrote:
> On 2013-11-20 19:53, Meta wrote:
> > Yes. It is very important not to allow direct access to the underlying
> > value. This is important for ensuring that it is not put in an invalid
> > state. This is a mistake that was made with std.typecons.Nullable,
> > making it useless for anything other than giving a non-nullable type a
> > null state (which, in fairness, is probably all that it was originally
> > intended for).
> 
> In that case all string functionality needs to be provided inside the
> Validated struct. In addition to that we loose the beauty of UFCS, at
> least for functions expecting plain "string".

You could use alias this and alias the Validated struct to the underlying 
string, but if you did that, you'd probably end up having it escape the struct 
and used as a naked string the vast majority of the time, which would 
essentially defeat the purpose of the Validated struct.

- Jonathan M Davis


More information about the Digitalmars-d mailing list