Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
hyperPad

hyperPad Forum

  1. Home
  2. General Discussion
  3. Best way to make functions?

Best way to make functions?

Scheduled Pinned Locked Moved General Discussion
11 Posts 4 Posters 3.2k Views 1 Watching
  • 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.
  • RyanAndChadR Offline
    RyanAndChadR Offline
    RyanAndChad
    wrote on last edited by RyanAndChad
    #1

    What's the best way to make a function?
    I just want a block of code that I can use repeatedly with an input and an output :O

    Edit: I think it's possible with Dictionaries and Broadcast/Recieve message. I'm using the dictionary to store arguments and outputs. But I have some questions.

    1. when a dictionary is passed through broadcast to recieve, is the pointer passed, or the value? Is it possible to use a pointer to the dictionary?

    2. if I call a behavior bundle, will the next block execute immediately or once that behavior bundle has completed?

    Michael KhalfinG Aidan_FireA 2 Replies Last reply
    0
    • RyanAndChadR RyanAndChad

      What's the best way to make a function?
      I just want a block of code that I can use repeatedly with an input and an output :O

      Edit: I think it's possible with Dictionaries and Broadcast/Recieve message. I'm using the dictionary to store arguments and outputs. But I have some questions.

      1. when a dictionary is passed through broadcast to recieve, is the pointer passed, or the value? Is it possible to use a pointer to the dictionary?

      2. if I call a behavior bundle, will the next block execute immediately or once that behavior bundle has completed?

      Michael KhalfinG Offline
      Michael KhalfinG Offline
      Michael Khalfin
      wrote on last edited by
      #2

      @domination I was wondering this too.

      1 Reply Last reply
      0
      • RyanAndChadR RyanAndChad

        What's the best way to make a function?
        I just want a block of code that I can use repeatedly with an input and an output :O

        Edit: I think it's possible with Dictionaries and Broadcast/Recieve message. I'm using the dictionary to store arguments and outputs. But I have some questions.

        1. when a dictionary is passed through broadcast to recieve, is the pointer passed, or the value? Is it possible to use a pointer to the dictionary?

        2. if I call a behavior bundle, will the next block execute immediately or once that behavior bundle has completed?

        Aidan_FireA Offline
        Aidan_FireA Offline
        Aidan_Fire
        wrote on last edited by
        #3

        @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
        0
        • Aidan_FireA Aidan_Fire

          @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 Offline
          RyanAndChadR Offline
          RyanAndChad
          wrote on last edited by
          #4

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

          D 1 Reply Last reply
          0
          • RyanAndChadR RyanAndChad

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

            D Offline
            D Offline
            Deeeds
            wrote on last edited by
            #5

            @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
            0
            • D Deeeds

              @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 Offline
              RyanAndChadR Offline
              RyanAndChad
              wrote on last edited by RyanAndChad
              #6

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

              D 1 Reply Last reply
              0
              • RyanAndChadR RyanAndChad

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

                D Offline
                D Offline
                Deeeds
                wrote on last edited by
                #7

                @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
                0
                • D Deeeds

                  @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 Offline
                  RyanAndChadR Offline
                  RyanAndChad
                  wrote on last edited by
                  #8

                  @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
                  1
                  • RyanAndChadR RyanAndChad

                    @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 Offline
                    D Offline
                    Deeeds
                    wrote on last edited by
                    #9

                    @domination said in Best way to make functions?:

                    This method probably doesn't have optimal performance either.

                    good pun!!!!

                    RyanAndChadR 1 Reply Last reply
                    0
                    • RyanAndChadR RyanAndChad

                      @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 Offline
                      D Offline
                      Deeeds
                      wrote on last edited by
                      #10

                      @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
                      0
                      • D Deeeds

                        @domination said in Best way to make functions?:

                        This method probably doesn't have optimal performance either.

                        good pun!!!!

                        RyanAndChadR Offline
                        RyanAndChadR Offline
                        RyanAndChad
                        wrote on last edited by RyanAndChad
                        #11

                        good pun!!!!

                        @Deeeds not intended

                        1 Reply Last reply
                        0

                        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                        With your input, this post could be even better 💗

                        Register Login
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Search