Can I implement group typing in PHP?
I'm not sure whether it's called group typing, but what I mean is this:
Since PHP is dynamically typed, this adds delays which is understandable. Is it possible to create some kind of type system in PHP so that
ints,floats and other numeric values can be grouped under Number , as well as开发者_如何转开发 grouping of other types to increase runtime speeds so that if a variable is of type Number, at runtime, PHP can just quickly only check through that group without even testing if its a string or some other type.
Is this possible, or am I completely missing something here?
You're missing something. Numbers and strings aren't objects in PHP -- they're a distinct type of value, which is already handled more or less in the way that you describe.
You simply can't do that in PHP, the language doesn't have that kind of tools.
精彩评论