On Fri, 27 May 2011 21:18:40 +0300, Jonathan M Davis <[email protected]> wrote:

On 2011-05-27 11:05, Vladimir Panteleev wrote:
Why hasLength!string is false:
https://github.com/D-Programming-Language/phobos/blob/96941d5384a5fee302df/
std/range.d#L767

Would it make sense to introduce a hasOpaqueLength oslt. to fix this?

Um. Why? What would it give you? hasLength is intended for range-based stuff. and and any arrays of char or wchar are ranges of dchar, so they don't have a length property as far as ranges are concerned. If you want your template to work with any of the string types, then just use isSomeString to check whether it's a string. What would hasOpaqueLength do? What would it get you? Yes, the situation with char and wchar technically having a length property but having hasLength be false for them is a bit odd, but it works, and hasLength does exactly what it's supposed to - check whether the type has a length property
for use with ranges. And char and wchar arrays don't.

Wow, you sure took your time to bash my stupid suggestion :) I agree completely, TBH I only added that because I didn't want my post to look like a complaint without even an attempt to suggest a solution.

As long as std.array.join & co. don't do a character-by-character copy for strings, I'm happy. Still, putting isSomeString in std.array/std.range checks seems like a hack to me.

--
Best regards,
 Vladimir                            mailto:[email protected]

Reply via email to