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

From: Date: Fri, 18 Apr 2008 08:03:41 +0000
Subject: Re: [RFC] Strict type hints (parameter and return value)
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-37129@lists.php.net to get a copy of this message
On Fri, Apr 18, 2008 at 9:03 AM, Lukas Kahwe Smith <mls@pooteeweet.org> wrote: > Suddenly I need to ensure that all my variables have the proper types. So > what will people do? > .... > So maybe an "(int)" here or there > is not so much more code to type, but you can already see that code you safe > on one end, you have to start adding on the other, the one which you write > more often. You are right, of course. I stated before that the hints automatically casting the parameter is the best approach. With automatic casting, which seems to be fairly obvious semantics for type hints, you will not need to cast at call-time. > More importantly, in some cases simple type juggeling with > "(int)" will not be sufficient, you might have to do some minor checks etc. > In the past library authors did this as part of the code that the strict > type hinting camp is now hoping to remove. So again more code in my glue > code. There isn't a strict typing camp. Felipe's first patch was just checking, which didn't provide any guarantees to the library author. The second was strict typing, which provides guarantees, as you say, at great expense. I am hoping that the third will be casting, which provides guarantees, at no call-time expense. Paul -- Paul Biggar paul.biggar@gmail.com

« previous php.internals (#37129) next »