On Jan 2, 1:33 am, jemptymethod <[email protected]> wrote:
> On Jan 1, 6:56 pm, RobG <[email protected]> wrote:
>
>
>
> > The use of $ may be Ok in ECMA-5, but it still grates with me. If you
> > want to be able to safely access "private" variables and objects, you
> > need privileged functions that are available externally.
>
> Which my "module" code plainly provides
>
>
>
> > > return (function() {
> > > $private.init();
> > > $public = {};
> > > return $public;
> > > })();
> > > })();
>
> > > var module = Module;
>
> > Which does nothing other than assign a reference to Module to module.
> > It doesn't execute anything, only built-in constructors can be called
> > that way when used with "new".
>
> Did you run the code? It absolutely executes. Please consider
> consulting another current thread entitled beginning "Immediately
> invoked
> function":http://groups.google.com/group/jsmentors/browse_thread/thread/44d80b9...
I'm quite certain he was referring specifically to:
var module = Module;
And no, it doesn't execute anything.
> $public.init logs to console, and you get back an object, albeit
> empty, since this is merely a template; you of course augment $public
> with the methods you would like to expose via the public interface.
Which would look like this according to your code:
$public = {
foo : function(){
return $private.state().something;
}
}
Seems a bit clunky with that function call.
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]