D's greatest mistakes
    bearophile 
    bearophileHUGS at lycos.com
       
    Tue Nov 30 04:46:54 PST 2010
    
    
  
spir:
> Andrej Mitrovic:
> 
> > constraint
> > {
> >     isDynamicArray(a);
> >     isIterable(a);
> > }
> > body
> > {
> >     ...
> > }
> I like very much the idea of constraint blocks. Much better than expanding func header line, reuses an existing syntactic construct, and far cleaner.
But I'd like that syntax to allow for an error message for each constraint. So it becomes like contract programming, done at compile-time on types and compile-time constants, and the "in" keyword is enough:
in {
  static assert(isDynamicArray!T, "err msg 1");
  static assert(isIterable!T, "err msg 2");
  ...
} body {
  ...
}
Bye,
bearophile
    
    
More information about the Digitalmars-d
mailing list