How can I reference a closure using a string the same way I do it with a member function without using eval?
<p>We have some js code splitted in many files. We have a core file that defines code used by many other js files.</p>

<p>Currently we have something like this:</p>

<p>core.js:</p>

<pre><code>window.mycore = function() {

    var myfunction1 = function() {
    };
    var myfunction2 = function() {
    };
    var myfunction3 = function() {
        //..
        var a =  myfunction1(b);
        //..        
    };
    //...
    // many "myfunction"
    //...
    var myfunctionN = function() {
    };
    var publish = function() {
        for(var i = 0; i &lt; arguments.length; i++) {
            try {
                window.mycore[arguments[i]] = eval('(' + arguments[i] + ')');
            }
            catch(e) {
                Log.err(600, arguments[i], e);
            }
        }
    };
    publish("myfunction1", "myfunction7", "myfunction8",/*...*/"myfunctionM")
}
</code></pre>

<p>app.js:</p>

<pre><code>// ...
// ...
var result = window.core.myfunction1("myparam");
// ...
// ...
</code></pre>

<p>Note that none core methods are declared as members of the window.core object. Instead they are attached to the core object with the publish function.</p>

<p>This has some pros:</p>

<ul>
<li>The core code can reference any core function without the need of writing "window.core."</li>
<li>We avoid writing "var myfunction = window.mycore.myfunction = function() ..." in every public function declaration</li>
<li>The exposed methods can be seen centraliced.</li>
</ul>

<p>But, the use of eval in the publish function is bringing us problems when using code analysis tools since they don't tend to understand eval declarations.</p>

<p>So, here is my question.
Which is the better way to improve this code, so we can keep the advantages mentioned but  eradicating the eval declaration.
I am aware of the solution of sending to the publish function some name/value pairs like publish({'myfunction1': myfunction1}, ... ), but I also want to avoid function name repetitions.
Consider that I am not looking for radical changes since there is a lot of code written already.</p>

<p>Thanks!</p>
