A more dynamic runtime-based system is needed, one which permits a more modular style of code development for Javascript MAX-objects, and which provides a mechanism to support reusable code libraries. Browser-based Javascript permits the use of libraries (like Google Closure) via
<script src="">
tags that leverage the dynamic nature of an HTML document, but this has no real equivalent inside a MAX/MSP patch. The obvious model for file inclusion is the classic C #include file directive, but as there is no pre-processing system within MAX-Javascript, we need to construct an alternative. Fortunately, Javascript is capable of dynamic code evaluation, via
eval()
; unfortunately eval()
is incredibly slow and much frowned-upon.A useful file-inclusion system would be designed to achieve the following:
- simple syntax
- file inclusion relative to the 'main' code or to a given library location (as per C preprocessor)
- minimised
eval()
overhead - optimise to single eval
- remove re-eval of unchanged code
- dynamic control over inclusion mechanism
- possible compatibility with other methods (ie could be useable to override
goog.global.CLOSURE_IMPORT_SCRIPT
in Google Closure)
No comments:
Post a Comment