Bill's sample with the *begin* method -- topic changed ...

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Bill's sample with the *begin* method -- topic changed ...

ThSITC
Hi Bill, and all:

Did now investigate your program snippet (from your mail as of 16.03.2013, below, at the end), with the following results:

1.) Your program snippet (named Bill_1) does *not* compile at all, and that's why I did investigate it, as a *say* statement *after an exit statement* will never be reached (which is great, thank' to mike's ingenuity checking that
at compile time :-)

Bill_1.nrx  Source code:
==================
 
/* Bill_1: Bill's example from mail 2013-03-17 (ibm-netrexx) */
/*       : discussing the overloading of *keywords*          */
/*************************************************************/
/* NetRexx 3 */

begin

loop  i = 1 to 5
   say "\n Loop iteration" i
 
   if i = 3 then do
      say "   Leave in iteration 3"
      leave
      end
 
   if i > 3 then say "   Why am I still in this loop?"
   end

say "\n Now exit"
exit
say "   Why was the exit was not done?\n"


/* Remainder of the program */
method begin static
say "\n Begin Test"

----------------------------------------------------------------------------------
Bill_1 NetRexx compilation LOG:

NetRexx portable processor, version NetRexx 3.01RC2, build 54-20111013-0038
Copyright (c) RexxLA, 2011.  All rights reserved.
Parts Copyright (c) IBM Corporation, 1995,2008.
Program Bill_1.nrx
 21 +++ say "   Why was the exit was not done?\n"
    +++ ^^^
    +++ Error: Clause cannot be reached
    function begin
Compilation of 'Bill_1.nrx' failed [one error]
***************************************************************************************

Thus, I did modify the program commenting out the unallowed Say after the Exit, as follows:

Bill_2.nrx (NetRexx Source):
=====================
/* Bill_2: Bill's example from mail 2013-03-17 (ibm-netrexx) */
/*       : discussing the overloading of *keywords*          */
/*       : with the un-allowed SAY statement after the exit  */
/*       : commented out (Thomas.Schneider, 17.03.2013)      */
/*************************************************************/
/* NetRexx 3 */

begin

loop  i = 1 to 5
   say "\n Loop iteration" i
 
   if i = 3 then do
      say "   Leave in iteration 3"
      leave
      end
 
   if i > 3 then say "   Why am I still in this loop?"
   end

say "\n Now exit"
exit
-- The below *say* statement commented out, as this somple
-- will *not* compile otherwise (Thomas Schneider, 17.03.2013)
-- say "   Why was the exit was not done?\n"


/* Remainder of the program */
method begin static
say "\n Begin Test"

This now correct program *does compile*, of course!

Bill_2.log (NetRexxC Compilation log) is as follows:
========================================

/* Bill_2: Bill's example from mail 2013-03-17 (ibm-netrexx) */
/*       : discussing the overloading of *keywords*          */
/*       : with the un-allowed SAY statement after the exit  */
/*       : commented out (Thomas.Schneider, 17.03.2013)      */
/*************************************************************/
/* NetRexx 3 */

begin

loop  i = 1 to 5
   say "\n Loop iteration" i
 
   if i = 3 then do
      say "   Leave in iteration 3"
      leave
      end
 
   if i > 3 then say "   Why am I still in this loop?"
   end

say "\n Now exit"
exit
-- The below *say* statement commented out, as this somple
-- will *not* compile otherwise (Thomas Schneider, 17.03.2013)
-- say "   Why was the exit was not done?\n"


/* Remainder of the program */
method begin static
say "\n Begin Test"

**************************************************************************
And the execution does now give:

 Begin Test

 Loop iteration 1

 Loop iteration 2

 Loop iteration 3
   Leave in iteration 3

 Now exit

*********************************************************************************
*********************************************************************************

Thus, in summary:

1.) Your original snippet is *not* related to any Keyword Overloading
at all (see my original response on this issue, as *Begin* is *NO KEYWORD*
in NetRexx at all.
2.) When the semantic  error in your program (Say after Exit) is removed,
the program *does work* as expected and designed!
3.) Thus, the wrong behaviour in your original program shall be caused
by a coding error on a deeper leve l(most probably in an  *called* method, I think!)

I think adding a *TRACE METHODS* at the start of your origininal source
shall help you to find the cause!

******************************************************************************
Hope this does help a bit, Bill :-)

Thomas.

******************************************************************************  
PS: and sorry for this lengthy mail.
       Needless to say how much shorted it would have been when allowing *attachments*  ;-)

But as I did suggest that so many times, I will *not* repeat this requirement again,
and  did take the time to do a lot of *Cuts and Pastes* :-)

Have a nice Sunday, all!
******************************************************************************

      '__________________________________________
Am 17.03.2013 15:09, schrieb Thomas Schneider:
Hi Bill,
   as far as I do know, *begin* is *no keyword* in NetRexx!
... *or* did I miss something ?
Happy Sunday, all, anyway !
Thomas.
==================================================================================


Am 16.03.2013 19:46, schrieb Bill Fenlason:
Sorry for the delay with this.  A simple test shows that keywords can be overloaded with methods.  Here is a snip from a program named "keyword_test.nrx" :

/* NetRexx 3 */

begin

loop  i = 1 to 5
   say "\n Loop iteration" i
  
   if i = 3 then do
      say "   Leave in iteration 3"
      leave
      end
  
   if i > 3 then say "   Why am I still in this loop?"
   end

say "\n Now exit"
exit
say "   Why was the exit was not done?\n"


/* Remainder of the program */
method begin static
say "\n Begin Test"

------------------- snip (what has been omitted here?) ----------------------
...

Here is the somewhat surprising output from interpreting this program:

===== Exec: keyword_test =====

 Begin Test

 Loop iteration 1

 Loop iteration 2

 Loop iteration 3
   Leave in iteration 3

 Loop iteration 4
   Why am I still in this loop?

 Loop iteration 5
   Why am I still in this loop?

 Now exit
   Why was the exit was not done?

Processing of 'keyword_test.nrx' complete


And here is the rest of the program (not shown above):
...
-------------------- snip (what has been omitted here?) ----------------------

/* Method with the same name as leave keyword */
method leave static
--say "Leave method entered"

/* Method with the same name as exit keyword */
method exit static
--say "Exit method entered"

------------------------------------------------------------------------------------

I was wrong about a method named "end" since the mismatch with "loop" etc. will be caught.  But I think this example shows the astonishment factor with regard to overloading keywords.

I have not tested having the keyword overloads in an imported package, but I assume it would produce the same results.

Of course some may feel that keyword overloading is an advantage, but I think it is not, particularly for the beginning programmer.

Bill


On 3/12/2013 8:30 AM, Bill Fenlason wrote:
Mike,

On 3/12/2013 3:55 AM, Mike Cowlishaw wrote:
Bill wrote: 
 
 What I mean is that the same NetRexx statement is either valid or an error depending on the dynamic execution environment - that is, can depend on exactly what is available at runtime and the current state of affairs within the program execution.  See page 79 of the language reference manual ("Keyword Instructions").  Also, because you can overload a keyword with a method, you can not determine if the statement is in error until the runtime environment is available.  (Consider a program which accesses a Java method named "end" :).
 
Is this really true?   I thought it was only variables (including arguments & properties).  Since those are statically determined there shouldn't be any dependence on runtime environment.  Or maybe I'm forgetting something again.


Mike, I may be wrong on that.  I must admit that I have not tried it, but it is based on my understand of the determination of keywords.  I may have it confused in my memory - my current medications seem to encourage that :).  I will test this later today when I have time.

I think keywords should have priority over variable names IN SITUATIONS WHERE THE KEYWORD IS VALID, but NetRexx does not work that way.  I think that in the example on page 79, the fact that the second  "say 'Hello' " is in error rates high on the astonishment scale.  
 
This means the programmer has to learn all the keywords in the language ... but I agree a more complicated rule might be possible.  However it wasn't clear whether the syntax (effectively "3 'Hello') might _not_ be an error in the future, especially as an expression like that is valid in Classic Rexx, e.g., the second line of:
 
  options='open binary stream'
  options args
 
would issue a command in Rexx but be a keyword instruction in (modified) NetRexx.   


 Considering how few keywords Rexx has, I doubt that learning the keywords would be a problem. 

I think that the statement "options args" that issues a command also ranks pretty high on the astonishment scale.

I agree that assuming that all versions of NetRexx (now and in the future) should be parsable without language version information will certainly allow breakage.  That is why I suggest that the language version (if not the original) be explicit in the heading.  I see no difficulty on insisting that the first comment token be "NetRexx" and the next non-whitespace token sequence be a language level indication (e.g. /*  NetRexx  3.2  */ )

 
Mike 


Bill



_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/



--
Thomas Schneider, IT Consulting; http://www.thsitc.com; Vienna, Austria, Europe


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/



--
Thomas Schneider, IT Consulting; http://www.thsitc.com; Vienna, Austria, Europe

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Thomas Schneider, Vienna, Austria (Europe) :-)

www.thsitc.com
www.db-123.com
Reply | Threaded
Open this post in threaded view
|

Re: Bill's sample with the *begin* method -- topic changed ...

Tom Maynard
On 17/3/13 9:59, Thomas Schneider wrote:
Your program...does *not* compile

Perhaps that's because you didn't try to compile **the actual program**.  You obviously didn't read the original note very thoroughly, Thomas.  That's too bad.

You missed the most important part:

And here is the rest of the program (not shown above):
...
-------------------- snip (what has been omitted here?) ----------------------

/* Method with the same name as leave keyword */
method leave static
--say "Leave method entered"

/* Method with the same name as exit keyword */
method exit static
--say "Exit method entered"

------------------------------------------------------------------------------------

If you try again with the actual program, as given, you'll have much "better" results.

Tom.


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: Bill's sample with the *begin* method -- topic changed ...

billfen
In reply to this post by ThSITC
Thomas,
Please recompile the whole program, including all THREE of the methods.
Possibly you missed the point that I was not disclosing the remainder of the program.
Bill

On 3/17/2013 10:59 AM, Thomas Schneider wrote:
Hi Bill, and all:

Did now investigate your program snippet (from your mail as of 16.03.2013, below, at the end), with the following results:

1.) Your program snippet (named Bill_1) does *not* compile at all, and that's why I did investigate it, as a *say* statement *after an exit statement* will never be reached (which is great, thank' to mike's ingenuity checking that
at compile time :-)

Bill_1.nrx  Source code:
==================
 
/* Bill_1: Bill's example from mail 2013-03-17 (ibm-netrexx) */
/*       : discussing the overloading of *keywords*          */
/*************************************************************/
/* NetRexx 3 */

begin

loop  i = 1 to 5
   say "\n Loop iteration" i
 
   if i = 3 then do
      say "   Leave in iteration 3"
      leave
      end
 
   if i > 3 then say "   Why am I still in this loop?"
   end

say "\n Now exit"
exit
say "   Why was the exit was not done?\n"


/* Remainder of the program */
method begin static
say "\n Begin Test"

----------------------------------------------------------------------------------
Bill_1 NetRexx compilation LOG:

NetRexx portable processor, version NetRexx 3.01RC2, build 54-20111013-0038
Copyright (c) RexxLA, 2011.  All rights reserved.
Parts Copyright (c) IBM Corporation, 1995,2008.
Program Bill_1.nrx
 21 +++ say "   Why was the exit was not done?\n"
    +++ ^^^
    +++ Error: Clause cannot be reached
    function begin
Compilation of 'Bill_1.nrx' failed [one error]
***************************************************************************************

Thus, I did modify the program commenting out the unallowed Say after the Exit, as follows:

Bill_2.nrx (NetRexx Source):
=====================
/* Bill_2: Bill's example from mail 2013-03-17 (ibm-netrexx) */
/*       : discussing the overloading of *keywords*          */
/*       : with the un-allowed SAY statement after the exit  */
/*       : commented out (Thomas.Schneider, 17.03.2013)      */
/*************************************************************/
/* NetRexx 3 */

begin

loop  i = 1 to 5
   say "\n Loop iteration" i
 
   if i = 3 then do
      say "   Leave in iteration 3"
      leave
      end
 
   if i > 3 then say "   Why am I still in this loop?"
   end

say "\n Now exit"
exit
-- The below *say* statement commented out, as this somple
-- will *not* compile otherwise (Thomas Schneider, 17.03.2013)
-- say "   Why was the exit was not done?\n"


/* Remainder of the program */
method begin static
say "\n Begin Test"

This now correct program *does compile*, of course!

Bill_2.log (NetRexxC Compilation log) is as follows:
========================================

/* Bill_2: Bill's example from mail 2013-03-17 (ibm-netrexx) */
/*       : discussing the overloading of *keywords*          */
/*       : with the un-allowed SAY statement after the exit  */
/*       : commented out (Thomas.Schneider, 17.03.2013)      */
/*************************************************************/
/* NetRexx 3 */

begin

loop  i = 1 to 5
   say "\n Loop iteration" i
 
   if i = 3 then do
      say "   Leave in iteration 3"
      leave
      end
 
   if i > 3 then say "   Why am I still in this loop?"
   end

say "\n Now exit"
exit
-- The below *say* statement commented out, as this somple
-- will *not* compile otherwise (Thomas Schneider, 17.03.2013)
-- say "   Why was the exit was not done?\n"


/* Remainder of the program */
method begin static
say "\n Begin Test"

**************************************************************************
And the execution does now give:

 Begin Test

 Loop iteration 1

 Loop iteration 2

 Loop iteration 3
   Leave in iteration 3

 Now exit

*********************************************************************************
*********************************************************************************

Thus, in summary:

1.) Your original snippet is *not* related to any Keyword Overloading
at all (see my original response on this issue, as *Begin* is *NO KEYWORD*
in NetRexx at all.
2.) When the semantic  error in your program (Say after Exit) is removed,
the program *does work* as expected and designed!
3.) Thus, the wrong behaviour in your original program shall be caused
by a coding error on a deeper leve l(most probably in an  *called* method, I think!)

I think adding a *TRACE METHODS* at the start of your origininal source
shall help you to find the cause!

******************************************************************************
Hope this does help a bit, Bill :-)

Thomas.

******************************************************************************  
PS: and sorry for this lengthy mail.
       Needless to say how much shorted it would have been when allowing *attachments*  ;-)

But as I did suggest that so many times, I will *not* repeat this requirement again,
and  did take the time to do a lot of *Cuts and Pastes* :-)

Have a nice Sunday, all!
******************************************************************************

      '__________________________________________
Am 17.03.2013 15:09, schrieb Thomas Schneider:
Hi Bill,
   as far as I do know, *begin* is *no keyword* in NetRexx!
... *or* did I miss something ?
Happy Sunday, all, anyway !
Thomas.
==================================================================================


Am 16.03.2013 19:46, schrieb Bill Fenlason:
Sorry for the delay with this.  A simple test shows that keywords can be overloaded with methods.  Here is a snip from a program named "keyword_test.nrx" :

/* NetRexx 3 */

begin

loop  i = 1 to 5
   say "\n Loop iteration" i
  
   if i = 3 then do
      say "   Leave in iteration 3"
      leave
      end
  
   if i > 3 then say "   Why am I still in this loop?"
   end

say "\n Now exit"
exit
say "   Why was the exit was not done?\n"


/* Remainder of the program */
method begin static
say "\n Begin Test"

------------------- snip (what has been omitted here?) ----------------------
...

Here is the somewhat surprising output from interpreting this program:

===== Exec: keyword_test =====

 Begin Test

 Loop iteration 1

 Loop iteration 2

 Loop iteration 3
   Leave in iteration 3

 Loop iteration 4
   Why am I still in this loop?

 Loop iteration 5
   Why am I still in this loop?

 Now exit
   Why was the exit was not done?

Processing of 'keyword_test.nrx' complete


And here is the rest of the program (not shown above):
...
-------------------- snip (what has been omitted here?) ----------------------

/* Method with the same name as leave keyword */
method leave static
--say "Leave method entered"

/* Method with the same name as exit keyword */
method exit static
--say "Exit method entered"

------------------------------------------------------------------------------------

I was wrong about a method named "end" since the mismatch with "loop" etc. will be caught.  But I think this example shows the astonishment factor with regard to overloading keywords.

I have not tested having the keyword overloads in an imported package, but I assume it would produce the same results.

Of course some may feel that keyword overloading is an advantage, but I think it is not, particularly for the beginning programmer.

Bill


On 3/12/2013 8:30 AM, Bill Fenlason wrote:
Mike,

On 3/12/2013 3:55 AM, Mike Cowlishaw wrote:
Bill wrote: 
 
 What I mean is that the same NetRexx statement is either valid or an error depending on the dynamic execution environment - that is, can depend on exactly what is available at runtime and the current state of affairs within the program execution.  See page 79 of the language reference manual ("Keyword Instructions").  Also, because you can overload a keyword with a method, you can not determine if the statement is in error until the runtime environment is available.  (Consider a program which accesses a Java method named "end" :).
 
Is this really true?   I thought it was only variables (including arguments & properties).  Since those are statically determined there shouldn't be any dependence on runtime environment.  Or maybe I'm forgetting something again.


Mike, I may be wrong on that.  I must admit that I have not tried it, but it is based on my understand of the determination of keywords.  I may have it confused in my memory - my current medications seem to encourage that :).  I will test this later today when I have time.

I think keywords should have priority over variable names IN SITUATIONS WHERE THE KEYWORD IS VALID, but NetRexx does not work that way.  I think that in the example on page 79, the fact that the second  "say 'Hello' " is in error rates high on the astonishment scale.  
 
This means the programmer has to learn all the keywords in the language ... but I agree a more complicated rule might be possible.  However it wasn't clear whether the syntax (effectively "3 'Hello') might _not_ be an error in the future, especially as an expression like that is valid in Classic Rexx, e.g., the second line of:
 
  options='open binary stream'
  options args
 
would issue a command in Rexx but be a keyword instruction in (modified) NetRexx.   


 Considering how few keywords Rexx has, I doubt that learning the keywords would be a problem. 

I think that the statement "options args" that issues a command also ranks pretty high on the astonishment scale.

I agree that assuming that all versions of NetRexx (now and in the future) should be parsable without language version information will certainly allow breakage.  That is why I suggest that the language version (if not the original) be explicit in the heading.  I see no difficulty on insisting that the first comment token be "NetRexx" and the next non-whitespace token sequence be a language level indication (e.g. /*  NetRexx  3.2  */ )

 
Mike 


Bill



_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/



--
Thomas Schneider, IT Consulting; http://www.thsitc.com; Vienna, Austria, Europe


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/



--
Thomas Schneider, IT Consulting; http://www.thsitc.com; Vienna, Austria, Europe


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/



No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.2904 / Virus Database: 2641/6172 - Release Date: 03/13/13



_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/