No, you should not do this: "new M.core_comment(options);" and {M.core_component.init == function()} at the same time, it is even worse than before. There are two ways to make these API:
1/ everything method static + some shared storage - this is how we did it actually in 1.9, and many areas will still do that in 2.0; it may not seem nice but at least it is very easy to understand for ppl without extensive knowledge of OOP and ppl that know more strict languages like Java. Please note that M.util.* will be all "static" sharing M.cfg
2/ the second way is to add instances of objects to M hierarchy on the fly. It is possible only at lower level, I do not like it at all at the second level, in your case the M.core_component.
The there is the documentation problem, in order to create nice JS Docs from our code we need so code in some "parse-able" way, these anonymous classes and instances might not help much.
Looking at your last c.js it looks to me like self modifying machine code:
1/ M.core_comment is a function that defines new class
2/ then it creates instance of that class and assigns it to self
3/ then you somehow inject static init method in in between 1/ and 2/
Is this really what you want to encourage all over the moodle codebase? I am personally having problems understanding that. I would definitely be amazed when I would saw this when I was starting with JS.
Why not simply do:
1/ M.core_comment.CommentManager - class definition
2/ M.core_comment.init(options) - does "new M.core_comment.ComponentManager(options)", each instance handles one block with comments
3/ from PHP use $PAGE->requires->js_funtion_call('M.core_comment.init', array($options1), 'core_comment'); $PAGE->requires->js_funtion_call('M.core_comment.init', array($options2), 'core_comment');
(My code in cvs now does this with exception that CommentManager class is created on the fly in local function scope only (can not be documented automatically), hmm, I am wondering how the garbage collection works in browsers, the instance is hanging in the air, only event handlers make it accessible from the outside, but it looks like it is enough).
Other plugins that just need to init page layout will also use $PAGE->requires->js_funtion_call('M.mod_forum.init_view', array(), 'mod_forum');, of course we could also use some $PAGE->requires->js_new_object($classname, $args, $modulename), but I would personally prefer the unified js_function_call() everywhere
+1 cool! Is there anything in the filepicker that is not in YUI3 ?