[Proto-Scripty] Re: local variables for for() array iteration

2011-01-20 Thread RobG


On Jan 20, 4:50 pm, Ran Berenfeld  wrote:
> Thank you for the advise.
> one more / last question to clarify.
> In one of the articles about javascript scopes I read that using "var"
> inside a class constructor actually
> creates a "private member" of the class. is it true ?

No. There are no classes in ECMAScript. Functions can be called using
the new keyword to use them as constructors. Various patterns can be
used in ECMAScript to emulate features of classic object inheritance.

The var keyword is used to keep the scope of a variable to the
execution context that it is declared within (ECMAScript only has
function level scope).

It has a role in emulating "private members" but does not do so by
itself. The pattern most commonly used is Richard Cornford's module
pattern:




> if this is true,

It isn't.

> then should I avoid using
> for (var i=0;i like statements inside a class constructor ?

A consequence being that every variable inside your constructor will
become a global variable when the statement assigning to them is
executed (which will be after the constructor is called).

> because then "i" would become a
> class member,
> and then using "var i" inside class function is not safe.
>
> am I right ?

No.

--
Rob

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



[Proto-Scripty] PureMVC port to Prototype

2011-01-20 Thread Tekool
For those who already heard of the well known PureMVC framework at
www.puremvc.org, you will probably be interested in that I ported
PureMVC to Prototype. The port include Unit Tests and has been proved
flawless but I will probably soon create a working demo for it with
some complex Prototype UI components.

URL of my blog post announcing the port :
http://www.tekool.net/blog/2011/01/19/puremvc-port-to-prototype-javascript-framework/

If some of you have time to check that the syntax and notation
convention I used are good, thank to report this as a comment on the
blog post, I'm not sure to check this thread so often, thanks.

Hope this helps.


-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.