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/

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
Oorexx-users mailing list
Oorexx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-users

Reply via email to