Re: type hinting

From: Date: Fri, 04 Jan 2008 18:23:42 +0000
Subject: Re: type hinting
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-34438@lists.php.net to get a copy of this message
* the code gets smaller because not so many typechecks in every function
What do you mean "not so many"? You need one per checked parameter.
* because the code gets smaller it is faster executed (userspace typecheck is slower than "engine-space")
If you need single-opcode-level speedups, you probably better off to reimplement the same function in C. If we ever discover the speed of is_integer is a huge problem, we can make it an operator. However, I so far didn't see any evidence of that.
* with type hints byte code optimizer can optimize the code far better
Do you have any optimizer that can do that? Any plans to make one? Any tests showing you can optimize real-life application this way?
* with type hints static analysing tools that check for bugs/vulnerabilities can perform far better (intra procedural analysis gives more information)
That is true, type hints do make static analysis easier - strict typing is created exactly for that purpose. However, it only helps if all the code is strictly typed - otherwise you just move point of failure around. And in any case, type won't help you much form most real static analysis purposes, such as security - "string" can hold anything. -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com

« previous php.internals (#34438) next »