1
0
Fork 0

Removed 'Late Static Binding' section from documentation

- May be re-introduced in the future, but the documentation will have to be updated with the new implementation
closure/master
Mike Gerwitz 2011-05-31 22:31:58 -04:00
parent 557dcf6904
commit 9492a181f3
1 changed files with 0 additions and 78 deletions

View File

@ -1114,7 +1114,6 @@ implementation must be broken into two separate parts: properties and methods.
@menu @menu
* Static Methods:: * Static Methods::
* Static Properties:: * Static Properties::
* Late Static Binding:: Static members are not strictly static
* Constants:: Immutable static properties * Constants:: Immutable static properties
@end menu @end menu
@ -1221,83 +1220,6 @@ omitted. Consider the following example:
@caption{Static accessor method cannot be omitted} @caption{Static accessor method cannot be omitted}
@end float @end float
@node Late Static Binding
@subsection Late Static Binding
Static members in ease.js are not truly ``static''. Instead, the concept of
@dfn{late static binding} is adopted, which exists somewhere between static and
dynamic binding. Subclasses are free to override static members just as they
would non-static, similar to PHP's @var{static::}. This is in contrast to
languages like Java that support only hiding, not overriding, of static members.
Static members are not bound to the class when declared. Instead, the binding
takes place when a method is called. This late binding is the same type of
binding that occurs with non-static members. The term ``late static binding`` is
adopted rather than simply using ``dynamic binding`` because it is important to
make the distinction that the members are still bound in a static-like manner to
the class itself.
Because late static binding permits overriding static members, each @ref{Member
Visibility,level of visibility} is supported. To demonstrate what late static
binding implies, let's consider altering our example from @ref{f:static-ex}. We
will add an additional static method, @code{BigBang.create()}, which the factory
methods will use to instantiate the object. This will permit subtypes to
override the implementation. We will then create a subtype,
@var{UnstableBigBang}, which will create a big bang that's destined to create an
unstable and uninhabitable universe.
@float Figure, f:static-binding
@verbatim
var BigBang = Class( 'BigBang',
{
// ...
'public static fromBraneCollision': function( brane_set )
{
// do initialization tasks...
return this.create( 'brane', brane_set.getData() );
},
'protected static create': function( id, data )
{
console.log( 'New BigBang' );
return BigBang( id, data );
},
// ...
} ),
UnstableBigBang = Class( 'UnstableBigBang' ).extend( BigBang
{
'protected static create': function( id, data )
{
var bang = BigBang( id, data );
bang.doom();
console.log( 'BigBang is doomed.' );
return bang;
},
} )
;
BigBang.fromBraneCollision( brane_set );
// Output: New BigBang
UnstableBigBang.fromBraneCollision( brane_set );
// Output: BigBang is doomed.
@end verbatim
@caption{Demonstrating late static binding by overriding a static method}
@end float
Method @code{BigBang.fromBraneCollision()} calls static method @code{create()},
which is overridden by subtype @var{UnstableBigBang}. Because @var{this} is
bound when the method is called (``late''), rather than being statically bound
to the original @code{create()}, @code{UnstableBigBang.create()} is called. Had
ease.js implemented true static binding, the results would be similar to Java's
concept of static @emph{hiding}, which would cause ``New BigBang`` to be output
twice instead of ``BigBang is doomed''.
@node Constants @node Constants
@subsection Constants @subsection Constants
@dfn{Constants}, in terms of classes, are immutable static properties. This @dfn{Constants}, in terms of classes, are immutable static properties. This