Re: So how exactly does one make a persistent range object?

2011-06-13 Thread Ali Çehreli
On Sat, 04 Jun 2011 20:27:16 +0200, Andrej Mitrovic wrote: This is my #1 problem with ranges right now: import std.range; int[3] a = [1, 2, 3]; shared range = cycle(a[]); // nope void main() { foo(); } void foo() { // do something with range } test.d(6): Error:

Re: So how exactly does one make a persistent range object?

2011-06-06 Thread Andrej Mitrovic
On 6/6/11, Jonathan M Davis jmdavisp...@gmx.com wrote: On the whole, I believe that ranges were generally intended to be processed and then tossed, which is usually what happens with iterators.. That's what I thought but wasn't sure if that was really the case. I don't really have a solid C++

Re: So how exactly does one make a persistent range object?

2011-06-06 Thread Timon Gehr
Andrej Mitrovic wrote: On 6/6/11, Jonathan M Davis jmdavisp...@gmx.com wrote: So, anything you do on your own could be polymorphic, but as soon as you get ranges from Phobos, you lose the polymorphism. Yeah, I've noticed that. I wouldn't want to loose the ability to call into

Re: So how exactly does one make a persistent range object?

2011-06-05 Thread Andrej Mitrovic
Ah the good old typeof. It's nice to have language sugar like this that save the day. :)

Re: So how exactly does one make a persistent range object?

2011-06-05 Thread Jonathan M Davis
On 2011-06-05 09:43, Andrej Mitrovic wrote: Ah the good old typeof. It's nice to have language sugar like this that save the day. :) I really don't think that Andrei was thinking that people would need to save ranges when he started internalizing all of the range types in std.range and

Re: So how exactly does one make a persistent range object?

2011-06-05 Thread Andrej Mitrovic
On 6/6/11, Jonathan M Davis jmdavisp...@gmx.com wrote: I really don't think that Andrei was thinking that people would need to save ranges when he started internalizing all of the range types in std.range and std.algorithm. There are some classes like InputRangeObject defined in std.range that

Re: So how exactly does one make a persistent range object?

2011-06-05 Thread Jonathan M Davis
On 2011-06-05 17:19, Andrej Mitrovic wrote: On 6/6/11, Jonathan M Davis jmdavisp...@gmx.com wrote: I really don't think that Andrei was thinking that people would need to save ranges when he started internalizing all of the range types in std.range and std.algorithm. There are some

Re: So how exactly does one make a persistent range object?

2011-06-05 Thread Andrej Mitrovic
Yeah I'm referring to polymorphism. If I want to provide some sort of interface for my users that let them build any type of range at runtime, or even a range of ranges, then there's polymorphism involved. Other than polymorphism there's no other way a function can take or return a generic range

Re: So how exactly does one make a persistent range object?

2011-06-05 Thread Jonathan M Davis
On 2011-06-05 17:47, Andrej Mitrovic wrote: Yeah I'm referring to polymorphism. If I want to provide some sort of interface for my users that let them build any type of range at runtime, or even a range of ranges, then there's polymorphism involved. Other than polymorphism there's no other

So how exactly does one make a persistent range object?

2011-06-04 Thread Andrej Mitrovic
This is my #1 problem with ranges right now: import std.range; int[3] a = [1, 2, 3]; shared range = cycle(a[]); // nope void main() { foo(); } void foo() { // do something with range } test.d(6): Error: static variable a cannot be read at compile time test.d(6): Error: cannot

Re: So how exactly does one make a persistent range object?

2011-06-04 Thread Andrej Mitrovic
Ok, this works: shared Cycle!(int[]) range; So, problem solved? Sometimes I feel like I should just e-mail myself and then give myself the answer instead of posting here. LOL.

Re: So how exactly does one make a persistent range object?

2011-06-04 Thread Andrej Mitrovic
Problem not so much solved. What if I want to keep a stride range? There's no Stride struct defined in std.range, stride() is defined as an auto function and hides the type inside the function itself. How I can store such an object in module scope? This won't work: auto var = stride([1, 2, 3],

Re: So how exactly does one make a persistent range object?

2011-06-04 Thread Jonathan M Davis
On 2011-06-04 18:01, Andrej Mitrovic wrote: Problem not so much solved. What if I want to keep a stride range? There's no Stride struct defined in std.range, stride() is defined as an auto function and hides the type inside the function itself. How I can store such an object in module