Stepping back and looking at constness from another angle.
Carlos Santander
csantander619 at gmail.com
Thu Jun 7 15:11:39 PDT 2007
Walter Bright escribió:
> 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.
I guess that's clear, but what does it mean when there're no parentheses?
--
Carlos Santander Bernal
More information about the Digitalmars-d
mailing list