Re: [RFC] Type hints (parameter and return value)

From: Date: Thu, 17 Apr 2008 17:14:32 +0000
Subject: Re: [RFC] Type hints (parameter and return value)
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-37092@lists.php.net to get a copy of this message
On Thu, 2008-04-17 at 10:06 -0700, Stanislav Malyshev wrote: > Hi! > > > The problem with this is that there's not much point in converting the > > value. PHP will do that anyway, making this kind of pointless. > > There would be a point since PHP might convert to different type that > you intended. Think of $foo = "My age is $age". If $age is supposed to > be int, then converting int hint might help. > > > Overall, I think type hinting should work by checking the type. If it > > does not match, raise an error. For example, int means int, not numeric > > string. > > What code scenario would make it necessary to distinguish between number > stored as string and number stored as binary? > > > This only serves to include an additional type juggling system into php, > > which is very confusing. > > There's already type juggling in PHP, and if you find it confusing, you > find whole PHP and whole set of dynamic languages very confusing. I > guess maybe C or Java would work better then :) I understand it very well, but why have a whole other system of type juggling? That would be duplicating type juggling functionality that's already in there.

« previous php.internals (#37092) next »