February 14, 2010
On 2010-02-14 07:15:55 -0500, bearophile <bearophileHUGS@lycos.com> said:

> The first can be done turning an interval into syntax sugar for iota(1,100):
> The foreach(i; retro(1 .. 100))

I'm all for it, but we'll need to have 1..100 mapped to a new interval type for this to work. Then you can easily implement this (among many other interesting things):

	auto reverse(Interval!int interval) { ... }


-- 
Michel Fortin
michel.fortin@michelf.com
http://michelf.com/

February 14, 2010
Mike James Wrote:

> Andrei Alexandrescu Wrote:
> 
> > Gone, that is. Walter agreed to remove it.
> > 
> > To achieve the functionality of
> > 
> > foreach_reverse (r) { ... }
> > 
> > use
> > 
> > foreach (retro(r)) { ... }
> > 
> > using retro in std.range.
> > 
> > 
> > Andrei
> 
> I think Reverse would have been a better title. Retro sounds like you might be using only 8088 assembler instructions in the output...
> 
> -=mike=-

Read about a guy that used preprocessor to change C keywords to his taste on company project. Nearly caused heart attack to next guy in line to maintain that code. Maybe we could keep both keywords :D
February 14, 2010
Michel Fortin:
> It's an amusing name in the way Andrei likes it, but the meaning isn't very clear. "reverse" would be a better name.

In Python it's "reversed":

>>> a = [5,7,1,3]
>>> reversed(a)
<listreverseiterator object at 0x019E25B0>
>>> list(reversed(a))
[3, 1, 7, 5]

Python use verbs in past tense (like "sorted", "reversed", etc) to denote something that doesn't change the given input (while "sort" sorts in-place).

Bye,
bearophile
February 14, 2010
== Quote from bearophile (bearophileHUGS@lycos.com)'s article
> The second gives no problems if retro is well done:
> foreach(v; retro(structWithopApplyReverse))
> Bye,
> bearophile

I have no idea how you would implement retro such that it worked with opApplyReverse.
February 14, 2010
== Quote from Lars T. Kyllingstad (public@kyllingen.NOSPAMnet)'s article
> Andrei Alexandrescu wrote:
> > Gone, that is. Walter agreed to remove it.
> >
> > To achieve the functionality of
> >
> > foreach_reverse (r) { ... }
> >
> > use
> >
> > foreach (retro(r)) { ... }
> >
> > using retro in std.range.
> Let me first say that I think it's great that one of D's ugliest
> keywords is going away. But does retro (or ranges in general) support
> iteration over both index and element?
>    foreach_reverse(i, e; foo) { ... }
> -Lars

Bug 3519:  http://d.puremagic.com/issues/show_bug.cgi?id=3519
February 14, 2010
== Quote from Daniel Murphy (yebbliesnospam@gmail.com)'s article
> Andrei Alexandrescu Wrote:
> > Gone, that is. Walter agreed to remove it.
> >
> > To achieve the functionality of
> >
> > foreach_reverse (r) { ... }
> >
> > use
> >
> > foreach (retro(r)) { ... }
> >
> > using retro in std.range.
> >
> >
> > Andrei
> What about where foreach is being done over something other than a range?
> eg.
> foreach(i; 1..100)
> foreach(v; structwithopapply)

In general, now that we've decided to keep opApply, std.range needs to be reworked a little to make it coexist as peacefully as possible with ranges.  For this case, I guess retro could simply have an opApply method that forwards to structwithopapply's opApplyReverse method.
February 14, 2010
On 2010-02-14 09:34:16 -0500, bearophile <bearophileHUGS@lycos.com> said:

> Python use verbs in past tense (like "sorted", "reversed", etc) to denote something that doesn't change the given input (while "sort" sorts in-place).

That certainly is a useful convention to make things easier to read. I'd very much like to see it used in D.


-- 
Michel Fortin
michel.fortin@michelf.com
http://michelf.com/

February 14, 2010
Michel Fortin, el 14 de febrero a las 07:48 me escribiste:
> On 2010-02-14 05:12:41 -0500, Jacob Carlborg <doob@me.com> said:
> 
> >It iterates backwards, all the way back to the 50s. I think "reverse" is a much better word.
> 
> Agree.
> 
> My dictionary says: "retro": imitative of a style, fashion, or design from the recent past.
> 
> It's an amusing name in the way Andrei likes it, but the meaning isn't very clear. "reverse" would be a better name.

This is a pattern in Andrei, which I think it really hurts the language (the names are very clever and funny, but that shouldn't be the point of a name, a name should be clear).

-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
February 14, 2010
Leandro Lucarella wrote:
> Michel Fortin, el 14 de febrero a las 07:48 me escribiste:
>> On 2010-02-14 05:12:41 -0500, Jacob Carlborg <doob@me.com> said:
>>
>>> It iterates backwards, all the way back to the 50s. I think
>>> "reverse" is a much better word.
>> Agree.
>>
>> My dictionary says: "retro": imitative of a style, fashion, or
>> design from the recent past.
>>
>> It's an amusing name in the way Andrei likes it, but the meaning
>> isn't very clear. "reverse" would be a better name.
> 
> This is a pattern in Andrei, which I think it really hurts the language
> (the names are very clever and funny, but that shouldn't be the point of
> a name, a name should be clear).

At least in this case being funny was not the point. I needed a name that was (a) short, (b) different from "reverse", (c) memorable. It is understood that other paint colors are available, but please don't forget to give a little love to the painter. :o) It would be of course best if names that arguably hurt the language were changed, so please compile a list.

Andrei
February 14, 2010
Andrei Alexandrescu Wrote:

> Leandro Lucarella wrote:
> > Michel Fortin, el 14 de febrero a las 07:48 me escribiste:
> >> On 2010-02-14 05:12:41 -0500, Jacob Carlborg <doob@me.com> said:
> >>
> >>> It iterates backwards, all the way back to the 50s. I think "reverse" is a much better word.
> >> Agree.
> >>
> >> My dictionary says: "retro": imitative of a style, fashion, or design from the recent past.
> >>
> >> It's an amusing name in the way Andrei likes it, but the meaning isn't very clear. "reverse" would be a better name.
> > 
> > This is a pattern in Andrei, which I think it really hurts the language (the names are very clever and funny, but that shouldn't be the point of a name, a name should be clear).
> 
> At least in this case being funny was not the point. I needed a name that was (a) short, (b) different from "reverse", (c) memorable. It is understood that other paint colors are available, but please don't forget to give a little love to the painter. :o) It would be of course best if names that arguably hurt the language were changed, so please compile a list.
> 
> Andrei

1.   Contrawise
2.   Rearward
3.   AssBackwards
4.   Reorientated
5.   Turnedabout
6.   Turnedaround
7.   Inversified
8.   Flipped
9.   Refluxed
10. VolteFace

or how about Reverse...

-=mike=-