Menu

Late static binding

Status: shipped. How static:: is resolved at compile time through per-descendant method copies.

PHP's static:: resolves to the called class at runtime, not the class that lexically defines the method. Manticore has no runtime metadata and monomorphises aggressively, so LSB is implemented the same way: per-descendant method copies, the called class threaded as a compile-time scope and the right copy selected at each call site.

What it covers#

Mechanism#

For an LSB method M owned by class R, every strict descendant S of R gets a specialised copy named R__M__lsb<S> whose static:: resolves to S. The normal R__M copy serves the S == R case.

Cost & limits#

Edit this page on GitHub