Andrei Alexandrescu napisał:

> On 1/17/11 1:53 PM, Tomek Sowiński wrote:
> > Andrei Alexandrescu napisał:
> >
> >> std.range has a function repeat that repeats one value forever. For
> >> example, repeat(42) is an infinite range containing 42, 42, 42,...
> >>
> >> The same module also has a function replicate that repeats one value a
> >> specific number of times. In fact, replicate can be expressed as an
> >> overload of repeat, so that's what I just did (not committed yet):
> >> repeat(42, 100) repeats 42 one hundred times, repeat(42) repeats 42
> >> forever. I'll put replicate on the deprecation chute.
> >>
> >> So far so good. Now, string has its own repeat. repeat("abc", 2) returns
> >> the string "abcabc".
> >>
> >> I want to generalize the functionality in string's repeat and move it
> >> outside std.string. There is an obvious semantic clash here. If you say
> >> repeat("abc", 3) did you mean one string "abcabcabc" or three strings
> >> "abc", "abc", and "abc"?
> >>
> >> So we need distinct names for the functions. One repeats one value, the
> >> other repeats a range. Moreover, I'm thinking sometimes you want to
> >> repeat a range lazily, i.e. instead of producing "abcabc" just return a
> >> range that looks like it.
> >>
> >> Ideas for a good naming scheme are welcome.
> >
> > Overload cycle and call it a day?
> 
> cycle(r, n) already has a meaning: cycle r for a maximum total of n 
> elements.

Now I'm confused. The docs say it's an initial index...

-- 
Tomek

Reply via email to