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?
---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