On Fri, 2008-01-04 at 13:02 -0500, Robert Cummings wrote: > On Fri, 2008-01-04 at 12:51 -0500, Sam Barrow wrote: > > On Fri, 2008-01-04 at 12:48 -0500, Robert Cummings wrote: > > > On Fri, 2008-01-04 at 12:41 -0500, Sam Barrow wrote: > > > > On Fri, 2008-01-04 at 12:37 -0500, Robert Cummings wrote: > > > > > On Fri, 2008-01-04 at 18:23 +0100, Pierre wrote: > > > > > > On Jan 4, 2008 6:20 PM, Marcus Boerger <[EMAIL PROTECTED]> wrote: > > > > > > > Hello Pierre, > > > > > > > > > > > > > > we never accepted this as a pro argument. Infact we often saw > > > > > > > the > > > > > > > necessaity to highlight something is optional to vote against it. > > > > > > > We do this > > > > > > > for a reason. That is we only want to support mainstream features. > > > > > > > > > > > > My point of view is that this feature should be a mainstream > > > > > > feature. > > > > > > To make it optional was to lower the issues for those who don't care > > > > > > about argument strictness. We did not give them this choice for the > > > > > > OO > > > > > > strictness. > > > > > > > > > > IMHO, optionally inclusion of type hinting for functions/methods can > > > > > only be a boon to code quality and readability. IMHO when a type hint > > > > > is > > > > > provided and a parameter doesn't match the type hint then I think a > > > > > fatal error should occur. This forces the user of the function that > > > > > has > > > > > type hinting to ensure their data is of the correct type. This > > > > > prevents > > > > > accidental wrong data conversion. However, I see the other side of the > > > > > coin too where automatic type conversion could be desirable also. > > > > > Perhaps a mixed solution would be viable? > > > > > > > > > > > > > I don't think conversion would make sense here, as PHP will > > > > automatically convert the variable before you use it anyway. Hinting > > > > will prevent mistakes, conversion will just try to ignore them, which is > > > > what PHP does already. > > > > > > I think that depends on what I do with the variable. PHP doesn't know > > > how I intend to use it, and if I know I want an int and I don't want to > > > test for browserland garbage in my variable everytime the function is > > > called, then an automatic type conversion to int for my function can > > > make perfect sense. Yes, I could force the developer using my function > > > to cast the parameter as an int, but I'm certain conversion in the > > > engine without a userland cast is faster, and it makes it more > > > convenient to the consumer of my function since they can still treat it > > > like a classic function. > > > > Yes, but whatever you do with it (echo, store in db, etc.) PHP will > > perform its default conversion routine for the variable type. You have a > > point though, this is something that I've actually been debating for > > some time: > > > > function a(int $a, cast int $b) { > > > > } > > > > $a must be an int > > $b will be cast to an int > > Yes, that makes more sense since it brings things in line with the > current semantics for array/object type hinting. > > > I just think this is getting a little bit too complicated. Many people > > on here are resistant enough to scalar type hinting because they say > > it's confusing, they'll definitely be even more resistant to something > > like this. > > It's funny sometimes the complaints about too complicated. I mean, if > people don't want to use a "complicated feature" then they shouldn't. I > don't think cutting the legs out from developers who want to use said > features is the solution. I mean we're all programmers around here... is > it really that complicated? Required paraneter types, automatic > parameter casting, and ad-hoc paramets types? :)
I agree with you 100% here, I just don't think the PHP development team is going to be wiling to implement it, since they are very big on keeping it easy for beginners. I agree with you 100% though, I'm just saying that in the situation it's probably not going to happen. > Cheers, > Rob. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php