develooper Front page | perl.perl5.porters | Postings from January 2011

Re: Changing variable to numeric without assignment (was: Usingsmart matching)

Thread Previous | Thread Next
From:
Abigail
Date:
January 28, 2011 04:14
Subject:
Re: Changing variable to numeric without assignment (was: Usingsmart matching)
Message ID:
20110128121415.GG8853@almanda
On Fri, Jan 28, 2011 at 01:00:23PM +0100, Zsbán Ambrus wrote:
> On Fri, Jan 28, 2011 at 12:59 AM, Jan Dubois <jand@activestate.com> wrote:
> > I would agree with this (caching converted representations should not
> > be detectable at the language level).  Unfortunately some operations
> > are *documented* to behave otherwise:
> >
> > |       The auto-increment operato
> >
> > (From perlop.pod; note the phrase "used in a numeric context")
> >
> > Personally I consider these design mistakes, but I also don't think we
> > can undo them anymore either.  Just some of the warts we have to live
> > with.
> 
> Can we at least collect a list of operations that care here on the
> mailing list, for reference?  The ones I know about are the increment
> operator (++), the range operator (.. ...), and the bitwise operators
> (& | ^) which all care about whether the scalar has been used as a
> number.
> 


And the operator that started this thread: ~~

  $perl -E '$a = "1"; say "1: ", "1 x" ~~ $a; 0 + $a; say "2: ", "1 x" ~~ $a'
  1: 
  2: 1
  $


Abigail

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About