@strict

BCS none at anon.com
Sun Feb 14 15:15:54 PST 2010


Hello bearophile,

> @strict denotes a normal function/method, where all the names
> (variable) it uses inside are written down in an explicit way. Some of
> such names are normal function arguments, the other names can be
> global variables, variables from an outer function, instance
> attributes, static class attributes, enums.
> 
> // inside here types are optional
> @strict(in int y, in z, out k, inout w) int foo(int x) {
> // ... code
> }

I Like the idea but I think that is a bit /to/ explicit. It makes me think 
of the declared exceptions thing in Java. I don't remember exactly what the 
problem is there (I've done next to no Java) but being overly explicit seems 
to me to be an invitation for problems.

Might the following get most of the advantages?

@strict acts like pure but allows the function to modify it's arguments.

that plus some relaxed rules about what can be used for default parameters 
would get >90% of what I see you asking for:

int a;
void Outer()
{
    int b;
    @strict int Inner(int i, ref j = b, out k = a)
    {
         k = j;
         return i + j;
    }
    int m = Inner();
}


--
<IXOYE><





More information about the Digitalmars-d mailing list