PugsBugs: Weird behavior of shift

2 views
Skip to first unread message

Stevan Little

unread,
Apr 18, 2005, 12:08:36 AM4/18/05
to perl6-c...@perl.org
These examples:

pugs -e 'say shift [1, 2, 3].shift'
pugs -e 'say shift([1, 2, 3].shift)'
pugs -e 'say shift([1, 2, 3]).shift'

do not ever return, but yet does not seem to chew up the CPU either.

Meanwhile, these examples:

pugs -e 'say pop [1, 2, 3].pop'
pugs -e 'say pop([1, 2, 3].pop)'
pugs -e 'say pop([1, 2, 3]).pop'

all print '3'.

Just a weird one, I thought I would share it. I am not even sure it is
really a bug to be honest (other than the fact it does not seem to
return).

Stevan

Larry Wall

unread,
Apr 18, 2005, 10:18:29 AM4/18/05
to perl6-c...@perl.org
On Mon, Apr 18, 2005 at 12:08:36AM -0400, Stevan Little wrote:
: These examples:

:
: pugs -e 'say shift [1, 2, 3].shift'
: pugs -e 'say shift([1, 2, 3].shift)'
: pugs -e 'say shift([1, 2, 3]).shift'
:
: do not ever return, but yet does not seem to chew up the CPU either.

I don't see how those can be semantically valid, even if they parse.
I read them as shifting the return value of a shift, which would
be an attempt to shift on a scalar.

: Meanwhile, these examples:


:
: pugs -e 'say pop [1, 2, 3].pop'
: pugs -e 'say pop([1, 2, 3].pop)'
: pugs -e 'say pop([1, 2, 3]).pop'
:
: all print '3'.

Same problem. 3.pop doesn't mean much. All I can figure is that
it's following the list-in-scalar context rule to make [3].pop
out of it.

Larry

Reply all
Reply to author
Forward
0 new messages