Re: Apropos of nothing...

2001-12-21 Thread Piers Cawley
Resending due to BT doing bad things to good nameservers. Damian Conway <[EMAIL PROTECTED]> writes: >> >$val = (foo())[0]; >> > >> > List? >> >> Scalar, obviously. > > How do you figure that? (Not a criticism: I'd really like to understand your > thought process her

Re: Apropos of nothing...

2001-12-20 Thread Piers Cawley
Damian Conway <[EMAIL PROTECTED]> writes: >> >$val = (foo())[0]; >> > >> > List? >> >> Scalar, obviously. > > How do you figure that? (Not a criticism: I'd really like to understand your > thought process here so I can assess the relative DWIMity of the two > alternat

Re: Apropos of nothing...

2001-12-20 Thread Damian Conway
Aaron Sherman wrote: > >> $ref = [1,2]; > >> @ary[$ref] = foo(); # probably a syntax error > > Ok, as far as I can recall, Larry hinted that arrays and references to > arrays would be interchangable in many contexts in P6. In this case, I > can't see any reason that subscripting wou

Re: Apropos of nothing...

2001-12-20 Thread Damian Conway
> > $val = (foo())[0]; > > > > List? > > Scalar, obviously. How do you figure that? (Not a criticism: I'd really like to understand your thought process here so I can assess the relative DWIMity of the two alternatives). > With a possible runtime error if foo doesn't ret

Re: Apropos of nothing...

2001-12-20 Thread Piers Cawley
Aaron Sherman <[EMAIL PROTECTED]> writes: > On Sun, Dec 16, 2001 at 03:55:10PM +1100, Damian Conway wrote: > > [...] > >>> And, just for laughs: >>> >>> $ref = [1,2]; >>> @ary[$ref] = foo(); # probably a syntax error > > Ok, as far as I can recall, Larry hinted that arrays a

Re: Apropos of nothing...

2001-12-20 Thread Aaron Sherman
On Sun, Dec 16, 2001 at 03:55:10PM +1100, Damian Conway wrote: [...] >> And, just for laughs: >> >> $ref = [1,2]; >> @ary[$ref] = foo(); # probably a syntax error Ok, as far as I can recall, Larry hinted that arrays and references to arrays would be interchangable in many

Re: Apropos of nothing...

2001-12-15 Thread Damian Conway
Piers posed the following puzzles: > @ary[0] = foo() # scalar Yes. > @ary[1,2] = foo() # list context Yes. > @bar = 1; > @ary[@bar] = foo() # ? probably list or maybe scalar... List. With an explicit array as index, it's definitely a (one-element) slice. > @bar = (1,

Re: Apropos of nothing...

2001-12-13 Thread Piers Cawley
"Brent Dax" <[EMAIL PROTECTED]> writes: > Piers Cawley: > # In the following code fragment, what context is foo() in? > # > # @ary[0] = foo() > > The short answer is scalar context. The long answer is below. Note > that the long answer is only the way I think of it. You may think > differe

Re: Apropos of nothing...

2001-12-13 Thread Damian Conway
> > @ary[0] =()= foo(); # " " " " " "" " > > Hm, thats a change from perl5. In perl5 that would assign the number of > elements returned from foo(). Is there a good reason for this change ? Firstly, Larry may have to rule on which behaviour actually *is*

Re: Apropos of nothing...

2001-12-13 Thread Graham Barr
On Fri, Dec 14, 2001 at 06:39:02AM +1100, Damian Conway wrote: > >> In the following code fragment, what context is foo() in? >> >> @ary[0] = foo() > > Scalar context. @ary[0] is a single element of @ary. > > To call foo() in list context use any of the following: > > (@

Re: Apropos of nothing...

2001-12-13 Thread Bart Lateur
On Thu, 13 Dec 2001 12:17:44 -0500, Mark J. Reed wrote: > @i = (0); > @ary[@i] = foo(); > >How could one get that behavior without the intermediate array? Parens, likely. (@ary[0]) = foo(); -- Bart.

Re: Apropos of nothing...

2001-12-13 Thread Damian Conway
> In the following code fragment, what context is foo() in? > > @ary[0] = foo() Scalar context. @ary[0] is a single element of @ary. To call foo() in list context use any of the following: (@ary[0]) = foo(); # Assign @ary[0] the first element returned @(@ary[

RE: Apropos of nothing...

2001-12-13 Thread Brent Dax
Piers Cawley: # In the following code fragment, what context is foo() in? # # @ary[0] = foo() The short answer is scalar context. The long answer is below. Note that the long answer is only the way I think of it. You may think differently. I like to think of it as 'one context'. 'Scalar'

Re: Apropos of nothing...

2001-12-13 Thread Mark J. Reed
On Thu, Dec 13, 2001 at 12:12:14PM -0500, Ted Ashton wrote: > Thus it was written in the epistle of Piers Cawley, > > In the following code fragment, what context is foo() in? > > > > @ary[0] = foo() > > Scalar, I would think. I assume that the following would make the assignment a slice an

Re: Apropos of nothing...

2001-12-13 Thread Ted Ashton
Thus it was written in the epistle of Piers Cawley, > In the following code fragment, what context is foo() in? > > @ary[0] = foo() Scalar, I would think. Just my guess, Ted -- Ted Ashton ([EMAIL PROTECTED]) | From the Tom Swifty collection: Southern Adventist University| "Multiplicati

Apropos of nothing...

2001-12-13 Thread Piers Cawley
In the following code fragment, what context is foo() in? @ary[0] = foo() the following code @ary= foo() obviously evaluates @foo in a list context, but in the first I'm no longer sure. -- Piers "It is a truth universally acknowledged that a language in possession of a ri