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/44d80b9e7cf3998a

$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.

Try this:

var module = Module;
console.log(module);

and then consult Firebug:

$private.init invoked
Object

> Variables starting with a capital letter are, by convention, reserved
> for constructors.

And modules

-- 
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]

Reply via email to