----- Original Message -----
From: "Paul Johnson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, December 03, 2002 5:13 PM
Subject: Re: a Bug in PERL


>
> PRADEEP GOEL said:
> >
> > ----- Original Message -----
> > From: "Paul Johnson" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Cc: <[EMAIL PROTECTED]>
> > Sent: Monday, December 02, 2002 5:01 PM
> > Subject: Re: a Bug in PERL
> >
> >
> >>
> >> PRADEEP GOEL said:
> >> > If i am not wrong somewhere , there is a bug come to my notice , in
> >> PERL
> >> >
> >> > @lastnotpop =
> >> ("where_gone_me","remaining_is_alright","no_fear_now"); foreach
> >> $faltu (@lastnotpop)  #$faltu is extra doesn't makes difference even
> >> if removed
> >> > { $pch = pop(@lastnotpop );
> >> >  print " \n  can't pop last  one from @lastnotpop
> >> i.e.($lastnotpop[0] )
> >> > :
> >> > popped element is  $pch #";
> >> >  }
> >> > If there are more than one elemnt in a array(say @lastnotpop  than
> >> the last/first element i.e.
> >> > $lastnotpop[0]  can't be popped out in this single foreach loop.
> >> >
> >> > I don't think it's intensional feature , else it should also not be
> >> able to pop the only
> >> > element , if it has one , but it does.
> >>
> >> This is a case of "Doctor, it hurts when I ...".
> > lllllllllllllllllllll  I haven't heard about this case
> >  do u mean when " i strike at some wrong place "
>
> I suppose so.
>
> Patient:  Doctor, it hurts when I raise my arm.
> Doctor:   Well, don't do that then
$$$$$$$$$$$  patient : - well then come to my home & do my  jobs where arm
raising is needed ..

>
> >> If you look in perlsyn, under the heading "Foreach Loops", you will
> >> see:
> >>
> >>   If any part of LIST is an array, C<foreach> will get very confused
> >> if you add or remove elements within the loop body, for example with
> >> C<splice>.   So don't do that.
> > llllllllllllllllllll -  whether C<foreach>  will get confused or not ,
> > but i have already,
> > since this is a common procedure , in any programming language to remove
> > /add elements
> > of an array in a loop .
>
> Yes, but not the array over which you are iterating.
$$$$$$$$$ in NO case a language changes its behaviour for an array with 1
element
& the same code with array of 2 or more elements ( what the PERL is doing
here )
it does pops out if last element also happens to be the only element of
array.
>
> I am unclear as to what your posted code should do.  I can think of a
> number of interpretations.  Perl says that this behaviour is undefined.
> This means that it doesn't need to give a (possibly arbitrary)
> interpretation and allows the implementation the flexibility to be coded
> for speed.
>
> >  & also that any programming language must follow some sure mathematical
> > rules & should not get confused .
>
> The rule is "don't do that".  Most languages have rules like that for
> various situations.  In C, for example, a statement such as i = i++ is
> unedefined behaviour.  The compiler may do what it will with that
> statement and the whole program.
>
$$$$$$$$$certainly a prog language is implemented by a compiler/interpreter
& they follow the mathematical rules ,
i =i++ will too have the same behaviour for two differnt two same kind of
variales( may be arrays)
by same compiler

BRIEF ///////////////////////////////////////////
I don't think any language defines two different behaviour anywhere at any
place for
either two arrays with different no of elements nor for any two variables of
same type
at same place,same compiler  ( say continuous in a program)
That's why it seems to be a  BUG
> --
> Paul Johnson - [EMAIL PROTECTED]
> http://www.pjcj.net
>
>
>
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to