Re: typeof(string.front) should be char

2012-03-03 Thread Jonathan M Davis
On Friday, March 02, 2012 20:41:35 Ali Çehreli wrote: On 03/02/2012 06:30 PM, Piotr Szturmaj wrote: Hello, For this code: auto c = testc; auto w = testw; auto d = testd; pragma(msg, typeof(c.front)); pragma(msg, typeof(w.front)); pragma(msg, typeof(d.front));

Re: typeof(string.front) should be char

2012-03-03 Thread Jacob Carlborg
On 2012-03-03 03:30, Piotr Szturmaj wrote: Hello, For this code: auto c = testc; auto w = testw; auto d = testd; pragma(msg, typeof(c.front)); pragma(msg, typeof(w.front)); pragma(msg, typeof(d.front)); compiler prints: dchar dchar immutable(dchar) I thought all these would be either dchar

Re: typeof(string.front) should be char

2012-03-03 Thread Piotr Szturmaj
Jonathan M Davis wrote: On Friday, March 02, 2012 20:41:35 Ali Çehreli wrote: On 03/02/2012 06:30 PM, Piotr Szturmaj wrote: Hello, For this code: auto c = testc; auto w = testw; auto d = testd; pragma(msg, typeof(c.front)); pragma(msg, typeof(w.front));

Re: typeof(string.front) should be char

2012-03-03 Thread Ali Çehreli
On 03/03/2012 04:36 AM, Jacob Carlborg wrote: On 2012-03-03 03:30, Piotr Szturmaj wrote: Hello, For this code: auto c = testc; auto w = testw; auto d = testd; pragma(msg, typeof(c.front)); pragma(msg, typeof(w.front)); pragma(msg, typeof(d.front)); compiler prints: dchar dchar

Re: typeof(string.front) should be char

2012-03-03 Thread Ali Çehreli
On 03/03/2012 05:57 AM, Piotr Szturmaj wrote: Consider a custom range of char: struct CharRange { @property bool empty(); @property char front(); void popFront(); } typeof(CharRange.front) and ElementType!CharRange both return _char_ Yes, and I would expect both to the same type.

Re: typeof(string.front) should be char

2012-03-03 Thread Timon Gehr
On 03/03/2012 09:40 AM, Jonathan M Davis wrote: ... but operating on code points is _far_ more correct than operating on code units. It's also more efficient. [snip.] No, it is less efficient.

Re: typeof(string.front) should be char

2012-03-03 Thread Jacob Carlborg
On 2012-03-03 15:10, Ali Çehreli wrote: On 03/03/2012 04:36 AM, Jacob Carlborg wrote: On 2012-03-03 03:30, Piotr Szturmaj wrote: Hello, For this code: auto c = testc; auto w = testw; auto d = testd; pragma(msg, typeof(c.front)); pragma(msg, typeof(w.front)); pragma(msg, typeof(d.front));

Re: typeof(string.front) should be char

2012-03-03 Thread Jonathan M Davis
On Saturday, March 03, 2012 18:38:44 Timon Gehr wrote: On 03/03/2012 09:40 AM, Jonathan M Davis wrote: ... but operating on code points is _far_ more correct than operating on code units. It's also more efficient. [snip.] No, it is less efficient. Operating on code points is more

Re: typeof(string.front) should be char

2012-03-03 Thread Jonathan M Davis
On Saturday, March 03, 2012 14:57:59 Piotr Szturmaj wrote: This discrepancy pushes the range writer to handle special string cases. Yes it does. And there's _no_ way around that if you want to handle unicode both correctly and efficiently. To handle it correctly, you must operate on code

Re: typeof(string.front) should be char

2012-03-03 Thread Timon Gehr
On 03/03/2012 08:46 PM, Jonathan M Davis wrote: On Saturday, March 03, 2012 18:38:44 Timon Gehr wrote: On 03/03/2012 09:40 AM, Jonathan M Davis wrote: ... but operating on code points is _far_ more correct than operating on code units. It's also more efficient. [snip.] No, it is less

Re: typeof(string.front) should be char

2012-03-03 Thread H. S. Teoh
On Sat, Mar 03, 2012 at 12:42:53PM -0800, Jonathan M Davis wrote: [...] The current solution encourages correct usage (or at least usage which is closer to correct, since it still isn't at the grapheme level) without disallowing more optimized code. [...] Speaking of graphemes, is anyone

Re: typeof(string.front) should be char

2012-03-03 Thread H. S. Teoh
On Sat, Mar 03, 2012 at 11:53:41AM -0800, Jonathan M Davis wrote: [...] If you want to iterate by char, then use foreach or use a wrapper range (or cast to ubyte[] and operate on that). Or use: string str = ...; for (size_t i=0; i str.length; i++) { /* do

Re: typeof(string.front) should be char

2012-03-03 Thread Ali Çehreli
On 03/03/2012 01:42 PM, H. S. Teoh wrote: On Sat, Mar 03, 2012 at 12:42:53PM -0800, Jonathan M Davis wrote: [...] The current solution encourages correct usage (or at least usage which is closer to correct, since it still isn't at the grapheme level) without disallowing more optimized code.

Re: typeof(string.front) should be char

2012-03-03 Thread Jonathan M Davis
On Saturday, March 03, 2012 13:46:16 Ali Çehreli wrote: On 03/03/2012 01:42 PM, H. S. Teoh wrote: On Sat, Mar 03, 2012 at 12:42:53PM -0800, Jonathan M Davis wrote: [...] The current solution encourages correct usage (or at least usage which is closer to correct, since it still isn't at

Re: typeof(string.front) should be char

2012-03-03 Thread Jonathan M Davis
On Saturday, March 03, 2012 13:46:16 Ali Çehreli wrote: On 03/03/2012 01:42 PM, H. S. Teoh wrote: On Sat, Mar 03, 2012 at 12:42:53PM -0800, Jonathan M Davis wrote: [...] The current solution encourages correct usage (or at least usage which is closer to correct, since it still isn't at

typeof(string.front) should be char

2012-03-02 Thread Piotr Szturmaj
Hello, For this code: auto c = testc; auto w = testw; auto d = testd; pragma(msg, typeof(c.front)); pragma(msg, typeof(w.front)); pragma(msg, typeof(d.front)); compiler prints: dchar dchar immutable(dchar) IMO it should print this: immutable(char) immutable(wchar)

Re: typeof(string.front) should be char

2012-03-02 Thread Ali Çehreli
On 03/02/2012 06:30 PM, Piotr Szturmaj wrote: Hello, For this code: auto c = testc; auto w = testw; auto d = testd; pragma(msg, typeof(c.front)); pragma(msg, typeof(w.front)); pragma(msg, typeof(d.front)); compiler prints: dchar dchar immutable(dchar) IMO it should print this: