Home About Rice Downloads Documents Others Cooker CookerGX
Documents  >  Reference  >  scope
scope

Referable range of identifier.

Scope means the source code range that is able to refer a identifier.

If scope surrounds other scope, the inside scope can see the outside scope, but the outside scope cannot see a identifier that is internal to the inside scope.

For example,


class sample

bool _flag;

open method void sample_method()

bool method_flag = _flag; //♦1

if(true)

bool if_flag = method_flag; //♦2

endif

bool method_flag2 = if_flag; //♦3

endmethod

endclass


♦1 : Referable. _falg is declared in the scope created by the class definition. It is referable from the inside (the scope of the method definition).

♦2 : Referable. method_flag is declared in the scope created by the method definition. It is referable from the inside (the scope of the if statement).

♦3 : Error. if_flag is declared in the scope created by the if statement. It is unreferable from the outside (the scope of the method definition).

Next
Previous
Copyright © Rice All rights reserved.