Re: Scalar type hinting

From: Date: Thu, 01 Mar 2012 01:56:16 +0000
Subject: Re: Scalar type hinting
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19  Groups: php.internals 
Request: Send a blank email to internals+get-58380@lists.php.net to get a copy of this message
On Wed, Feb 29, 2012 at 8:46 PM, Kris Craig <kris.craig@gmail.com> wrote: > I was thinking something more along the lines of simply throwing an error > if, say, (int) $a != $a.... *if *$a is defined as an integer. > > --Kris > > > On Wed, Feb 29, 2012 at 5:16 PM, John Crenshaw <johncrenshaw@priacta.com > >wrote: > > > > -----Original Message----- > > > From: Kris Craig [mailto:kris.craig@gmail.com] > > > > > > @Richard I think you made a very good point. Should we treat a float > => > > int mismatch the same as we would a string => int mismatch, or should the > > former fail more gracefully? I can see good arguments for both. > > > > > > --Kris > > > > I'm beginning to think that the type hinting question is too closely > > related to the dirty secrets of type juggling to resolve them separately. > > You may have to either discard consistency, or else fix the problem of > > silent bizarre conversions at the same time ('foo'==0, '123abc'=123). > > Fixing the conversions is a BC break though. > > > > John Crenshaw > > Priacta, Inc. > > > John raises some real concerns about the relation of hinting and juggling. I'm wondering about allowing developers to declare type intentions (I'll post an idea in a separate thread.) Adam

« previous php.internals (#58380) next »