logo hyperPad Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Login

    Best way to make functions?

    Scheduled Pinned Locked Moved
    General Discussion
    4
    11
    1.5k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • GameCRAZYG
      GameCRAZY @RyanAndChad
      last edited by

      @domination I was wondering this too.

      1 Reply Last reply Reply Quote 0
      • Aidan_FireA
        Aidan_Fire @RyanAndChad
        last edited by

        @domination A function as in like a calculation? Behaviour blocks execute from top to bottom THEN left to right. Say if you have a receive message, with a behaviour bundle under it, stuff under the behaviour bundle then some other behaviour to the right of the behaviour bundle, everything underneath the behaviour bundle will happen first, then whatever was to the right of the behaviour bundle. If that makes sense 🙂

        RyanAndChadR 1 Reply Last reply Reply Quote 0
        • RyanAndChadR
          RyanAndChad @Aidan_Fire
          last edited by

          @aidan-oxley I meant a function as in regular code.

          D 1 Reply Last reply Reply Quote 0
          • D
            Deeeds @RyanAndChad
            last edited by

            @domination

            Can you give me an idea of your favourite other programming languages and environments so I can explain it in those terms and help you see how to do something like functions in hyperPad?

            @Aidan-Oxley has come up through learning coding via hyperPad, so far as I know.

            And hyperPad doesn't have functions as seen in regular paradigms of the majority of common programming languages.

            You can do a faking of the sort of separation you get from functions by using messaging, but it's not really the same thing, and seems to have diabolical impact on build time when used between layers and many objects.

            It will take some time to explain, though, hence the request for some background info on what you know to help communicate this as fast as possible.

            RyanAndChadR 1 Reply Last reply Reply Quote 0
            • RyanAndChadR
              RyanAndChad @Deeeds
              last edited by RyanAndChad

              @deeeds I'm currently using Go. Know JavaScript as well and a little bit of C++.

              D 1 Reply Last reply Reply Quote 0
              • D
                Deeeds @RyanAndChad
                last edited by

                @domination

                func myFunction(parameterA, parameterB int) returnValue int  {}
                

                is possible to replicate, but you have to jump through hoops.

                Firstly, there's no way to send more than one thing in a message, which is the best way to make this possible. So instead of sending the values for parameters in the function call, it's best to set values in a storage container to be used by the function.

                How to think of this:

                Message Broadcast with Name is the function call. The message title (Key) can be thought of as the name of the function. The Broadcast value can be used as a tool for overloading, to pass into the function or to determine what the function does.

                A Box Container, Dictionary, Array or set of Value Behaviours can be used to store the parameter values.

                The receiver of the message holds the function, and looks to the container(s) for parameter values to operate on. In the same way, the "function" can send/store values to known containers for the return, and call any other behaviours to either execute them, turn them on and execute them, turn them on/off to change their state and/or send a message to another "function" receiver.

                RyanAndChadR 1 Reply Last reply Reply Quote 0
                • RyanAndChadR
                  RyanAndChad @Deeeds
                  last edited by

                  @deeeds this is similar to what I had going before.
                  I used the message key as the name and sent a dictionary through the message value. A callback key could also be sent in the argument dictionary so when the function finishes, it can broadcast a message back to the caller.

                  e.g:
                  http://bit.ly/2CLVQTD

                  But I still have a few concerns. If I call the function again before it finishes, it will be interrupted. Also, it's a lot of junk to work with to do something that should be simple and would be beneficial.
                  This method probably doesn't have optimal performance either.

                  D 2 Replies Last reply Reply Quote 1
                  • D
                    Deeeds @RyanAndChad
                    last edited by

                    @domination said in Best way to make functions?:

                    This method probably doesn't have optimal performance either.

                    good pun!!!!

                    RyanAndChadR 1 Reply Last reply Reply Quote 0
                    • D
                      Deeeds @RyanAndChad
                      last edited by

                      @domination said in Best way to make functions?:

                      Also, it's a lot of junk to work with to do something that should be simple and would be beneficial.

                      agreed!!!!!!!!!!!!

                      https://forum.hyperpad.com/topic/771/known-issues-limitations-of-hyperpad

                      1 Reply Last reply Reply Quote 0
                      • RyanAndChadR
                        RyanAndChad @Deeeds
                        last edited by RyanAndChad

                        good pun!!!!

                        @Deeeds not intended

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post