digitalmars.D.learn - Problem with std.array(std.regex.splitter())
- bearophile (12/12) Aug 08 2010 This D2 code:
- Pelle (4/16) Aug 09 2010 std.array.array() erroneously requires a forward range, where it should
- Jonathan M Davis (11/15) Aug 09 2010 Well, the requirement for save() being part of a forward range is fairly...
- bearophile (5/11) Aug 09 2010 I have tried the latest beta and indeed it works, thank you.
- Lars T. Kyllingstad (9/20) Aug 09 2010 It should be in the documentation of std.range.isForwardRange(), but
- Jonathan M Davis (5/20) Aug 09 2010 save() gives you a generic way to get a copy of the range so that you ca...
This D2 code: import std.regex: splitter, regex; import std.array: array; void main() { array(splitter(", abc, de", regex(", *"))); } Gives the errors: test.d(4): Error: template std.array.array(Range) if (isForwardRange!(Range)) does not match any function template declaration test.d(4): Error: template std.array.array(Range) if (isForwardRange!(Range)) cannot deduce template function from argument types !()(Splitter!(string)) Do you know what's wrong in it? Bye and thank you, bearophile
Aug 08 2010
On 08/09/2010 12:50 AM, bearophile wrote:This D2 code: import std.regex: splitter, regex; import std.array: array; void main() { array(splitter(", abc, de", regex(", *"))); } Gives the errors: test.d(4): Error: template std.array.array(Range) if (isForwardRange!(Range)) does not match any function template declaration test.d(4): Error: template std.array.array(Range) if (isForwardRange!(Range)) cannot deduce template function from argument types !()(Splitter!(string)) Do you know what's wrong in it? Bye and thank you, bearophilestd.array.array() erroneously requires a forward range, where it should require an input range. Splitter also does not define save(), so it's not a forward range.
Aug 09 2010
On Monday 09 August 2010 01:13:30 Pelle wrote:std.array.array() erroneously requires a forward range, where it should require an input range. Splitter also does not define save(), so it's not a forward range.Well, the requirement for save() being part of a forward range is fairly recent, and a bunch of ranges which are supposed to be forward ranges don't have them even though they're supposed to. The change was made fairly close to the release of 2.047, I believe, and it was missed for many ranges. It's mostly if not entirely fixed in svn. Actually, if I try and compile Bearophile's code on my machine (which has a fairly recent version of phobos), it compiles just fine. So, I don't know if array() should require an input range or a forward range, but the issue here has to do with recent changes to forward ranges which didn't make it into all forward ranges. It should be fixed with 2.048. - Jonathan M Davis
Aug 09 2010
Jonathan M Davis:Well, the requirement for save() being part of a forward range is fairly recent, and a bunch of ranges which are supposed to be forward ranges don't have them even though they're supposed to. The change was made fairly close to the release of 2.047, I believe, and it was missed for many ranges. It's mostly if not entirely fixed in svn. Actually, if I try and compile Bearophile's code on my machine (which has a fairly recent version of phobos), it compiles just fine.I have tried the latest beta and indeed it works, thank you. Where can I find information about the purposes and meaning of save()? TDPL? Bye, bearophile
Aug 09 2010
On Mon, 09 Aug 2010 07:31:21 -0400, bearophile wrote:Jonathan M Davis:It should be in the documentation of std.range.isForwardRange(), but Andrei seems to have forgotten it. He did describe it in his 'On Iteration' article, though: http://www.informit.com/articles/article.aspx?p=1407357 Check out page 7, section 'Forward Ranges'. (I think the whole article is worth reading, if you haven't already -- it really helped me understand ranges.) -LarsWell, the requirement for save() being part of a forward range is fairly recent, and a bunch of ranges which are supposed to be forward ranges don't have them even though they're supposed to. The change was made fairly close to the release of 2.047, I believe, and it was missed for many ranges. It's mostly if not entirely fixed in svn. Actually, if I try and compile Bearophile's code on my machine (which has a fairly recent version of phobos), it compiles just fine.I have tried the latest beta and indeed it works, thank you. Where can I find information about the purposes and meaning of save()? TDPL?
Aug 09 2010
On Monday, August 09, 2010 04:31:21 bearophile wrote:Jonathan M Davis:save() gives you a generic way to get a copy of the range so that you can mess with the copy without altering the original. That way you don't have to worry about the different copy semantics for classes, structs, and arrays. - Jonathan M DavisWell, the requirement for save() being part of a forward range is fairly recent, and a bunch of ranges which are supposed to be forward ranges don't have them even though they're supposed to. The change was made fairly close to the release of 2.047, I believe, and it was missed for many ranges. It's mostly if not entirely fixed in svn. Actually, if I try and compile Bearophile's code on my machine (which has a fairly recent version of phobos), it compiles just fine.I have tried the latest beta and indeed it works, thank you. Where can I find information about the purposes and meaning of save()? TDPL? Bye, bearophile
Aug 09 2010