Change 19729 by [EMAIL PROTECTED] on 2003/06/09 19:13:16 Subject: [PATCH] Re: nitpick with \(0..2) From: Steve Grazzini <[EMAIL PROTECTED]> Date: Fri, 6 Jun 2003 01:42:59 -0400 Message-ID: <[EMAIL PROTECTED]>
Affected files ... ... //depot/perl/op.c#572 edit ... //depot/perl/pod/perlop.pod#113 edit ... //depot/perl/t/op/ref.t#19 edit Differences ... ==== //depot/perl/op.c#572 (text) ==== Index: perl/op.c --- perl/op.c#571~19694~ Thu Jun 5 11:37:02 2003 +++ perl/op.c Mon Jun 9 12:13:16 2003 @@ -2009,6 +2009,8 @@ o->op_type = OP_RV2AV; o->op_ppaddr = PL_ppaddr[OP_RV2AV]; + o->op_flags &= ~OPf_REF; /* treat \(1..2) like an ordinary list */ + o->op_flags |= OPf_PARENS; /* and flatten \(1..2,3) */ o->op_seq = 0; /* needs to be revisited in peep() */ curop = ((UNOP*)o)->op_first; ((UNOP*)o)->op_first = newSVOP(OP_CONST, 0, SvREFCNT_inc(*PL_stack_sp--)); ==== //depot/perl/pod/perlop.pod#113 (text) ==== Index: perl/pod/perlop.pod --- perl/pod/perlop.pod#112~19493~ Sun May 11 12:13:00 2003 +++ perl/pod/perlop.pod Mon Jun 9 12:13:16 2003 @@ -418,10 +418,10 @@ =head2 Range Operators Binary ".." is the range operator, which is really two different -operators depending on the context. In list context, it returns an +operators depending on the context. In list context, it returns a list of values counting (up by ones) from the left value to the right value. If the left value is greater than the right value then it -returns the empty array. The range operator is useful for writing +returns the empty list. The range operator is useful for writing C<foreach (1..10)> loops and for doing slice operations on arrays. In the current implementation, no temporary array is created when the range operator is used as the expression in C<foreach> loops, but older ==== //depot/perl/t/op/ref.t#19 (xtext) ==== Index: perl/t/op/ref.t --- perl/t/op/ref.t#18~19300~ Mon Apr 21 12:42:04 2003 +++ perl/t/op/ref.t Mon Jun 9 12:13:16 2003 @@ -200,14 +200,14 @@ # test the \(@foo) construct # package main; [EMAIL PROTECTED] = (1,2,3); [EMAIL PROTECTED] = \(1..3); @bar = \(@foo); @baz = \(1,@foo,@bar); print @bar == 3 ? "ok 39\n" : "not ok 39\n"; print grep(ref($_), @bar) == 3 ? "ok 40\n" : "not ok 40\n"; print @baz == 3 ? "ok 41\n" : "not ok 41\n"; -my(@fuu) = (1,2,3); +my(@fuu) = \(1..2,3); my(@baa) = \(@fuu); my(@bzz) = \(1,@fuu,@baa); print @baa == 3 ? "ok 42\n" : "not ok 42\n"; End of Patch.