May 17, 2007 Re: Ideas for shortening "foreach_reverse" (was Re: I have a suggestion.) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | Sean Kelly wrote:
> Justin C Calvarese wrote:
>> YonggangLuo wrote:
>>> i think it's will be a good idea to replace "foreach_reverse" with "frr".
>>> "foreach_reverse" is too long as a keyword
>>
>> I agree that foreach_reverse is way too long for a keyword. Also, it has that unslightly underscore.
>>
>> I think that frr is a little too short. Since it's a keyword that will be rarely used, newcomers to D will likely get confused.
>>
>> I'm "voting" for foreachrev, but here's a whole list of decent alternatives to the current "foreach_reverse" mess:
>>
>> 1. foreachrev
>> 2. rforeach
>> 3. revforeach
>
> I still like:
>
> foreach - unordered?
> foreach(fwd) - explicitly forward
> foreach(rev) - explicitly reverse
> foreach(any) - unordered
>
Yep, or something of that ilk. It's very D-like; it means we can get rid of the special-case keyword; and it leaves wiggle room for future innovation, like foreach(any), foreach(parallel), etc., without requiring more keywords.
The only thing better than that would be what Oskar said: to improve the compiler to the point that a construct like foreach(e; reversed(A)) could be as efficient as the current hard-coded foreach_reverse behavior.
--bb
|
May 18, 2007 Re: Ideas for shortening "foreach_reverse" (was Re: I have a suggestion.) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | On Thu, 17 May 2007 10:58:36 -0700, Sean Kelly wrote: > > I still like: > > foreach - unordered? > foreach(fwd) - explicitly forward > foreach(rev) - explicitly reverse > foreach(any) - unordered I like this style of syntax for D too. The keyword "foreach_reverse" doesn't go with the rest of D's style. I also like the styles in which the order qualification is more visually linked to the array reference itself. Something along the lines of ... foreach( elem, array.order.fwd) foreach( elem, array.order.rev) foreach( elem, array.order.none) -- Derek (skype: derek.j.parnell) Melbourne, Australia "Justice for David Hicks!" 18/05/2007 10:09:43 AM |
May 18, 2007 Re: Ideas for shortening "foreach_reverse" (was Re: I have a suggestion.) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Derek Parnell | "Derek Parnell" <derek@nomail.afraid.org> wrote in message news:dabhxjbzr6ww$.1shkxsv5aswsm$.dlg@40tude.net... > I also like the styles in which the order qualification is more visually linked to the array reference itself. Something along the lines of ... > > foreach( elem, array.order.fwd) > foreach( elem, array.order.rev) > foreach( elem, array.order.none) > I agree. foreach(elem; array)(reverse) { ... } Though that somehow looks a little disconnected. foreach(elem; array; reverse) { } Hm. foreach(elem; array, "reverse") { } oops, there's some MiniD. ;) |
May 18, 2007 Re: Ideas for shortening "foreach_reverse" (was Re: I have a suggestion.) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | Jarrett Billingsley wrote: > Hm. > > foreach(elem; array, "reverse") > { > > } > > oops, there's some MiniD. ;) > /me slaps Jarret with a trout labeled "shameless self promotion" PS, try Enki. :p -- - EricAnderton at yahoo |
May 18, 2007 Re: Ideas for shortening "foreach_reverse" (was Re: I have a suggestion.) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | Sean Kelly wrote:
> Justin C Calvarese wrote:
>> YonggangLuo wrote:
>>> i think it's will be a good idea to replace "foreach_reverse" with "frr".
>>> "foreach_reverse" is too long as a keyword
>>
>> I agree that foreach_reverse is way too long for a keyword. Also, it has that unslightly underscore.
>>
>> I think that frr is a little too short. Since it's a keyword that will be rarely used, newcomers to D will likely get confused.
>>
>> I'm "voting" for foreachrev, but here's a whole list of decent alternatives to the current "foreach_reverse" mess:
>>
>> 1. foreachrev
>> 2. rforeach
>> 3. revforeach
>
> I still like:
>
> foreach - unordered?
> foreach(fwd) - explicitly forward
> foreach(rev) - explicitly reverse
> foreach(any) - unordered
>
>
> Sean
This has the additional benefit that when multi-processors become really common, D will have already built in a construct for parallelization...the any option. I suppose that one *could* add a "parallelize" option, but that could *only* be advisory, and as such any is just as good.
|
Copyright © 1999-2021 by the D Language Foundation