Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re: foreach my Dog $spot (...) {...} #566

Closed
p5pRT opened this issue Sep 20, 1999 · 10 comments

Comments

@p5pRT
Copy link
Collaborator

@p5pRT p5pRT commented Sep 20, 1999

Migrated from rt.perl.org#1418 (status was 'resolved')

Searchable as RT1418$

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Sep 20, 1999

From The RT System itself

NOTE​: I'm not saying this should be implemented in perl5.006, so TomC you
  can sit down... :-)

Two forms​:

  for my(a, b, c) (a1, b1, c1, a2, b2, c2, ...) {
  }

and​:

  for my(a, b, c) (a1, a2, ...) (b1, b2, ...) (c1, c2, ...) {
  }

They are actually unambiguous... :-) As a simplification​:

  for my(a) (a1, a2, ...) {
  }

Is just a simplification of both of the above... :-)

mark

--
markm@​nortelnetworks.com/mark@​mielke.cc/markm@​ncf.ca __________________________
. . _ ._ . . .__ . . ._. .__ . . . .__ | CUE Development (4Y21)
|\/| |_| |_| |/ |_ |\/| | |_ | |/ |_ | Nortel Networks
| | | | | \ | \ |__ . | | .|. |__ |__ | \ |__ | Ottawa, Ontario, Canada

  One ring to rule them all, one ring to find them, one ring to bring them all
  and in the darkness bind them...

  http​://mark.mielke.cc/

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Sep 20, 1999

From The RT System itself

How does the extension go?

  for my(Dog $dog, Cat $cat) (@​list_of_alternating_dog_cats) {
  ...
  }

mark (who has only wished for such a syntax once every 3 months or less)

--
markm@​nortelnetworks.com/mark@​mielke.cc/markm@​ncf.ca __________________________
. . _ ._ . . .__ . . ._. .__ . . . .__ | CUE Development (4Y21)
|\/| |_| |_| |/ |_ |\/| | |_ | |/ |_ | Nortel Networks
| | | | | \ | \ |__ . | | .|. |__ |__ | \ |__ | Ottawa, Ontario, Canada

  One ring to rule them all, one ring to find them, one ring to bring them all
  and in the darkness bind them...

  http​://mark.mielke.cc/

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Sep 20, 1999

From The RT System itself

I don't like that one as much - the most common use I have for this
is

  foreach my ($key,$value) (%hash)
or
  foreach my ($option,$value) (@​_)

Tuomas
--
Nick Ing-Simmons <nik@​tiuk.ti.com>
Via, but not speaking for​: Texas Instruments Ltd.

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Sep 20, 1999

From The RT System itself

On Thu, 16 Sep 1999, Mark Mielke wrote​:

On Thu, Sep 16, 1999 at 10​:19​:06AM -0700, "Larry Wall" wrote​:

Michael G Schwern writes​:
: So, any reason why​: foreach my Dog $spot (...) {...} shouldn't work?
Seems reasonable to me. Especially since we might get tremendous
compiler speedups out of
for my int $i (1 .. 1_000_000) { }

How does the extension go?

for my(Dog $dog, Cat $cat) (@​list_of_alternating_dog_cats) {
...
}

for my(Dog $dog, Cat $cat) (@​list_of_dogs) (@​list_of_cats) {
}

  Tuomas

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Sep 20, 1999

From The RT System itself

I find myself having to do​:
  package Class;
  use fields qw(foo bar);

  sub new { bless [] }
 
  package main;

  my Class $this = Class->new;
  my Class $that = Class->new;

  foreach ($this, $that) {
  my Class $obj = $_;
  # etc...
  }

foreach my Class $obj ($this, $that) { would be much simpler. Alas,
this requires a toke/lex patch, which is waaaay outside of my
skillset. :(

--

Michael G Schwern schwern@​pobox.com
  http​://www.pobox.com/~schwern
  /(?​:(?​:(1)[.-]?)?\(?(\d{3})\)?[.-]?)?(\d{3})[.-]?(\d{4})(x\d+)?/i

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Apr 22, 2003

@iabyn - Status changed from 'stalled' to 'resolved'

@p5pRT p5pRT closed this Apr 22, 2003
@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Apr 22, 2003

@iabyn - Status changed from 'stalled' to 'resolved'

3 similar comments
@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Apr 22, 2003

@iabyn - Status changed from 'stalled' to 'resolved'

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Apr 22, 2003

@iabyn - Status changed from 'stalled' to 'resolved'

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Apr 22, 2003

@iabyn - Status changed from 'stalled' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.