Stepping back and looking at constness from another angle.
Walter Bright
newshound1 at digitalmars.com
Thu Jun 7 13:18:00 PDT 2007
Leandro Lucarella wrote:
> Carlos Santander, el 5 de junio a las 21:15 me escribiste:
>> invariant(char)[new] ret = "prefix";
>
> Syntax is getting so obscure... I'm scared.
>
Think of invariant(type) this way: imagine a template that creates a
pointer to its type argument:
template Pointer(T)
{
alias T* Pointer;
}
and used like:
int x;
Pointer!(int) p = &x;
This is the notion of the "type constructor". So, let's think about
doing it for const/invariant:
template Const(T)
and:
Const!(int)
from there it's a short step to just:
const(int)
i.e. it "const-ifies" its argument.
More information about the Digitalmars-d
mailing list