[Issue 4317] Calling std.string.split with static array for separator fails to compile
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed May 25 03:22:22 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4317
Jonathan M Davis <jmdavisProg at gmx.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jmdavisProg at gmx.com
--- Comment #3 from Jonathan M Davis <jmdavisProg at gmx.com> 2011-05-25 03:18:04 PDT ---
The template error is not the best, but it's definitely an error to try and use
a static array as a range. You need to take a slice of it.
> Isn't it better and nicer to define it as a normal string?
> immutable string whitespace = " \t\v\r\n\f"; /// ASCII whitespace
I'm currently in the process of rearranging some of std.string, std.ctype, and
std.uni to make it more consistent in terms of naming and where each type of
functionality goes (such as putting the functions which operate on single
characters instead of strings in std.ctype if they deal with ASCII or std.uni
if they deal with unicode rather than having them be in std.string which is
supposed to operate on strings). One of the changes that I made does change
whitespace to a string (albeit in std.ctype rather than std.string). So,
assuming that my pull request passes peer review on github once I'm done, this
particular case will work.
However, what the compiler is doing is completely correct. Range functions
_shouldn't_ work with static arrays, because static arrays are not ranges. They
can't be, since they're not mutable. If the error is still this bad (which is
questionable given that a number of functions in std.string, std.array,
std.range, and std.algorithm have been moved around and/or updated since
2.047), then the template constraints on split should be improved. But the
compiler is perfectly correct in not allowing this code to work.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list