Prev: LibXML (XPATH) and escape
Next: Module name access
From: C.DeRykus on 27 Jan 2010 21:41 On Jan 27, 4:54 pm, "Uri Guttman" <u...(a)StemSystems.com> wrote: > >>>>> "CD" == C DeRykus <dery...(a)gmail.com> writes: > > CD> perl -e 'grep ++$_, -2..2' > CD> perl -e 'grep ++$_, [-2..2]' > > CD> grep appears to be creating a temp array in the former case instead > CD> of a list. > > the second line makes no sense as it is passing an array ref to grep. Oops, right, I meant: perl -we "print grep ++$_, @{[0..1]}" > ... -- Charles DeRykus
From: C.DeRykus on 27 Jan 2010 22:07 On Jan 27, 5:18 pm, Ben Morrow <b...(a)morrow.me.uk> wrote: > Quoth "C.DeRykus" <dery...(a)gmail.com>: > > > On Jan 27, 1:43 pm, Ben Morrow <b...(a)morrow.me.uk> wrote: > > > Quoth Jürgen Exner <jurge...(a)hotmail.com>: > > > > > "C.DeRykus" <dery...(a)gmail.com> wrote: > > > > >I prefer the for modifier but wish 'void' was a keyword for side- > > > > >effects only map use. > > > > Dear Lord no. That's as bad as the people who insist on casting > > > everything to (void) in C. Evaluating a function in void context is a > > > perfectly ordinary thing to do, so why does it need a redundant keyword? > > > I mentioned "crazies" but you're probably right. Rather than > > judicious use in cases like map to bridge changed semantics, > > it'd turn viral. > > There are no changed semantics, just an optimisation. Agreed, "bridge the optimization" would have been the correct wording. > > > > > Doesn't > > > > undef = map ..... > > > > work (I didn't try it)? > > > > No, that's scalar assignment, which gives scalar context to the RHS. At > > > runtime you get 'Modification of a read-only value attempted', of > > > course. > > > Ah. I suppose you could still signal map's only purpose were the > > side-effects with '() = map ...' (added keystrokes+slower though) > > That's a list assignment, so the RHS is in list context (it *is* > possible to try these things before posting, you know). > Um, I was addressing the broader issue of using map in scalar context without generating a LHS list. I *wanted* to suggest map could be put in list context and resultant list tossed to clarify that only the side-effects were of interest. -- Charles DeRykus
From: C.DeRykus on 27 Jan 2010 22:15 On Jan 27, 7:07 pm, "C.DeRykus" <dery...(a)gmail.com> wrote: > On Jan 27, 5:18 pm, Ben Morrow <b...(a)morrow.me.uk> wrote: > > ... > > > > > > > Doesn't > > > > > undef = map ..... > > > > > work (I didn't try it)? Ah, I think the above is attributed to me but I didn't say it. > > > > > No, that's scalar assignment, which gives scalar context to the RHS.. At > > > > runtime you get 'Modification of a read-only value attempted', of > > > > course. > > > > Ah. I suppose you could still signal map's only purpose were the > > > side-effects with '() = map ...' (added keystrokes+slower though) > > > That's a list assignment, so the RHS is in list context (it *is* > > possible to try these things before posting, you know). I see how the mis-attribution created more confusion now. > > Um, I was addressing the broader issue of using map in scalar > context without generating a LHS list. I *wanted* to suggest > map could be put in list context and resultant list tossed to > clarify that only the side-effects were of interest. And that's why I responded here in this vein. -- Charles DeRykus
From: Dr.Ruud on 28 Jan 2010 07:17
C.DeRykus wrote: > Ah. I suppose you could still signal map's only purpose were the > side-effects with '() = map ...' (added keystrokes+slower though) That would signal that you don't want map to optimize for void context. (map knows when it is in void context) -- Ruud |