Post Reply 
How do I create a Subroutine using System RPL?
09-28-2022, 10:10 PM (This post was last modified: 09-29-2022 02:17 PM by wmundstock.)
Post: #6
RE: How do I create a Subroutine using System RPL?
Thank very much David!
So much useful information on such a small message...

(09-18-2022 03:14 AM)DavidM Wrote:  What is the development tool you're using here?
I am using Debug4X.

(09-18-2022 03:14 AM)DavidM Wrote:  "NULLNAME <objectname>" would create a reference for a hidden subroutine if the code is included in a project that is targeting a library for output.
That was definitely it. I was not compiling it as a library. How would one do a subroutine in a regular program that is not installed as a library?
I found the following example, but seems rather overly complicated for something simple.
Code:
RPL 
( C:\Users\User\Documents\HP Projects\SystemRPL\NonLibrarySubroutines\CMP.s, part of the NonLibrarySubroutine.hpp project, created by <> on 29/09/2022 )

* Main program starts here
::

    ' ( puts next object into the stack, in this case some short code )
    ::
       "Equal are the values"
    ;
    
    ' ( puts the second function to the stack )
    ::
       "Different are the values"
    ;
    
    ( Name each one of the LAMS as below. )
    { LAM ValuesAreEqual
            LAM ValuesAreDifferent }
            
    BIND ( This "stores the LAMs - creates temporary context )
    ( Carry on with your MAIN program )
    CK2&Dispatch
 REALREAL ::  ( note: REALREAL is in ROM and defined as #00011 )
    %= ITE
       LAM ValuesAreEqual ( this is how to call a LAM )
       LAM ValuesAreDifferent
 ;
        ABND ( Purge the temporary variables ).
        
;


(09-18-2022 03:14 AM)DavidM Wrote:  Also worth noting: the calling program object you've shown may work, but is inefficient in structure. While it is sometimes necessary to have nested dispatch scenarios, this isn't one of the situations where you would go that route. This situation is actually a straightforward application of the normal dispatch model, which accommodates a check for two reals as it appears you need here.
I was not aware of this form that you presented with the REALREAL, thanks for sharing this! Much easier and more efficient this way!

(09-18-2022 03:14 AM)DavidM Wrote:  Technically speaking, there's also no need for the "::" and ";" with the two NULLNAME procedures, since there's only a single object being encapsulated. But it will work just fine with them as-is.
Awesome! I was not aware of that either. Thanks for the note.

I have a final question here, how would one learn about the REALREAL thing? I found references of it in the document Programming in System RPL Second Edition, but nothing self explanatory. Is there another documentation that you recommend?

Again, thanks for sharing your knowledge!
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: How do I create a Subroutine using System RPL? - wmundstock - 09-28-2022 10:10 PM



User(s) browsing this thread: 2 Guest(s)