On Fri, Oct 25, 2002 at 06:28:28PM -0400, Miko O'Sullivan wrote:
> From: "Larry Wall" <[EMAIL PROTECTED]>
> > :      ?   - force to bool context
> > :      !   - force to bool context, negate
> > :      +   - force to numeric context
> > :      -   - force to numeric context, negate
> > :      ~   - force to string context
> >
> > We're obviously missing the "force to string context, negate" operator.
> :-)
> 
> Mr. Wall, may I be excused?  My brain is full.  Oh, I have to stick it out
> with everyone else? OK, um....
> 
> Just so I understand... why do we need "force to blah context" operators at
> all?  Are we planning on doing a lot of context forcing?  Isn't "a lot of
> context forcing" mean that the context concept isn't working? Nay, say I.  I
> think context will continue to work.  Which means... maybe we don't need all
> that shorthand.  I've been quite happy with the scalar function in Perl5.
> What if we just had a few more functions like that for the occasional
> context forcing, or even just one "context" function that takes a context
> name as the first argument.

The negate operators we have already:

perl -e '$x = "0"; print !$x'
perl -e '$x = "10.000"; print -$x'

The others save use doing:

perl -e '$x = "2"; print !!$x'
perl -e '$x = "10.000"; print -(-$x)'
perl -e 'print "" . localtime'

OK, Perl 5 doesn't have all these contexts, and these may be not the
most compelling of examples, but you get the idea.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

Reply via email to