D's greatest mistakes
spir
denis.spir at gmail.com
Tue Nov 30 04:20:58 PST 2010
On Mon, 29 Nov 2010 12:31:42 +0000
Andrej Mitrovic <andrej.mitrovich at gmail.com> wrote:
> constraint
> {
> isDynamicArray(a);
> isIterable(a);
> }
> body
> {
> ...
> }
>
> So maybe every statement would be checked for the return value, and
> you would get the exact line where a constraint failed when
> instantiating a template.
>
> Just a passing thought anyway..
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 what is wrong with using interfaces (or abstract classes) instead of having to write custom type-checking funcs? If only as style guidelines:
constraint
{
a isa DynamicArray;
a isa Iterable;
}
The language could provide abstract classes for commonly checked capabilities of builtin types.
Denis
-- -- -- -- -- -- --
vit esse estrany ☣
spir.wikidot.com
More information about the Digitalmars-d
mailing list