No, not really. a ::attribute is just a method that allows access to an
object variable....which is just a variable like any other, just in a
different home. You still need the expose instruction to make the magic
happen.
Rick
On Wed, May 2, 2018 at 9:16 AM, Rony G. Flatscher <rony.flatsc...@wu.ac.at>
wrote:
> Experimenting further with variable references. Very nice feature is to
> also become able to refer to attributes with variable references. E.g.:
>
> -- purpose: test whether attributes can be used via variable references as
> well
>
> o=.test~new("eins", "zwei") -- German
> say "1, o:" o -- show current settings of attributes
>
> call change o~getOneRef, "un" -- French
> say "2a, o:" o -- show current settings of attributes
>
> call change o~getTwoRef, "deux" -- French
> say "2b, o:" o -- show current settings of attributes
>
> ::routine change -- use variable reference to change value to point to
> use arg >ref, value -- make "ref" an alias variable
> ref=value
>
> ::class test -- class that defines two attributes
> ::attribute one -- attribute
> ::attribute two -- atribute
>
> ::method init -- initialize attribute values
> expose one two
> use arg one, two
>
> ::method getOneRef -- return reference to attribute
> expose one
> return >one
>
> ::method getTwoRef -- return reference to attribute
> expose two
> return >two
>
> ::method string
> expose one two
> return "a" self~class~id"["one","two"]"
>
> The above program yields:
>
> E:\reference\test2>testAttributeAccess.rex
> 1, o: a TEST[eins,zwei]
> 2a, o: a TEST[un,zwei]
> 2b, o: a TEST[un,deux]
>
> The question: would access via variable references to attributes be safe
> in a multithreaded scenario as well? I.e. what if a variable reference to
> an attribute get used to change the value (replace or interact with) and in
> another thread a guarded method gets executed concurrently, which guards
> the access to its attributes (thereby blocking concurrent access). Would
> the access to the variable reference be blocked until the guarded method
> completes?
>
No it would not. The blocking mechanism only applies to the invocation of
methods, not to the access of variables itself. There is no such thing as
"blocking access to attributes. Attributes are METHODS, not VARIABLES. If
you've chosen to give out access to that variable by creating a reference
to it, it can be changed.
Rick
>
>
> ---rony
>
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Oorexx-devel mailing list
> Oorexx-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/oorexx-devel
>
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Oorexx-devel mailing list
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel