Next in Review Queue: The New std.path
KennyTM~
kennytm at gmail.com
Fri Jul 15 13:32:06 PDT 2011
On Jul 16, 11 04:16, Lars T. Kyllingstad wrote:
> On Sat, 16 Jul 2011 00:17:03 +0800, KennyTM~ wrote:
>
>> On Jul 16, 11 00:05, Jonathan M Davis wrote:
>>> On Friday 15 July 2011 23:48:39 KennyTM~ wrote:
>>>> On Jul 15, 11 23:26, Lars T. Kyllingstad wrote:
>>>>>>> So here you have had to use Unqual
>>>>>>> immutable(Unqual!C1)[] setExtension(C1, C2)(in C1[] path, in C2[]
>>>>>>> ext) immutable(Unqual!C1)[] defaultExtension(C1, C2)(in C1[]
>>>>>>> path, in C2[] ext)
>>>>>>>
>>>>>>> Instead of Unqual isn't it nicer to use a Deconst!() template?
>>>>>
>>>>> Hmm, I guess you're right. "shared" shouldn't be stripped, for
>>>>> instance.
>>>>
>>>> Given that immutable( const(char) ) == immutable(char), I think the
>>>> Unqual! should simply be removed.
>>>
>>> I'd still put the Unqual in there. Perhaps it's due to compiler bugs,
>>> but from what I've seen, it can get kind of funny when you try and have
>>> an immutable const or a const immutable. Using Unqual makes it very
>>> clear what you mean.
>>>
>>> - Jonathan M Davis
>>
>> OK. But I think you should file the compiler bug :) From what I see,
>> it's that 'immutable' always win.
>>
>> --------------------------
>> alias const(char) CC;
>> alias immutable(char) IC;
>> alias immutable(CC) ICC;
>> alias const(IC) CIC;
>> pragma(msg, ICC);
>> pragma(msg, CIC);
>> --------------------------
>> immutable(char)
>> immutable(char)
>> --------------------------
>
> True, but this doesn't apply to the present case. Since the parameters
> are marked with 'in', they become const(immutable(char)[]), not const
> (immutable(char))[]. This isn't too hard to fix, but I prefer to use
> Unqual, Deconst, Mutable, or whatever it ends up being called.
>
> -Lars
Even if `typeof(path)` becomes `const(string)`, C1 is still an
`immutable(char)`, so `immutable(C1)[]` will still work.
------------------------------------
immutable(C1)[] setExtension(C1, C2)(in C1[] path, in C2[] ext) {
pragma(msg, typeof(return), " <- ", C1);
return typeof(return).init;
}
void main() {
setExtension("1", "2");
setExtension("3".dup, "4".dup);
setExtension(cast(const)"5".dup, cast(const)"6".dup);
}
------------------------------------
string <- immutable(char)
string <- char
string <- const(char)
------------------------------------
More information about the Digitalmars-d
mailing list