D - foreach improvement suggestion
- pts+d math.bme.hu (14/14) Sep 15 2003 Dear All,
- Walter (6/19) Sep 15 2003 I understand the need for this, and I think I have a way to make it work...
Dear All,
I suggest an improvement over foreach on objects:
Now works: foreach (item; container) { ... }
Should be added: foreach (item; container_obj.apply1) { ... }
foreach (item; container_obj.apply2) { ... }
This way we could have iterators which iterate over only parts of the container:
-- hash.keys
-- hash.values
-- hash.pairs
-- file.lines
-- file.chars
I'd also like to suggest a syntax sugar: for and foreach could be synonyms, just
as in Perl.
pts
Sep 15 2003
<pts+d math.bme.hu> wrote in message news:bk4nbe$2dtt$1 digitaldaemon.com...Dear All, I suggest an improvement over foreach on objects: Now works: foreach (item; container) { ... } Should be added: foreach (item; container_obj.apply1) { ... } foreach (item; container_obj.apply2) { ... } This way we could have iterators which iterate over only parts of thecontainer:-- hash.keys -- hash.values -- hash.pairs -- file.lines -- file.charsI understand the need for this, and I think I have a way to make it work. Stay tuned!I'd also like to suggest a syntax sugar: for and foreach could besynonyms, justas in Perl.It makes it easier to parse them if they are separate.
Sep 15 2003








"Walter" <walter digitalmars.com>