Prev | Current Page 871 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

The
developer will not usually use this class directly and may not even be aware of its existence because the
haXe environment treats it transparently.
Static Initialization
Every class can have a static method __init__() that is executed automatically before the main()
method invocation. Inside this method you cannot use the try / catch construct because the needed
declarations required to make the construct work may not be initialized yet. Another thing that requires
caution is to avoid using values from other static fields because their initialization is not guaranteed to
occur before the __init__ execution.
__resolve and __setfield
Every class that implements Dynamic automatically gains two magic methods: __resolve() and
__setfield() . The __resolve() method is auto - magically invoked each time that an inexistent
instance field is used. If the field is a method, it is probably a good practice to use __resolve to return
a function instead of a value. The returned function is then used to perform the proper action.


Pages:
859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883