Re: How to reverse char[]?

2012-02-08 Thread Jos van Uden
On 8-2-2012 2:36, Timon Gehr wrote: char[] is handled by Phobos as a range of dchar, ergo it does not have swappable elements. I'm surprised that array.reverse does work (using 2.057)

Re: How to reverse char[]?

2012-02-08 Thread Steven Schveighoffer
On Wed, 08 Feb 2012 04:30:04 -0500, Jos van Uden user@domain.invalid wrote: On 8-2-2012 2:36, Timon Gehr wrote: char[] is handled by Phobos as a range of dchar, ergo it does not have swappable elements. I'm surprised that array.reverse does work (using 2.057) array.reverse is *not* the

Re: How to reverse char[]?

2012-02-08 Thread Timon Gehr
On 02/08/2012 03:56 PM, Steven Schveighoffer wrote: On Wed, 08 Feb 2012 04:30:04 -0500, Jos van Uden user@domain.invalid wrote: On 8-2-2012 2:36, Timon Gehr wrote: char[] is handled by Phobos as a range of dchar, ergo it does not have swappable elements. I'm surprised that array.reverse

Re: How to reverse char[]?

2012-02-08 Thread H. S. Teoh
On Wed, Feb 08, 2012 at 09:56:17AM -0500, Steven Schveighoffer wrote: [...] D will continue to trip over itself and fall into newbies until it makes a decision to make strings not also be arrays. [...] I disagree. D will continue to trip over itself until it treats all arrays equally, that is,

Re: How to reverse char[]?

2012-02-08 Thread H. S. Teoh
On Wed, Feb 08, 2012 at 08:32:32AM -0800, Jonathan M Davis wrote: [...] Except that char[] is _not_ an array of characters. It's an array of code units. There is a _big_ difference. Not even dchar[] is an array of characters. It's both an array of code units and an array of code points, but

Re: How to reverse char[]?

2012-02-08 Thread Manfred Nowak
Jonathan M Davis wrote: thanks to how unicode works This does not mean, that the data structure representing a sequence of letters has to follow exactly the working you cited above. That data structure must only enable it efficiently. If a requirement for sequences of letters is, that a

Re: How to reverse char[]?

2012-02-08 Thread Jonathan M Davis
On Wednesday, February 08, 2012 09:35:28 H. S. Teoh wrote: On Wed, Feb 08, 2012 at 08:32:32AM -0800, Jonathan M Davis wrote: [...] Except that char[] is _not_ an array of characters. It's an array of code units. There is a _big_ difference. Not even dchar[] is an array of characters.

Re: How to reverse char[]?

2012-02-08 Thread Jonathan M Davis
On Wednesday, February 08, 2012 17:52:17 Manfred Nowak wrote: Jonathan M Davis wrote: thanks to how unicode works This does not mean, that the data structure representing a sequence of letters has to follow exactly the working you cited above. That data structure must only enable it

How to reverse char[]?

2012-02-07 Thread H. S. Teoh
Hi all, I'm trying to reverse a character array. Why doesn't the following work? import std.algorithm; void main() { char[] array = ['a', 'b', 'c']; reverse(array); } I get: Error: template std.algorithm.reverse(Range) if

Re: How to reverse char[]?

2012-02-07 Thread Timon Gehr
On 02/08/2012 02:29 AM, H. S. Teoh wrote: Hi all, I'm trying to reverse a character array. Why doesn't the following work? import std.algorithm; void main() { char[] array = ['a', 'b', 'c']; reverse(array); } I get: Error: template

Re: How to reverse char[]?

2012-02-07 Thread James Miller
On 02/08/2012 02:29 AM, H. S. Teoh wrote: Hi all, I'm trying to reverse a character array. Why doesn't the following work?        import std.algorithm;        void main() {                char[] array = ['a', 'b', 'c'];                reverse(array);        } I get: Error: template

Re: How to reverse char[]?

2012-02-07 Thread Jonathan M Davis
On Wednesday, February 08, 2012 02:36:23 Timon Gehr wrote: char[] is handled by Phobos as a range of dchar, ergo it does not have swappable elements. Apparently there is no template specialisation of 'reverse' that handles narrow strings, you might want to file an enhancement request. There