Jon,

A variable reference is something that works the way people keep thinking
use arg works. There are basically three pieces to this:

1. A variable reference class that can hold a reference to a variable.
Using a variable reference instance, a variable value can be retrieved or
set.
2. A new operator (well, two actually) that creates an instance of a
variable reference object from the current execution context.
3. An extension to USE ARG that allows an argument to be specified as a
required variable reference. This type of argument creates a variable alias
in the caller.

Most of this is invisible to the caller, but, for example, suppose you want
to have a call where you have an error code that is returned and you also
wish to pass other information back if the call was successful. There are
many awkward solutions that people have used for this, but with the
variable references you can do this.

if myFunc(>info) == 0 then

The > prefix operator creates a reference to the variable info that is
passed to the caller. On the call target side, you would have

use arg >returnInfo

...
 returnInfo = result
return 0

Assigning something to returnInfo actually assigns the value to the
variable info back in the caller.  Because the thing that gets passed
around is an object instance, this call-by-reference type will also work
from native code.

This is not in trunk yet, only in the sandbox branch sandbox\rick\reference

You would need to build this yourself or I believe Rony had a build in his
dropbox someplace.

Rick

On Mon, Jul 9, 2018 at 5:08 PM Jon Wolfers <sahana...@gmail.com> wrote:

> Hi Rick,
>
> Can you (or someone else) explain in simple layman's terms what a variable
> reference is and when one would want to use it, what's neat about it.
>
> In order to test/use play with these do we just need the latest release of
> 5.0.0 or something more or different.
>
> Sorry if either or both of these questions have been asked before - I
> missed them.
>
> thanks,
>
> Jon
>
>
> On 9 July 2018 at 21:12, Rick McGuire <object.r...@gmail.com> wrote:
>
>> Things have been very quiet about these new features, so I don't really
>> know if anybody is actually playing around with them or not. The code is
>> done, tests are written. The biggest outstanding item is getting the docs
>> written. So, we need to reach a consensus on whether either of these
>> features should be in 5.0.0 so the process of merging can start.
>>
>> Rick
>>
>>
>> ------------------------------------------------------------------------------
>> 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
>
------------------------------------------------------------------------------
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

Reply via email to