Re: [Oorexx-devel] Discussion: Adding variable references to ooRexx.

2018-04-13 Thread Rony G. Flatscher
Ad notation: just an idea as "food for thoughts" for an alternate, "symbol 
free" notation: what
about if making the variable reference feature available via the VAR()-BIF? 
This idea would allow a
second argument "R" (for "reference") in the VAR()-BIF, which will return the 
VariableReference of
the supplied variable.

Hence instead of writing:

a = 123
call foo &a
say a  -- displays "124"

::routine foo
  use arg &someVariable

  someVariable += 1
  return

one would code:

a = 123
call foo var(a,"reference")
say a  -- displays "124"

::routine foo
  use arg refVar 
  someVariable=var(refVar,"r")

  someVariable += 1 
  return

As it may be expected that the variable reference is not needed as often in 
Rexx/ooRexx as in a
C-based language, one may forgo a proper symbol operator for this quite 
interesting functionality.

---rony

On 13.04.2018 11:30, Rony G. Flatscher wrote:
> There are at least two aspects for me: one is the functionality, one is the 
> notation.
>
>   * The functionality aspect is a generalization of  "expose objvar" in 
> method routines, now made
> available in general. Therefore it could be used e.g. in ooRexx routine 
> packages where closely
> related routines can be coupled efficiently via the variable references 
> or multiple variables
> can be updated directly hence foregoing the need to process return values 
> to assign them to
> the variables in question and the like ...
>
>   * Ad notation: there is a big difference between Rexx and Object Rexx from 
> day one. Object Rexx
> introduced the tilde (~) and colons (in message names to indicate in 
> which superclass to start
> resolution of the method) and double-colons (to clearly indicate the 
> boundaries of directives
> that get preprocessed by the interpreter). And yes, initially they looked 
> a little bit alien
> vis-a-vis to classic Rexx, but what is also observable, after a while (to 
> get accustomed to
> them) they have been making quite a lot of sense in Object Rexx, and 
> indeed make the new
> Object Rexx concepts clearly, explicitly visible.
> Since 20 years there has been no other "alien" character been introduced 
> into the Object Rexx
> language, where "alien" relates to classic Rexx. I recall "&[&]" use in 
> EXEC and in the C
> language.
> Using any symbol for the purpose of getting a reference to a variable 
> seems to be o.k. as the
> operator needs to be explained anyway. My students for instance have 
> usually no preset concept
> to "&", so that symbol is as fine as any other for them. Those who know 
> C/C++ have probably no
> problem whatsoever to conceive the meaning immediately (learning that in 
> ooRexx it would not
> be a memory address but a reference that gets returned). Whether EXEC 
> programmers minds have
> been carved in stone such that they cannot conceive the meaning, well, I 
> do not know how they
> would perceive that. But then, there is no need for them to use that 
> feature (or any of the
> many other cool features of ooRexx), if they only have a need for the 
> classic Rexx features.
>
> The examples that Rick showed can be taught easily and using the operator in 
> both places
> (assignment expressions and USE ARG expressions) looks intuitive i.e. easily 
> explainable.
>
> I would like to experiment, "play around", explore with it ASAP (hopefully 
> being able to do so by
> early next week), also testing teaching it to the uninitiated to be able to 
> assess that aspect as
> well.
>
> ---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


Re: [Oorexx-devel] Discussion: Adding variable references to ooRexx.

2018-04-13 Thread René Jansen
I quite like Erich’s suggestion.

René

> On 13 Apr 2018, at 03:48, Erich Steinböck  wrote:
> 
> This will generally be used in a few selective place, such as situations 
> where you wish to return multiple values back from a call or method
> 
> A neat way to return multiple values might be a syntax like this:
> 
> r1, r2, .. = function(a1, a2, ..)
> 
> with function using
> 
> return r1, r2, ...
> 
> --
> 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


Re: [Oorexx-devel] Discussion: Adding variable references to ooRexx.

2018-04-13 Thread Rony G. Flatscher
There are at least two aspects for me: one is the functionality, one is the 
notation.

  * The functionality aspect is a generalization of  "expose objvar" in method 
routines, now made
available in general. Therefore it could be used e.g. in ooRexx routine 
packages where closely
related routines can be coupled efficiently via the variable references or 
multiple variables
can be updated directly hence foregoing the need to process return values 
to assign them to the
variables in question and the like ...

  * Ad notation: there is a big difference between Rexx and Object Rexx from 
day one. Object Rexx
introduced the tilde (~) and colons (in message names to indicate in which 
superclass to start
resolution of the method) and double-colons (to clearly indicate the 
boundaries of directives
that get preprocessed by the interpreter). And yes, initially they looked a 
little bit alien
vis-a-vis to classic Rexx, but what is also observable, after a while (to 
get accustomed to
them) they have been making quite a lot of sense in Object Rexx, and indeed 
make the new Object
Rexx concepts clearly, explicitly visible.
Since 20 years there has been no other "alien" character been introduced 
into the Object Rexx
language, where "alien" relates to classic Rexx. I recall "&[&]" use in 
EXEC and in the C language.
Using any symbol for the purpose of getting a reference to a variable seems 
to be o.k. as the
operator needs to be explained anyway. My students for instance have 
usually no preset concept
to "&", so that symbol is as fine as any other for them. Those who know 
C/C++ have probably no
problem whatsoever to conceive the meaning immediately (learning that in 
ooRexx it would not be
a memory address but a reference that gets returned). Whether EXEC 
programmers minds have been
carved in stone such that they cannot conceive the meaning, well, I do not 
know how they would
perceive that. But then, there is no need for them to use that feature (or 
any of the many other
cool features of ooRexx), if they only have a need for the classic Rexx 
features.

The examples that Rick showed can be taught easily and using the operator in 
both places (assignment
expressions and USE ARG expressions) looks intuitive i.e. easily explainable.

I would like to experiment, "play around", explore with it ASAP (hopefully 
being able to do so by
early next week), also testing teaching it to the uninitiated to be able to 
assess that aspect as well.

---rony


On 13.04.2018 04:57, Chip Davis wrote:
> Not wild about any of the suggestions so far.  The @ implies that what 
> follows is the location of
> something, not the thing itself.  Do we really need to be concerned about 
> variables in Classic
> Rexx on platforms that don't run ooRexx in the first place?
>
> -Chip-
>
>  Original message 
> From: Mike Cowlishaw 
> Date: 4/12/18 21:58 (GMT-05:00)
> To: 'Open Object Rexx Developer Mailing List' 
> 
> Subject: Re: [Oorexx-devel] Discussion: Adding variable references to ooRexx.
>
> Yes, I wasn't keen on arrows or '^' either :-).
>
>  
> But I'm even more un-keen on '&'.  <>
>  
> How about '*', then, as being still being one of the two ends of the 
> C notation? 
>
>
> I’m even less keen on using *. Now that C++ allows you to declare 
> arguments as being
> references rather than pointers, I've been moving away from using 
> pointers as arguments.  
>  
>  A resemblance to exec2 is not that strong of an argument when you 
> consider a large portion of
> the ooRexx users have never even heard of the language.   
>  
>
> That really isn't true .. almost all ooRexx users are Rexx users, mostly ex- 
> (or current) mainframers.
>
>  
>  
>  And it's not like every variable is going to suddenly acquiring a 
> leading '&'. This will
> generally be used in a few selective place, such as situations where you 
> wish to return
> multiple values back from a call or method.  
>  
>
> However or wherever it is used it would be inexplicable, and if it is used 
> only rarely then it
> would be even more baffling when it appears.  What does the 'and' operator 
> have to do with
> references?  
>  
> This would be a classic example of a bewildering notation that makes a 
> language inscrutable.  When
> seen, users would be forced to open the manual to figure out what it does.   
> In short: maybe a
> nice addition to Perl, but it has no place in a Rexx language.
>  
> Mike
>  

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


Re: [Oorexx-devel] Discussion: Adding variable references to ooRexx.

2018-04-13 Thread Erich Steinböck
>
> This will generally be used in a few selective place, such as situations
> where you wish to return multiple values back from a call or method


A neat way to return multiple values might be a syntax like this:

r1, r2, .. = function(a1, a2, ..)

with function using

return r1, r2, ...

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


Re: [Oorexx-devel] Discussion: Adding variable references to ooRexx.

2018-04-12 Thread Chip Davis
Not wild about any of the suggestions so far.  The @ implies that what follows 
is the location of something, not the thing itself.  Do we really need to be 
concerned about variables in Classic Rexx on platforms that don't run ooRexx in 
the first place?
-Chip-
 Original message From: Mike Cowlishaw  
Date: 4/12/18  21:58  (GMT-05:00) To: 'Open Object Rexx Developer Mailing List' 
 Subject: Re: [Oorexx-devel] Discussion: 
Adding variable references to ooRexx. 

Yes, I wasn't keen on arrows or '^' either 
:-).

  
  

 
But I'm even more un-keen on 
'&'.  <>
 
How about '*', then, as being still 
being one of the two ends of the C 
  notation? 
  

  I’m even less keen on using *. Now that C++ allows you to declare 
  arguments as being references rather than pointers, I've been moving away 
from 
  using pointers as arguments.  
   
   A resemblance to exec2 is not 
  that strong of an argument when you consider a large portion of the ooRexx 
  users have never even heard of the language.   
   
That really isn't true .. almost all ooRexx users are Rexx users, 
mostly ex- (or current) mainframers.

   
   
   And 
  it's not like every variable is going to suddenly acquiring a leading '&'. 
  This will generally be used in a few selective place, such as situations 
where 
  you wish to return multiple values back from a call or method.  
   
However or wherever it is used it would 
be inexplicable, and if it is used only rarely then it would be even more 
baffling when it appears.  What does the 'and' operator have to do with 
references?  
 
This would be a classic example of 
a bewildering notation that makes a language inscrutable.  When seen, 
users would be forced to open the manual to figure out what it 
does.   In short: maybe a nice addition to Perl, but it has no 
place in a Rexx language.
 
Mike
 --
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


Re: [Oorexx-devel] Discussion: Adding variable references to ooRexx.

2018-04-12 Thread Mike Cowlishaw
Yes, I wasn't keen on arrows or '^' either :-).

 
But I'm even more un-keen on '&'.  <>
 
How about '*', then, as being still being one of the two ends of the C
notation? 


I'm even less keen on using *. Now that C++ allows you to declare arguments
as being references rather than pointers, I've been moving away from using
pointers as arguments.  
 
 A resemblance to exec2 is not that strong of an argument when you consider
a large portion of the ooRexx users have never even heard of the language.

 

That really isn't true .. almost all ooRexx users are Rexx users, mostly ex-
(or current) mainframers.

 
 
 And it's not like every variable is going to suddenly acquiring a leading
'&'. This will generally be used in a few selective place, such as
situations where you wish to return multiple values back from a call or
method.  
 

However or wherever it is used it would be inexplicable, and if it is used
only rarely then it would be even more baffling when it appears.  What does
the 'and' operator have to do with references?  
 
This would be a classic example of a bewildering notation that makes a
language inscrutable.  When seen, users would be forced to open the manual
to figure out what it does.   In short: maybe a nice addition to Perl, but
it has no place in a Rexx language.
 
Mike
 
--
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


Re: [Oorexx-devel] Discussion: Adding variable references to ooRexx.

2018-04-12 Thread Rick McGuire
On Thu, Apr 12, 2018 at 12:19 PM Mike Cowlishaw  wrote:

>
>
> Or .. how about simple parentheses -- as already used in PARSE for a
>> similar purpose, for example?[I think we also considered   CALL
>> (foo) a,b once, to allow call by a variable name.]
>>
>
> Considered? It has been implemented since the original Object Rexx
> version. And the bit inside the parens is a generalized expression, not
> limited to just a variable. Even PARSE no longer has a limitation of just a
> variable name but has been opened up to an expression.
>
>
> Ah yes .. remember now; just never had occasion to use it!
>
>
> I had already considered the parenthesis approach and rejected it (I have
> been thinking about this problem for 14 years :-)). Using parenthesis means
> a) This is a special syntax that only applies to argument expressions with
> special rules, b) Would probably break programs for people who insist on
> coding call as "call foo(var)". I had also considered using square brackets
> in a similar fashion.
>
>
> OK.
>
>
> The syntax I have now uses a general expression operator with no
> compatibility problems.. This is not limited to just argument expressions.
> So, for example, I can do
>
> ref = &a
>
> To obtain a reference to variable A. I'd prefer to keep this approach,
> though am flexible on the "spelling" of the argument. I'm loathe to use "^"
> because some Rexx implementations have accepted that as a synonym for
> "prefix not" because of how the terminal emulators insisted on mapping the
> mainframe logical not character. "@" might make sense, but this will
> reraise the old mainframe variable name compatibility issue. "<-" might
> work, but the USE ARG end really should be the other direction "->". I
> suspect this would be difficult to work with and people would have a hard
> time remembering which arrow to use in which place, which is the nice part
> about using the same notation everywhere.
>
>
> Yes, I wasn't keen on arrows or '^' either :-).
>
> But I'm even more un-keen on '&'.  <>
>
> How about '*', then, as being still being one of the two ends of the C
> notation?
>

I’m even less keen on using *. Now that C++ allows you to declare arguments
as being references rather than pointers, I've been moving away from using
pointers as arguments. A resemblance to exec2 is not that strong of an
argument when you consider a large portion of the ooRexx users have never
even heard of the language.  And it's not like every variable is going to
suddenly acquiring a leading '&'. This will generally be used in a few
selective place, such as situations where you wish to return multiple
values back from a call or method.

Rick

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


Re: [Oorexx-devel] Discussion: Adding variable references to ooRexx.

2018-04-12 Thread Mike Cowlishaw
 

Or .. how about simple parentheses -- as already used in PARSE for a similar
purpose, for example?[I think we also considered   CALL (foo) a,b once,
to allow call by a variable name.]


Considered? It has been implemented since the original Object Rexx version.
And the bit inside the parens is a generalized expression, not limited to
just a variable. Even PARSE no longer has a limitation of just a variable
name but has been opened up to an expression.   
 

Ah yes .. remember now; just never had occasion to use it! 



I had already considered the parenthesis approach and rejected it (I have
been thinking about this problem for 14 years :-)). Using parenthesis means
a) This is a special syntax that only applies to argument expressions with
special rules, b) Would probably break programs for people who insist on
coding call as "call foo(var)". I had also considered using square brackets
in a similar fashion.  
 

OK. 


The syntax I have now uses a general expression operator with no
compatibility problems.. This is not limited to just argument expressions.
So, for example, I can do 


ref = &a

To obtain a reference to variable A. I'd prefer to keep this approach,
though am flexible on the "spelling" of the argument. I'm loathe to use "^"
because some Rexx implementations have accepted that as a synonym for
"prefix not" because of how the terminal emulators insisted on mapping the
mainframe logical not character. "@" might make sense, but this will reraise
the old mainframe variable name compatibility issue. "<-" might work, but
the USE ARG end really should be the other direction "->". I suspect this
would be difficult to work with and people would have a hard time
remembering which arrow to use in which place, which is the nice part about
using the same notation everywhere. 
 

Yes, I wasn't keen on arrows or '^' either :-).
 
But I'm even more un-keen on '&'.  <>
 
How about '*', then, as being still being one of the two ends of the C
notation? 
 
Mike
--
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


Re: [Oorexx-devel] Discussion: Adding variable references to ooRexx.

2018-04-12 Thread Rick McGuire
I've renamed the SET method on VariableReference to VALUE= per Rony's
suggestion. I also just committed changes so that the VariableReference
class implements an Unknown method so that it works the same way as the
.Stem class. If you are working directly with VariableReference objects,
for many purposes, you'll no need to use the VALUE method to retrieve the
value. For example,

a = 123
ref = &a
say ref+1   -- displays 124

Rick


On Thu, Apr 12, 2018 at 6:10 AM, Rony G. Flatscher 
wrote:

> 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 gets.
>
> 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?
>
> ---rony
>
>
> 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, 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


Re: [Oorexx-devel] Discussion: Adding variable references to ooRexx.

2018-04-12 Thread Rick McGuire
On Thu, Apr 12, 2018 at 9:21 AM, Mike Cowlishaw  wrote:

>
>
>
> I had similar thoughts, but I found that using '&' on both ends made
> things more understandable to the "normal" user. That is, the symmetry of
> using & on both the caller and receiver side connected these very firmly
> and only required explaining one piece of syntax. I'm hesitant to use the
> excuse of "it looks like C" as a reason not to use this. It would be
> understandable to people who already know C and easier to explain to those
> who don't.
>
>
> I agree that using the same notation at both ends is good.   But '&' is so
> particularly irksome .. the whole point of REX was to avoid the need for
> EXEC's '&' ... so it's doubly abrasive :-).
> '*' at both ends would make just as much sense to the C programmer, too.
>
> Or .. how about simple parentheses -- as already used in PARSE for a
> similar purpose, for example?[I think we also considered   CALL (foo)
> a,b once, to allow call by a variable name.]
>

Considered? It has been implemented since the original Object Rexx version.
And the bit inside the parens is a generalized expression, not limited to
just a variable. Even PARSE no longer has a limitation of just a variable
name but has been opened up to an expression.

I had already considered the parenthesis approach and rejected it (I have
been thinking about this problem for 14 years :-)). Using parenthesis means
a) This is a special syntax that only applies to argument expressions with
special rules, b) Would probably break programs for people who insist on
coding call as "call foo(var)". I had also considered using square brackets
in a similar fashion.

The syntax I have now uses a general expression operator with no
compatibility problems.. This is not limited to just argument expressions.
So, for example, I can do

ref = &a

To obtain a reference to variable A. I'd prefer to keep this approach,
though am flexible on the "spelling" of the argument. I'm loathe to use "^"
because some Rexx implementations have accepted that as a synonym for
"prefix not" because of how the terminal emulators insisted on mapping the
mainframe logical not character. "@" might make sense, but this will
reraise the old mainframe variable name compatibility issue. "<-" might
work, but the USE ARG end really should be the other direction "->". I
suspect this would be difficult to work with and people would have a hard
time remembering which arrow to use in which place, which is the nice part
about using the same notation everywhere.

Rick



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


Re: [Oorexx-devel] Discussion: Adding variable references to ooRexx.

2018-04-12 Thread Mike Cowlishaw

 

I had similar thoughts, but I found that using '&' on both ends made things
more understandable to the "normal" user. That is, the symmetry of using &
on both the caller and receiver side connected these very firmly and only
required explaining one piece of syntax. I'm hesitant to use the excuse of
"it looks like C" as a reason not to use this. It would be understandable to
people who already know C and easier to explain to those who don't.  
 

I agree that using the same notation at both ends is good.   But '&' is so
particularly irksome .. the whole point of REX was to avoid the need for
EXEC's '&' ... so it's doubly abrasive :-).  
'*' at both ends would make just as much sense to the C programmer, too.
 
Or .. how about simple parentheses -- as already used in PARSE for a similar
purpose, for example?[I think we also considered   CALL (foo) a,b once,
to allow call by a variable name.]
 
Mike
--
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


Re: [Oorexx-devel] Discussion: Adding variable references to ooRexx.

2018-04-12 Thread Rick McGuire
On Thu, Apr 12, 2018 at 6:29 AM, Mike Cowlishaw  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'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.
>
>
> Also wondering if it's needed .. I've been using USE ARG for this for many
> years, using for example:
>
> In the caller:
>
>   data.['admin']=0
>  call foobar data.
>
> and in the callee:
>
>   use arg data
>  admin=data.['admin']-- shorthand, which could of course use a
> different target name
> Since there are often dozens of variables it's safer and simpler to
> collect them together in some way rather than list them in some specific
> order and have to remember which matches which?
>
> Separately, the '&' prefix is horribly C-like, but only on one side of the
> transaction ... and C is the only reason for using for choosing that
> operator; something that implied a reference might be better?  Perhaps '^',
> for 'upwards reference'?   Or even '=' or '<-' 
>

I had similar thoughts, but I found that using '&' on both ends made things
more understandable to the "normal" user. That is, the symmetry of using &
on both the caller and receiver side connected these very firmly and only
required explaining one piece of syntax. I'm hesitant to use the excuse of
"it looks like C" as a reason not to use this. It would be understandable
to people who already know C and easier to explain to those who don't.

Rick


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


Re: [Oorexx-devel] Discussion: Adding variable references to ooRexx.

2018-04-12 Thread Mike Cowlishaw
 

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'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. 
 

Also wondering if it's needed .. I've been using USE ARG for this for many
years, using for example:
 
In the caller:
 
  data.['admin']=0
 call foobar data.
 
and in the callee:
 
  use arg data
 admin=data.['admin']-- shorthand, which could of course use a different
target name

Since there are often dozens of variables it's safer and simpler to collect
them together in some way rather than list them in some specific order and
have to remember which matches which?
 
Separately, the '&' prefix is horribly C-like, but only on one side of the
transaction ... and C is the only reason for using for choosing that
operator; something that implied a reference might be better?  Perhaps '^',
for 'upwards reference'?   Or even '=' or '<-' 
 
Mike
--
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


Re: [Oorexx-devel] Discussion: Adding variable references to ooRexx.

2018-04-12 Thread Rick McGuire
On Thu, Apr 12, 2018 at 6:10 AM, Rony G. Flatscher 
wrote:

> 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 gets.
>
> 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?
>
>  The & operator creates an instance of the VariableReference class. The
variable just gets assigned that instance value with no aliasing allowed.
The same object is returned if you use the arg() bif to get the argument.

>
>-
>- 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?
>
> The Use Arg pattern does not give you access to the VariableReference
object, it performs an actual aliasing of the local variable to the
variable held in the variable reference. Thus

a = 123
call foo &a
say a

::routine foo
  use arg &someVariable

  someVariable += 1'
  return

Would display '124'

>
>- 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?
>
> Sounds like a good suggestion, though I suspect most people would prefer
to use this object via the Use Arg aliasing, so they never have to deal
with that. Trivial to add though.

Rick

>
>
> ---rony
>
>
> 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, 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


Re: [Oorexx-devel] Discussion: Adding variable references to ooRexx.

2018-04-12 Thread Rony G. Flatscher
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 
gets.

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?

---rony



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, Slashdot.org! http://sdm.link/slashdot___
Oorexx-devel mailing list
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel