Thoughts on Adding methods to compiled classes

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

Thoughts on Adding methods to compiled classes

Jeff Hennick-3

In thinking more on the subject of dynamically adding methods to already compiled classes, and specifically to the Rexx class, it seems to me to be a very useful mechanism.

Is there a philosophical objection for having this?

Hearing no objections (yet), I will continue from my pinnacle of ignorance.

Currently if I have this definition of a method in some random class

  method verb(rexxObj=Rexx, len, let) returns Rexx

    ...rexxObj...ret=...

    return ret

I can use it such as

  str = Rexx "XyZ"

  abc = verb(str.upper, 5, 'Z')

But although it is totally equivalent, I can not use it this way

  str = Rexx "XyZ"

  abc = str.upper.verb(5, 'Z')

When the scanner encounters this, it asks the Rexx class to handle it, but that class knows nothing of it and reports the error.

(In my ignorance) I ask if the scanner, before going to the Rexx class, could check to see if there is a local method with a signature of verb(Rexx, Rexx, Rexx).  If it finds that, it should use it. 

A second step would be in defining a method.  Here, I suggest a new keyword, maybe, Classof classname.  This would permit the use of the classname variable this in its body:

  method verb(len, let) classof Rexx returns Rexx

    ...this...ret=...

    return ret

When the scanner sees this, it thinks:

  method verb(this=Rexx, len, let) returns Rexx

and compiles it as usual.  The original formulation would work equally.

I don't see either of these additions, if implemented, as breaking any existing programs.  I do see them as easing readability and removing a source of surprise.


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

Reply | Threaded
Open this post in threaded view
|

Re: Thoughts on Adding methods to compiled classes

ThSITC

HI Jeff,

May I add this to my 'OPEN ISSUES' folder on my Desktop, please ?

Kindly, Thomas Schneider.

===================================================================

Am 28.03.2020 um 21:58 schrieb Jeff Hennick:

In thinking more on the subject of dynamically addi ng methods to already compiled classes, and specifically to the Rexx class, it seems to me to be a very useful mechanism.

Is there a philosophical objection for having this?

Hearing no objections (yet), I will continue from my pinnacle of ignorance.

Currently if I have this definition of a method in some random class

  method verb(rexxObj=Rexx, len, let) returns Rexx

    ...rexxObj...ret=...

    return ret

I can use it such as

  str = Rexx "XyZ"

  abc = verb(str.upper, 5, 'Z')

But although it is totally equivalent, I can not use it this way

  str = Rexx "XyZ"

  abc = str.upper.verb(5, 'Z')

When the scanner encounters this, it asks the Rexx class to handle it, but that class knows nothing of it and reports the error.

(In my ignorance) I ask if the scanner, before going to the Rexx class, could check to see if there is a local method with a signature of verb(Rexx, Rexx, Rexx).  If it finds that, it should use it. 

A second step would be in defining a method.  Here, I suggest a new keyword, maybe, Classof classname.  This would permit the use of the classname variable this in its body:

  method verb(len, let) classof Rexx returns Rexx

    ...this...ret=...

    return ret

When the scanner sees this, it thinks:

  method verb(this=Rexx, len, let) returns Rexx

and compiles it as usual.  The original formulation would work equally.

I don't see either of these additions, if implemented, as breaking any existing programs.  I do see them as easing readability and removing a source of surprise.


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


Virus-free. www.avg.com

_______________________________________________
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: Thoughts on Adding methods to compiled classes

rvjansen
In reply to this post by Jeff Hennick-3
I might not have this objection, but the philosophical justification for static type checking is avoidance of runtime errors. With the lexer/parse scanning the full file in Object Rexx, instead of the clause based scanning of Rexx on CMS and TSO, people complained that not all execs ran, when in fact there execs contained errors that were outside of the execution path.

The execution of pipelines can be seen as entirely dynamic, as the pipes compiler writes all the source before we feed it to NetRexx. You might want to experiment with extending the Rexx class in there, before we touch the NetRexx translator itself, i.e. the pipes compiler can deliver the tools to NetRexx to do what you want, and we later move it into NetRexx if proven.

René.

On 28 Mar 2020, at 21:58, Jeff Hennick <[hidden email]> wrote:

In thinking more on the subject of dynamically adding methods to already compiled classes, and specifically to the Rexx class, it seems to me to be a very useful mechanism.

Is there a philosophical objection for having this?

Hearing no objections (yet), I will continue from my pinnacle of ignorance.

Currently if I have this definition of a method in some random class

  method verb(rexxObj=Rexx, len, let) returns Rexx

    ...rexxObj...ret=...

    return ret

I can use it such as

  str = Rexx "XyZ"

  abc = verb(str.upper, 5, 'Z')

But although it is totally equivalent, I can not use it this way

  str = Rexx "XyZ"

  abc = str.upper.verb(5, 'Z')

When the scanner encounters this, it asks the Rexx class to handle it, but that class knows nothing of it and reports the error.

(In my ignorance) I ask if the scanner, before going to the Rexx class, could check to see if there is a local method with a signature of verb(Rexx, Rexx, Rexx).  If it finds that, it should use it. 

A second step would be in defining a method.  Here, I suggest a new keyword, maybe, Classof classname.  This would permit the use of the classname variable this in its body:

  method verb(len, let) classof Rexx returns Rexx

    ...this...ret=...

    return ret

When the scanner sees this, it thinks:

  method verb(this=Rexx, len, let) returns Rexx

and compiles it as usual.  The original formulation would work equally.

I don't see either of these additions, if implemented, as breaking any existing programs.  I do see them as easing readability and removing a source of surprise.

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



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

Reply | Threaded
Open this post in threaded view
|

Re: Thoughts on Adding methods to compiled classes

rvjansen
In reply to this post by ThSITC
You might also want to look into Java 8 lambda’s, they can do a lot of what you want by having predefined interfaces for the chaining of methods. In Java these are specified inline, where NetRexx can use separate or inner classes. We have an example of that in the distribution:


-- make a string of words with a couple containing the letter 'k'

wordstring=String "Just a bunch of words to test for killer items containing a k"

-- convert the string into a Java List (a Collection):

alist=ArrayList(Arrays.asList(wordstring.split(" ")))

-- now run a filter stream operation on the list
-- using a hard coded Predicate class for a filter instead of a Java lambda expression:
-- (the filter just selects words containing the letter 'k')

sa=alist.stream.filter(Pred()).toArray

-- print the results for verification:

loop y over sa
    say y
    end

say "-----------------------"

    -- now run a foreach operation on a stream
    -- using a hard coded Consumer class instead of a Java lambda 
--     the consumer here just prints inputs with some surrounding brackets

alist.stream.foreach(Eatem())

class Pred implements Predicate
    method test(s=Object) returns boolean
      return Rexx(s.toString).pos('k')>0
     
class Eatem implements Consumer
    method accept(s=Object)
      say ">>"s"<<"
        

Is that something to consider? 

René.


On 29 Mar 2020, at 13:15, Thomas Schneider <[hidden email]> wrote:

HI Jeff,

May I add this to my 'OPEN ISSUES' folder on my Desktop, please ?

Kindly, Thomas Schneider.

===================================================================

Am 28.03.2020 um 21:58 schrieb Jeff Hennick:

In thinking more on the subject of dynamically addi ng methods to already compiled classes, and specifically to the Rexx class, it seems to me to be a very useful mechanism.

Is there a philosophical objection for having this?

Hearing no objections (yet), I will continue from my pinnacle of ignorance.

Currently if I have this definition of a method in some random class

  method verb(rexxObj=Rexx, len, let) returns Rexx

    ...rexxObj...ret=...

    return ret

I can use it such as

  str = Rexx "XyZ"

  abc = verb(str.upper, 5, 'Z')

But although it is totally equivalent, I can not use it this way

  str = Rexx "XyZ"

  abc = str.upper.verb(5, 'Z')

When the scanner encounters this, it asks the Rexx class to handle it, but that class knows nothing of it and reports the error.

(In my ignorance) I ask if the scanner, before going to the Rexx class, could check to see if there is a local method with a signature of verb(Rexx, Rexx, Rexx).  If it finds that, it should use it. 

A second step would be in defining a method.  Here, I suggest a new keyword, maybe, Classof classname.  This would permit the use of the classname variable this in its body:

  method verb(len, let) classof Rexx returns Rexx

    ...this...ret=...

    return ret

When the scanner sees this, it thinks:

  method verb(this=Rexx, len, let) returns Rexx

and compiles it as usual.  The original formulation would work equally.

I don't see either of these additions, if implemented, as breaking any existing programs.  I do see them as easing readability and removing a source of surprise.


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


Virus-free. www.avg.com
<a href="x-msg://16/#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1" class="">
_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/



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

Reply | Threaded
Open this post in threaded view
|

Re: Thoughts on Adding methods to compiled classes

Jeff Hennick-3

Thank you.

I will need to do a lot of learning just to read it.  Example: calling a class as a function to do something with no mention of the method to use.  (I am Rexxian, not Javanese.)

On 3/29/2020 7:30 AM, René Jansen wrote:
You might also want to look into Java 8 lambda’s, they can do a lot of what you want by having predefined interfaces for the chaining of methods. In Java these are specified inline, where NetRexx can use separate or inner classes. We have an example of that in the distribution:


-- make a string of words with a couple containing the letter 'k'

wordstring=String "Just a bunch of words to test for killer items containing a k"

-- convert the string into a Java List (a Collection):

alist=ArrayList(Arrays.asList(wordstring.split(" ")))

-- now run a filter stream operation on the list
-- using a hard coded Predicate class for a filter instead of a Java lambda expression:
-- (the filter just selects words containing the letter 'k')

sa=alist.stream.filter(Pred()).toArray

-- print the results for verification:

loop y over sa
    say y
    end

say "-----------------------"

    -- now run a foreach operation on a stream
    -- using a hard coded Consumer class instead of a Java lambda 
--     the consumer here just prints inputs with some surrounding brackets

alist.stream.foreach(Eatem())

class Pred implements Predicate
    method test(s=Object) returns boolean
      return Rexx(s.toString).pos('k')>0
     
class Eatem implements Consumer
    method accept(s=Object)
      say ">>"s"<<"
        

Is that something to consider? 

René.


On 29 Mar 2020, at 13:15, Thomas Schneider <[hidden email]> wrote:

HI Jeff,

May I add this to my 'OPEN ISSUES' folder on my Desktop, please ?

Kindly, Thomas Schneider.

===================================================================

Am 28.03.2020 um 21:58 schrieb Jeff Hennick:

In thinking more on the subject of dynamically addi ng methods to already compiled classes, and specifically to the Rexx class, it seems to me to be a very useful mechanism.

Is there a philosophical objection for having this?

Hearing no objections (yet), I will continue from my pinnacle of ignorance.

Currently if I have this definition of a method in some random class

  method verb(rexxObj=Rexx, len, let) returns Rexx

    ...rexxObj...ret=...

    return ret

I can use it such as

  str = Rexx "XyZ"

  abc = verb(str.upper, 5, 'Z')

But although it is totally equivalent, I can not use it this way

  str = Rexx "XyZ"

  abc = str.upper.verb(5, 'Z')

When the scanner encounters this, it asks the Rexx class to handle it, but that class knows nothing of it and reports the error.

(In my ignorance) I ask if the scanner, before going to the Rexx class, could check to see if there is a local method with a signature of verb(Rexx, Rexx, Rexx).  If it finds that, it should use it. 

A second step would be in defining a method.  Here, I suggest a new keyword, maybe, Classof classname.  This would permit the use of the classname variable this in its body:

  method verb(len, let) classof Rexx returns Rexx

    ...this...ret=...

    return ret

When the scanner sees this, it thinks:

  method verb(this=Rexx, len, let) returns Rexx

and compiles it as usual.  The original formulation would work equally.

I don't see either of these additions, if implemented, as breaking any existing programs.  I do see them as easing readability and removing a source of surprise.


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


Virus-free. www.avg.com
<a href="x-msg://16/#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1" class="" moz-do-not-send="true">
_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/



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


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

Reply | Threaded
Open this post in threaded view
|

Re: Thoughts on Adding methods to compiled classes

ThSITC
In reply to this post by rvjansen

May I please underline and vote for Rene's plan what to DO next with Pipes and NetRexx as beeing the *right plan* !!! Thank You, Mr President !!! Thomas.

==============================================================================================================================

Am 29.03.2020 um 13:23 schrieb René Jansen:
I might not have this objection , but the philosophical justification for static type checking is avoidance of runtime errors. With the lexer/parse scanning the full file in Object Rexx, instead of the clause based scanning of Rexx on CMS and TSO, people complained that not all execs ran, when in fact there execs contained errors that were outside of the execution path.

The execution of pipelines can be seen as entirely dynamic, as the pipes compiler writes all the source before we feed it to NetRexx. You might want to experiment with extending the Rexx class in there, before we touch the NetRexx translator itself, i.e. the pipes compiler can deliver the tools to NetRexx to do what you want, and we later move it into NetRexx if proven.

René.

On 28 Mar 2020, at 21:58, Jeff Hennick <[hidden email]> wrote:

In thinking more on the subject of dynamically adding methods to already compiled classes, and specifically to the Rexx class, it seems to me to be a very useful mechanism.

Is there a philosophical objection for having this?

Hearing no objections (yet), I will continue from my pinnacle of ignorance.

Currently if I have this definition of a method in some random class

  method verb(rexxObj=Rexx, len, let) returns Rexx

    ...rexxObj...ret=...

    return ret

I can use it such as

  str = Rexx "XyZ"

  abc = verb(str.upper, 5, 'Z')

But although it is totally equivalent, I can not use it this way

  str = Rexx "XyZ"

  abc = str.upper.verb(5, 'Z')

When the scanner encounters this, it asks the Rexx class to handle it, but that class knows nothing of it and reports the error.

(In my ignorance) I ask if the scanner, before going to the Rexx class, could check to see if there is a local method with a signature of verb(Rexx, Rexx, Rexx).  If it finds that, it should use it. 

A second step would be in defining a method.  Here, I suggest a new keyword, maybe, Classof classname.  This would permit the use of the classname variable this in its body:

  method verb(len, let) classof Rexx returns Rexx

    ...this...ret=...

    return ret

When the scanner sees this, it thinks:

  method verb(this=Rexx, len, let) returns Rexx

and compiles it as usual.  The original formulation would work equally.

I don't see either of these additions, if implemented, as breaking any existing programs.  I do see them as easing readability and removing a source of surprise.

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



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


Virus-free. www.avg.com

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

Today

Mike Cowlishaw
In reply to this post by rvjansen
24 years since NetRexx 'GA' (first public release on the WWW)!
 
Mike
 

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

Reply | Threaded
Open this post in threaded view
|

Re: Today

rvjansen
congratulations! How time flies.

Using it every day.

René.

On 22 Apr 2020, at 20:42, Mike Cowlishaw <[hidden email]> wrote:

24 years since NetRexx 'GA' (first public release on the WWW)!
 
Mike
 
_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/



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

Reply | Threaded
Open this post in threaded view
|

Re: Today

Mike Cowlishaw
:-)



congratulations! How time flies.

Using it every day.

René.

On 22 Apr 2020, at 20:42, Mike Cowlishaw <[hidden email]> wrote:

24 years since NetRexx 'GA' (first public release on the WWW)!
 
Mike

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

Reply | Threaded
Open this post in threaded view
|

Re: Today

Jason Martin
In reply to this post by Mike Cowlishaw
It ranks as one of the greatest software engineering feats in my forty
years using computers.

It needed to be shared, so that those that follow can see how much can
be done with so little.

:-)

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

Reply | Threaded
Open this post in threaded view
|

Re: Today

Mike Cowlishaw
:-))

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Jason Martin
> Sent: 22 April 2020 19:52
> To: IBM Netrexx
> Subject: Re: [Ibm-netrexx] Today
>
> It ranks as one of the greatest software engineering feats in
> my forty years using computers.
>
> It needed to be shared, so that those that follow can see how
> much can be done with so little.
>
> :-)
>
> _______________________________________________
> Ibm-netrexx mailing list
> [hidden email]
> Online Archive : https://urldefense.proofpoint.com/v2/url?u=http-3A__ibm-2Dnetrexx.215625.n3.nabble.com_&d=DwICAg&c=jf_iaSHvJObTbx-siA1ZOg&r=_6rXNpPJ1fYV-3bV1za02NiR4PUelvicfHXwtnTXpXE&m=mhMqJ1zT9gG8ifcgmophLkBj3CG8rIvTzrMeLQZjERk&s=etE9nyCyhh4UWQ-99xw3FDmcmH01O5phbW56cuq1rVw&e= 
>

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

Reply | Threaded
Open this post in threaded view
|

Re: Today

ThSITC
In reply to this post by Jason Martin
Hello Alan, there:

I do fully support Your message below ...

As I am now also on SourceForge, Project NetRexx, there,as well a my
private Project 'thsitc', as my first step I did enter a REVIIEW of
NetRexx there at SF Project Netrexx:

As already said, multiple times, NeTrexx is the best computer language
I've ever seen, and NetRexxC is the best compiler I have ever worked with !

Congratulations, MFC; and the whole development team !

Thomas.

www.db-123.com

www.thsitc.com

=======================================================================

Am 22.04.2020 um 20:52 schrieb Jason Martin:

> It ranks as one of the greatest software engineering feats in my forty
> years using computers.
>
> It needed to be shared, so that those that follow can see how much can
> be done with so little.
>
> :-)
>
> _______________________________________________
> Ibm-netrexx mailing list
> [hidden email]
> Online Archive : https://urldefense.proofpoint.com/v2/url?u=http-3A__ibm-2Dnetrexx.215625.n3.nabble.com_&d=DwICaQ&c=jf_iaSHvJObTbx-siA1ZOg&r=_6rXNpPJ1fYV-3bV1za02NiR4PUelvicfHXwtnTXpXE&m=99DaDK2_8W6ilDrtMybqlbR2WJHwsLGbyuKLbFJlkq4&s=08UvIq8s6rMD9Fx6qm4bm9mzK7TejBDiFhtRO7Ufbp8&e= 
>

--
This email has been checked for viruses by AVG.
https://urldefense.proofpoint.com/v2/url?u=https-3A__www.avg.com&d=DwICaQ&c=jf_iaSHvJObTbx-siA1ZOg&r=_6rXNpPJ1fYV-3bV1za02NiR4PUelvicfHXwtnTXpXE&m=99DaDK2_8W6ilDrtMybqlbR2WJHwsLGbyuKLbFJlkq4&s=Z9G-ETtbyZvuXj6ixB7fT4TDBmWjUoP_S3yxKlGWSLk&e= 

_______________________________________________
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: Today

Michael (maillists) Dag
In reply to this post by Mike Cowlishaw

I said it before… without REXX my professional career would be totally different…

 

From REXX/VM/CMS (1985) to rexxsaa on OS/2 to NetRexx now…

 

**Thank you**

 

Michael Dag

 

From: [hidden email] <[hidden email]> On Behalf Of Mike Cowlishaw
Sent: woensdag 22 april 2020 20:42
To: 'IBM Netrexx' <[hidden email]>
Subject: [Ibm-netrexx] Today

 

24 years since NetRexx 'GA' (first public release on the WWW)!

 

Mike

 


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

Reply | Threaded
Open this post in threaded view
|

Re: Today

ThSITC

As I said before ...

I am just dekivering Rexx2RTP to the public ...

Rexx2RTP is just impementing any and all so called FUNCTIONAL interfaces to NetRexx as well.

Any problems: Just give me a chat .-)

Thanks,

Thomas Schneider.

www.thsitc.com

www.db-123.com

=======================================================================================

Am 25.04.2020 um 15:48 schrieb maillists (@MQSystems):

I said it before… without REXX my professional career would be totally different…

 

From REXX/VM/CMS (1985) to rexxsaa on OS/2 to NetRexx now…

 

**Thank you**

 

Michael Dag

 

From: [hidden email] [hidden email] On Behalf Of Mike Cowlishaw
Sent: woensdag 22 april 2020 20:42
To: 'IBM Netrexx' [hidden email]
Subject: [Ibm-netrexx] Today

 

24 years since NetRexx 'GA' (first public release on the WWW)!

 

Mike

 


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


Virus-free. www.avg.com

_______________________________________________
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