![]() ![]() Thereâs a separate, small way in which references are bad for performance: accessing a variable that is a reference requires an additional pointer dereference, compared to accessing a regular variable. This problem is even worse with references, which is why Hack simply ignores them. As we saw in âInference on Propertiesâ, the typechecker must be very conservative with its inference around object properties, because there are so many ways to act upon properties at a distance. This makes it impossible to ensure type safety around references, and difficult to execute code around them efficiently.Īnother example of âaction at a distanceâ making type inference difficult is the problem of object properties. Passing a variable to a function by reference means that anything can happen to that variable, and the typechecker has no way of knowing what it is (because type inference is function-local, as described in âInference Is Function-Localâ). They allow the possibility of âaction at a distance,â where innocuous-looking code can have unknowable effects. References make it very difficult to do sound static analysis. They are a cross-sectional language feature: they have a deep influence on how PHP engines represent program values, on how variables are handled, on function call and return mechanisms, and on memory management. Of the features that Hack doesnât support, references are the most fundamental. ![]() Once more, to be clear: HHVM supports all of these features when running regular PHP code. If youâre simply looking to get started with Hack, itâs enough to skim the section headers of this chapter. In this chapter, weâll explore these unsupported features, analyzing why they are hard or impossible to implement static type analysis for and why theyâre hard to compile into efficient native code. ![]() PHP code that uses a feature absent from Hack can still interoperate seamlessly with Hack code. When HHVM is running PHP code (i.e., code in any file with
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |