foreach on first/last (Was: Unofficial wish list status.)

Henning Hasemann hhasemann at web.de
Wed Feb 28 23:47:53 PST 2007


On Thu, 01 Mar 2007 00:14:14 -0500
Xinok <xnknet at gmail.com> wrote:

> On First / On Last, I'm thinking we could make use of the 'in' and 'out' 
> keywords for this, something like with functions:
> 
> foreach(arg; arr)
> in{
> }
> out{
> }
> body{
> }
> 
> for the 'in' block, arg[0] would be used.
> for the 'out' block, arg[length-1] would be used.

I dont think this would be a good idea since it would often
be confused with pre- and postconditions, so other names
like first{ } and last{ } would be better.

Henning



More information about the Digitalmars-d mailing list