Re: Type hinting - Request for Discussion
| From: | Josh Thompson | Date: | Fri, 10 Jul 2009 01:03:34 +0000 |
| Subject: | Re: Type hinting - Request for Discussion | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-44888@lists.php.net to get a copy of this message | ||
troels knak-nielsen wrote:
I would much rather be explicit with a different syntax, that way we don't have to add a new set of resolution rules. For example what would this do to autoload? Would we have to call it to see if the class is available every time? I think the function syntax disambiguates things and hints at what is happening.- How do you know if it is a contract or the current object type hint?The simplest solution would be to make one take precedence. You're not likely to have both a class and a function with the same name, and if you do, you kind of had it coming to you. For backwards compatibility it would probably be most fitting to let the current behaviour (class/interface) take precedence, although the other way around makes for some quite interesting possibilities.
I can concede on this point. I just thought there might be some reason you would need it in a specific type, but none are coming to mind... -- Joshua Thompson Mechanical Engineer/Software Developer http://www.schmalls.com- It doesn't allow a type to be forced (casted) to the correct type.As far as I can tell, this is a moot point. The whole discussion about casting comes from the fact that hinting to a primitive type is more restrictive than php's weak typing system. With a contract system this problem doesn't exist. You could test that something conforms to your specifications and then simply let the type system do its thing.