Scope rules

Jeff Dyer jodyer at
Thu Feb 7 20:53:46 PST 2008

On 2/7/08 4:16 PM, Michael O'Brien wrote:

> I'm trying to find the scope rules for constructor initializers and for
> function parameter default values.  If someone could point me to a
> document or clarify these that would be great.
> I've read bits and pieces. For constructor initializers:
> class Shape {
>     function Shape():
>        leftSide = rightSide
>     {
>     }
>     function render(arg1 = expression) {
>     }
> }
> In the constructor initializers, I presume the leftSide has a scope
> equal to just outside the constructor and the rightSide binds to inside
> the constructor. Is this right?

'leftSide' targets the instance and so must be and instance variable.
'rightSide' has a scope that includes the constructor parameters, class
statics and scopes beyond.

> Also, can "this" be used in either right or left side?

Since 'this' is implied on the left side and meaningless on the right, I'd
say not be both.

> For function default arguments, is the scope of the expression just
> outside the function?

This has been debated recently. I don't recall that there was a resolution.
My thinking is is that default parameter expression should be scoped to the
scope just outside the function. This is how the RI currently works, FWIW.


> Michael
> _______________________________________________
> Es4-discuss mailing list
> Es4-discuss at

More information about the Es4-discuss mailing list