Re: Overhauling the notion of output range

2010-07-13 Thread Andrei Alexandrescu
On 07/13/2010 06:15 AM, Steven Schveighoffer wrote: On Mon, 12 Jul 2010 22:58:07 -0400, Andrei Alexandrescu wrote: Actually a char[] is not a valid output range. Overwriting variable-length codes with other variable-length codes might mess up the string. Hm... I think it should be, and here i

Re: Overhauling the notion of output range

2010-07-13 Thread Andrei Alexandrescu
On 07/13/2010 06:18 AM, Steven Schveighoffer wrote: On Tue, 13 Jul 2010 01:52:52 -0400, Philippe Sigaud wrote: You call r(e) and r([e])) 'delegates'. Are you just using it as a generic term, or does that mean using any callable (struct with opCall) is not a good idea in this case, for whatever

Re: Overhauling the notion of output range

2010-07-13 Thread Steven Schveighoffer
On Tue, 13 Jul 2010 01:52:52 -0400, Philippe Sigaud wrote: You call r(e) and r([e])) 'delegates'. Are you just using it as a generic term, or does that mean using any callable (struct with opCall) is not a good idea in this case, for whatever reason? I think struct with opCall is ok. That'

Re: Overhauling the notion of output range

2010-07-13 Thread Steven Schveighoffer
On Mon, 12 Jul 2010 22:58:07 -0400, Andrei Alexandrescu wrote: On 07/12/2010 04:39 PM, Steven Schveighoffer wrote: On Mon, 12 Jul 2010 17:25:43 -0400, Andrei Alexandrescu wrote: On 07/12/2010 02:41 PM, Steven Schveighoffer wrote: I'm unsure how it will work either. I admit now that I did

Re: Overhauling the notion of output range

2010-07-12 Thread Philippe Sigaud
On Tue, Jul 13, 2010 at 05:18, Andrei Alexandrescu < seewebsiteforem...@erdani.org> wrote: To clarify: http://erdani.com/d/phobos/std_range.html Seems good to me. Lots of flexibility. I may begin to write output ranges :-) So in the very first case, e may well be a range, but the way

Re: Overhauling the notion of output range

2010-07-12 Thread Andrei Alexandrescu
On 07/12/2010 09:58 PM, Andrei Alexandrescu wrote: Here's what I have. Works? [snip] To clarify: http://erdani.com/d/phobos/std_range.html Andrei

Re: Overhauling the notion of output range

2010-07-12 Thread Andrei Alexandrescu
On 07/12/2010 04:39 PM, Steven Schveighoffer wrote: On Mon, 12 Jul 2010 17:25:43 -0400, Andrei Alexandrescu wrote: On 07/12/2010 02:41 PM, Steven Schveighoffer wrote: I'm unsure how it will work either. I admit now that I didn't think through how this will be used. It's very simple. As far

Re: Overhauling the notion of output range

2010-07-12 Thread Andrei Alexandrescu
On 07/12/2010 04:39 PM, Steven Schveighoffer wrote: On Mon, 12 Jul 2010 17:25:43 -0400, Andrei Alexandrescu wrote: On 07/12/2010 02:41 PM, Steven Schveighoffer wrote: I'm unsure how it will work either. I admit now that I didn't think through how this will be used. It's very simple. As far

Re: Overhauling the notion of output range

2010-07-12 Thread Steven Schveighoffer
On Mon, 12 Jul 2010 17:25:43 -0400, Andrei Alexandrescu wrote: On 07/12/2010 02:41 PM, Steven Schveighoffer wrote: I'm unsure how it will work either. I admit now that I didn't think through how this will be used. It's very simple. As far as a user of an output range is concerned, they s

Re: Overhauling the notion of output range

2010-07-12 Thread Andrei Alexandrescu
On 07/12/2010 02:41 PM, Steven Schveighoffer wrote: I'm unsure how it will work either. I admit now that I didn't think through how this will be used. It's very simple. As far as a user of an output range is concerned, they should write stuff like: put(r, '['); char[] someBuf; put(r, someBuf

Re: Overhauling the notion of output range

2010-07-12 Thread BLS
On 12/07/2010 03:17, Andrei Alexandrescu wrote: he notion of output range has been a tad vague in the past; up until now a range that wanted to qualify as an output range had to define a method called put. What if we have to deal with non orthogonal structures, or .. simple directed graphs ?

Re: Overhauling the notion of output range

2010-07-12 Thread Michel Fortin
On 2010-07-12 13:49:50 -0400, Andrei Alexandrescu said: The point is that with a delegate you must choose between accepting E and E[]. Given the constraint, it's better for everyone to accept E[] and let put() take care of the occasional E by doing the wraparoo (&elem)[0..1]. If this means

Re: Overhauling the notion of output range

2010-07-12 Thread Steven Schveighoffer
On Mon, 12 Jul 2010 15:18:17 -0400, Andrei Alexandrescu wrote: On 07/12/2010 01:47 PM, Steven Schveighoffer wrote: On Mon, 12 Jul 2010 13:49:50 -0400, Andrei Alexandrescu wrote: Yes. The point is that with a delegate you must choose between accepting E and E[]. Given the constraint, it's b

Re: Overhauling the notion of output range

2010-07-12 Thread Andrei Alexandrescu
On 07/12/2010 01:47 PM, Steven Schveighoffer wrote: On Mon, 12 Jul 2010 13:49:50 -0400, Andrei Alexandrescu wrote: Yes. The point is that with a delegate you must choose between accepting E and E[]. Given the constraint, it's better for everyone to accept E[] and let put() take care of the occa

Re: Overhauling the notion of output range

2010-07-12 Thread dsimcha
== Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s article > On 07/12/2010 01:31 PM, dsimcha wrote: > > But efficiency only matters some of the time, assuming the kind of > > inefficiency in > > question is small constant term inefficiency (as is the case here) and not > > O(N!)

Re: Overhauling the notion of output range

2010-07-12 Thread Andrei Alexandrescu
On 07/12/2010 01:31 PM, dsimcha wrote: But efficiency only matters some of the time, assuming the kind of inefficiency in question is small constant term inefficiency (as is the case here) and not O(N!) inefficiency or 1000-fold constant term inefficiency. Historically the constant was large.

Re: Overhauling the notion of output range

2010-07-12 Thread Christian Kamm
Andrei Alexandrescu wrote: > Yes. The point is that with a delegate you must choose between accepting > E and E[]. Given the constraint, it's better for everyone to accept E[] > and let put() take care of the occasional E by doing the wraparoo > (&elem)[0..1]. I don't think the current implementat

Re: Overhauling the notion of output range

2010-07-12 Thread Steven Schveighoffer
On Mon, 12 Jul 2010 13:49:50 -0400, Andrei Alexandrescu wrote: On 07/12/2010 11:48 AM, Steven Schveighoffer wrote: On Mon, 12 Jul 2010 11:05:33 -0400, Andrei Alexandrescu wrote: On 07/12/2010 09:59 AM, Steven Schveighoffer wrote: If I always have to do something like this in order to app

Re: Overhauling the notion of output range

2010-07-12 Thread dsimcha
== Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s article > On 07/12/2010 12:55 PM, Steven Schveighoffer wrote: > > On Mon, 12 Jul 2010 13:43:18 -0400, torhu wrote: > > > >> On 12.07.2010 18:48, Steven Schveighoffer wrote: > >> [...] > >>> So what happens when you call put(r, e)

Re: Overhauling the notion of output range

2010-07-12 Thread Andrei Alexandrescu
On 07/12/2010 12:55 PM, Steven Schveighoffer wrote: On Mon, 12 Jul 2010 13:43:18 -0400, torhu wrote: On 12.07.2010 18:48, Steven Schveighoffer wrote: [...] So what happens when you call put(r, e) for one of these output classes? Instead of just calling add(e), it calls (add((&e)[0..1])) which

Re: Overhauling the notion of output range

2010-07-12 Thread Steven Schveighoffer
On Mon, 12 Jul 2010 13:43:18 -0400, torhu wrote: On 12.07.2010 18:48, Steven Schveighoffer wrote: [...] So what happens when you call put(r, e) for one of these output classes? Instead of just calling add(e), it calls (add((&e)[0..1])) which in turn goes through some needless loop, which then

Re: Overhauling the notion of output range

2010-07-12 Thread Andrei Alexandrescu
On 07/12/2010 11:48 AM, Steven Schveighoffer wrote: On Mon, 12 Jul 2010 11:05:33 -0400, Andrei Alexandrescu wrote: On 07/12/2010 09:59 AM, Steven Schveighoffer wrote: If I always have to do something like this in order to append a single element: put(r, (&elem)[0..1]); No, the library does

Re: Overhauling the notion of output range

2010-07-12 Thread torhu
On 12.07.2010 18:48, Steven Schveighoffer wrote: [...] So what happens when you call put(r, e) for one of these output classes? Instead of just calling add(e), it calls (add((&e)[0..1])) which in turn goes through some needless loop, which then ends up calling add(e). I don't see why this is pre

Re: Overhauling the notion of output range

2010-07-12 Thread Steven Schveighoffer
On Mon, 12 Jul 2010 11:05:33 -0400, Andrei Alexandrescu wrote: On 07/12/2010 09:59 AM, Steven Schveighoffer wrote: If I always have to do something like this in order to append a single element: put(r, (&elem)[0..1]); No, the library does that. Look here: http://www.dsource.org/projects/

Re: Overhauling the notion of output range

2010-07-12 Thread Andrei Alexandrescu
On 07/12/2010 09:59 AM, Steven Schveighoffer wrote: On Mon, 12 Jul 2010 10:41:51 -0400, Andrei Alexandrescu wrote: On 07/12/2010 07:44 AM, Steven Schveighoffer wrote: On Mon, 12 Jul 2010 02:21:25 -0400, Andrei Alexandrescu wrote: On 07/12/2010 12:45 AM, Philippe Sigaud wrote: On Mon, Jul

Re: Overhauling the notion of output range

2010-07-12 Thread Steven Schveighoffer
On Mon, 12 Jul 2010 10:41:51 -0400, Andrei Alexandrescu wrote: On 07/12/2010 07:44 AM, Steven Schveighoffer wrote: On Mon, 12 Jul 2010 02:21:25 -0400, Andrei Alexandrescu wrote: On 07/12/2010 12:45 AM, Philippe Sigaud wrote: On Mon, Jul 12, 2010 at 03:17, Andrei Alexandrescu mailto:seewe

Re: Overhauling the notion of output range

2010-07-12 Thread Andrei Alexandrescu
On 07/12/2010 07:44 AM, Steven Schveighoffer wrote: On Mon, 12 Jul 2010 02:21:25 -0400, Andrei Alexandrescu wrote: On 07/12/2010 12:45 AM, Philippe Sigaud wrote: On Mon, Jul 12, 2010 at 03:17, Andrei Alexandrescu mailto:seewebsiteforem...@erdani.org>> wrote: In related news, there's been thi

Re: Overhauling the notion of output range

2010-07-12 Thread Steven Schveighoffer
On Mon, 12 Jul 2010 02:21:25 -0400, Andrei Alexandrescu wrote: On 07/12/2010 12:45 AM, Philippe Sigaud wrote: On Mon, Jul 12, 2010 at 03:17, Andrei Alexandrescu mailto:seewebsiteforem...@erdani.org>> wrote: In related news, there's been this burning desire regarding a lightweight ou

Re: Overhauling the notion of output range

2010-07-11 Thread Andrei Alexandrescu
On 07/12/2010 12:45 AM, Philippe Sigaud wrote: On Mon, Jul 12, 2010 at 03:17, Andrei Alexandrescu mailto:seewebsiteforem...@erdani.org>> wrote: In related news, there's been this burning desire regarding a lightweight output range defined as simply a delegate that accepts const(char)

Re: Overhauling the notion of output range

2010-07-11 Thread Philippe Sigaud
On Mon, Jul 12, 2010 at 03:17, Andrei Alexandrescu < seewebsiteforem...@erdani.org> wrote: > In related news, there's been this burning desire regarding a lightweight > output range defined as simply a delegate that accepts const(char)[]. That > range is an output range all right, and the way you

Re: Overhauling the notion of output range

2010-07-11 Thread Andrei Alexandrescu
On 07/11/2010 08:34 PM, dsimcha wrote: 1. What happens if you run out of space in the input range variety? I guess it throws? It's up to the range. Most will throw. 2. Would there be a "standard" way of signaling how much stuff was written to the input range variety? I guess that since f

Re: Overhauling the notion of output range

2010-07-11 Thread dsimcha
== Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s article > The notion of output range has been a tad vague in the past; up until > now a range that wanted to qualify as an output range had to define a > method called put. > That definition is awkward though. For example, the std.

Re: Overhauling the notion of output range

2010-07-11 Thread Andrei Alexandrescu
On 07/11/2010 08:17 PM, Andrei Alexandrescu wrote: [snip] Forgot to mention one detail: now the free function std.range.put() serves as a convenient dispatcher for any kind of output range. Andrei

Overhauling the notion of output range

2010-07-11 Thread Andrei Alexandrescu
The notion of output range has been a tad vague in the past; up until now a range that wanted to qualify as an output range had to define a method called put. That definition is awkward though. For example, the std.algorithm.copy() primitive should work for an output range, but also for some o