From: Brandon C. <br...@sa...> - 2010-07-30 14:39:58
|
On 7/30/2010 9:51 AM, Anderson Goulart wrote: > Hi (again), > > Reading the manual, I saw that we can create object attrs using expose > inside the method, but you actually can create them using ::attribute. Is > that right? Any differences between them? > > Like these examples: > > /* first example */ > ::class Example > > ::method init > expose sample > sample = 0 > > > /* second example */ > ::class Example > > ::attribute sample private > > ::method init > self~sample = 0 > > > It is not clear for me if expose lets "sample" attr become private, > protected or public. > > > thanks, global The two examples do effectively the same thing. "::attribute" is just "syntax sugar". It allows you to save on about 6 lines of code. Past this syntax sugar, everything regarding protected/public/private it follows the same rules as defined under "::method". Maybe this reference will help: http://www.oorexx.org/docs/rexxref/x5149.htm <snipped> If you specify the ATTRIBUTE option, method variable accessor methods are created. In addition to generating a method named methodname, another method named methodname= is created. The first method returns the value of object instance variable that matches the method name. The second method assigns a new value to the object instance variable. For example, the directive ::method name attribute creates two methods, NAME and NAME=. The NAME and NAME= methods are equivalent to the following code sequences: ::method "NAME=" expose name use arg name ::method name expose name return name <snipped> Hope this helps! -- Brandon Cherry Network Engineer, Safe Data, Inc. 910-285-7200 x3017 http://www.safedatausa.com/ |