August 05, 2006
On Sat, 5 Aug 2006 17:23:08 -0400, Jarrett Billingsley wrote:

> import utf = std.utf;
> 
> wchar[] utf16(char[] s)
> {
>     return utf.toUTF16(s);
> }
> 
> ...
> 
> char[] s = "hello";
> wchar[] t = s.utf16;
> 
>  ;)
> 
> Aren't first-array-param-as-a-property functions cool?

I don't want to rain on anyone's parade, but the new import formats kill off this undocumented feature.

This works ...

 import std.utf;
 void main()
 {
    wchar[] w;
    dchar[] d;
    d = w.toUTF32();
 }
This doesn't ....

 static import std.utf;
 void main()
 {
    wchar[] w;
    dchar[] d;
    d = w.std.utf.toUTF32();
 }
And neither does this ...

 import utf = std.utf;
 void main()
 {
    wchar[] w;
    dchar[] d;
    d = w.utf.toUTF32();
 }

-- 
Derek Parnell
Melbourne, Australia
"Down with mediocrity!"
August 05, 2006
On Sat, 5 Aug 2006 17:23:08 -0400, Jarrett Billingsley wrote:

> import utf = std.utf;
> 
> wchar[] utf16(char[] s)
> {
>     return utf.toUTF16(s);
> }
> 
> ...
> 
> char[] s = "hello";
> wchar[] t = s.utf16;
> 
>  ;)
> 
> Aren't first-array-param-as-a-property functions cool?

Actually, that doesn't compile any more either.

Instead of

   wchar[] t = s.utf16;

you have to code ...

   wchar[] t = s.utf16();

I'm sure it used to work the way you wrote it.

-- 
Derek Parnell
Melbourne, Australia
"Down with mediocrity!"
August 05, 2006

Derek Parnell wrote:
> On Sat, 5 Aug 2006 17:23:08 -0400, Jarrett Billingsley wrote:
> 
> 
>>import utf = std.utf;
>>
>>wchar[] utf16(char[] s)
>>{
>>    return utf.toUTF16(s);
>>}
>>
>>...
>>
>>char[] s = "hello";
>>wchar[] t = s.utf16;
>>
>> ;)
>>
>>Aren't first-array-param-as-a-property functions cool?
> 
> 
> Actually, that doesn't compile any more either.
> 
> Instead of 
> 
>    wchar[] t = s.utf16;
> 
> you have to code ...
> 
>    wchar[] t = s.utf16();
> 
> I'm sure it used to work the way you wrote it.
> 


even worse, if abc has property foo which is dchar[], then

    abc.foo.utf8();

will also fail; you'd have to use:
abc.foo().utf8();
August 05, 2006

Hasan Aljudy wrote:
> 
> I know, but
> 1: The syntax is still not documented..
> 2: I'm talking about making these properties a part of the standard.
> 
> actually, I think:
> 
> alias toUTF8 utf8;
> alias toUTF16 utf16;
> alias toUTF32 utf32;
> 
> would do the trick.
> 
> 

even that doesn't always work now ..
1 2
Next ›   Last »