digitalmars.D - Dithering about ranges
- Georg Wrede (18/18) May 21 2009 Not cosidering D or programming, the notion of a range implies a
- Andrei Alexandrescu (20/41) May 21 2009 Actually, not. Infinity is a primitive notion with ranges. A range that
- Steve Teale (4/14) May 22 2009 Andrei,
- Andrei Alexandrescu (20/43) May 22 2009 Other people have explained this once, but allow me to repeat. There was...
Not cosidering D or programming, the notion of a range implies a beginning and an end. So, in a certain sense, ranges could be conceptualized as slices. All's well, and everything. But, things like input streams don't really support the notion of "range", or "slice". They don't even want to. Sure, one could "coerce" or "forge" an input range to pretend some manner of them, but that would be awkward at best, and laborios in practice. Does that mean that I'm against ranges? No. But there might be the possibility that ranges are not a panacea. Just as Structured Programming wasn't (look at Walter's gotos all over the place), OOP wasn't, Functional Programming wasn't, or that metaprogramming doesn't tell us whether God exists. Ranges solve some gargantuan problems in Modern Programming, but I don't expect them to usurp a dozen of other paradigms. Could it be that the optimum would be to have /both/ ranges and, ehhh, pointing notions? Today, no sane programmer (outside of C or outside of Java) would make his application /entirely/ ranges or /entirely/ classes.
May 21 2009
Georg Wrede wrote:Not cosidering D or programming, the notion of a range implies a beginning and an end.Actually, not. Infinity is a primitive notion with ranges. A range that defines empty like this: enum bool empty = false; is detected as infinite and treated accordingly by certain other ranges and algorithms. See isInfinite in std.range.So, in a certain sense, ranges could be conceptualized as slices.Yes, slices were a motivator and model for ranges.All's well, and everything. But, things like input streams don't really support the notion of "range", or "slice". They don't even want to.Why don't they?Sure, one could "coerce" or "forge" an input range to pretend some manner of them, but that would be awkward at best, and laborios in practice.What would be a natural interface for an input range?Does that mean that I'm against ranges? No. But there might be the possibility that ranges are not a panacea. Just as Structured Programming wasn't (look at Walter's gotos all over the place), OOP wasn't, Functional Programming wasn't, or that metaprogramming doesn't tell us whether God exists. Ranges solve some gargantuan problems in Modern Programming, but I don't expect them to usurp a dozen of other paradigms.For sure nobody cracked them to be that great. I think you perceive them as an imposition when they really are some rather unremarkable types with at most a handful of primitives.Could it be that the optimum would be to have /both/ ranges and, ehhh, pointing notions? Today, no sane programmer (outside of C or outside of Java) would make his application /entirely/ ranges or /entirely/ classes.I don't quite understand this. Ranges are a very simple abstraction for iteration. They show how other iteration abstractions either were too iterators, singly-linked lists used by functional languages), so in that regard I think they hit the spot pretty nicely. Ranges are useful, but hardly a be-all end-all. Thinking of building an application entirely of ranges... I can't quite parse that. Andrei
May 21 2009
Andrei Alexandrescu Wrote:I don't quite understand this. Ranges are a very simple abstraction for iteration. They show how other iteration abstractions either were too iterators, singly-linked lists used by functional languages), so in that regard I think they hit the spot pretty nicely. Ranges are useful, but hardly a be-all end-all. Thinking of building an application entirely of ranges... I can't quite parse that. AndreiAndrei, I'm still waiting to read the definitive article about ranges. Does this exist at present? It's nice to have something like an RFC, not just a new version of a standard library without warning, and just depend on the comments. As Walter has I think said, comments always lie! Steve
May 22 2009
Steve Teale wrote:Andrei Alexandrescu Wrote:Other people have explained this once, but allow me to repeat. There was a lengthy RFC period with discussions on the announce group entitled "RFC on range design for D2" supported by a document. That document has been since superseded by the implementation documentation which, aside you need to define and use ranges effectively. There was a lengthy "warning breaking changes coming" period, to the extent that some people on the group got tired of it. If you are interested in ranges, the one thing you shouldn't be doing is to wait for a tutorial written by yours truly. What you could be doing in little more than the time it takes to write a long post (ahem) would be to grok ranges yourself and write a solid tutorial about ranges in a blog, web page, or online magazine. They are deceptively simple and can be composed in very interesting ways. Waiting for something from Walter or myself is not the pattern to be in. Shin, Don, Jarrett, David, and others are doing great stuff, and incidentally don't whine as much (except for Jarrett -- squeaky wheel gets the K-Y). AndreiI don't quite understand this. Ranges are a very simple abstraction for iteration. They show how other iteration abstractions either iterators, Java iterators, singly-linked lists used by functional languages), so in that regard I think they hit the spot pretty nicely. Ranges are useful, but hardly a be-all end-all. Thinking of building an application entirely of ranges... I can't quite parse that. AndreiAndrei, I'm still waiting to read the definitive article about ranges. Does this exist at present? It's nice to have something like an RFC, not just a new version of a standard library without warning, and just depend on the comments. As Walter has I think said, comments always lie! Steve
May 22 2009