This appears to be a very interesting addition to the language which allows one 
to solve particular
problems in ways that otherwise are simply impossible. It seems to allow for 
"call by name"
semantics as one can learn the name of the variable whose VariableReference one 

Using the ampersand both as the operator for yielding a VariableReference and 
as an operator for
referring to the supplied VariableReference in a routine in a USE keyword 
statement appears quite
intuitive and would ease teaching it (the operator is only used in the very 
context of variable
references on both sides).

Maybe a few questions (been away on business trips and not having had time to 
get and build the
sandbox version of this interesting implementation):

  * what happens if USE ARG fetches a variable reference without the "&" 
operator: would it cause a
    runtime condition? If not, what kind of object gets assigned to the 
variable in the routine?
  * would it be possible to get at the VariableReferences from the array that 
arg(1,"Array") returns
    or is that restricted to the USE keyword instruction?
  * would it be possible to have a "value=" synonym for the "setValue" method 
as this would allow to
    apply the ooRexx attribute value assignment pattern?


On 11.04.2018 16:28, Rick McGuire wrote:
> Now that the ADDRESS WITH activity is moving along somewhat, I thought I 
> might revisit an idea
> that has been kicking around since the early days of the project. This was a 
> question of allowing
> some form of call-by-name to the language. 
> I've been mulling this over for some time and decided it was finally time to 
> take a crack at it.
> It turned out to be not that tough with the current state of the code. This 
> would not have been
> possible 14 years ago. 
> Anyway, the additions to the language are 
> 1) A new class called VariableReference, which has methods NAME, VALUE, and 
> SETVALUE.  This class
> gives access to variables that can be passed around. 
> 2) A new prefix operator, '&' that creates a reference to a variable that 
> follows it. Only simple
> and stem variables are support (i.e., non compound). This operator is the 
> only way to create a
> variable reference. 
> 3) An equivalent change to USE ARG to allow matching up a local variable name 
> to a variable
> reference, creating an alias to the original variable. Thus
> call foo &a
> ::routine foo
>   use arg &var 
> creates the alias and changes made to VAR in routine FOO are really changes 
> made to variable A in
> the caller. 
>  Note that arguments marked with & on USE ARG are always required and the 
> variable types must
> always be a match (that is, simple-to-simple or stem-to-stem).
> 4) Support in the APIs for passing VariableReferences as arguments (again, 
> these are never allowed
> to be optional), invoking the 3 methods on the reference, and also an API for 
> the method context
> for creating a reference object to an Object variable that can be passed as 
> an argument. 
> I'm a little torn over whether this is needed or not, but the fact that 
> people keep trying to do
> this via USE ARG argues there is demand for some sort of call-by-name 
> capability. Anyway, the
> prototype appears to be working, though there are a few more tests that need 
> to be written. This
> can be built and played with. 
> Rick

Check out the vibrant tech community on one of the world's most
engaging tech sites,!
Oorexx-devel mailing list

Reply via email to