Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    Higher order functions?

    Help
    6
    7
    308
    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.
    • S
      SpencerBeige last edited by

      Hi, I wanted to see if Higher-Order functions were a thing in Fuze, so I used the following test code:

      function test(color)
        clear(color)
        update()
      return void
      
      function test2(f)
        f(fuzeblue)
      return void
      
      test2(test())
      

      The idea is to pass test() as an input to test2(), however this didn't work.

      Does anyone know the correct syntax for higher order functions? Or maybe whether they exist in Fuze?

      1 Reply Last reply Reply Quote 0
      • R
        Richard F last edited by

        If you want to use a value from a function you need to return that value
        Eg return colour

        1 Reply Last reply Reply Quote 0
        • PB____
          PB____ last edited by PB____

          As far as I know the only type of delegation that FUZE currently supports is with setTimer (link).

          Discostew 1 Reply Last reply Reply Quote 1
          • Discostew
            Discostew F @PB____ last edited by

            @PB____ Yes, but I believe delegation in general was something being planned, like having function names in an array, so we can just call the array element.

            1 Reply Last reply Reply Quote 0
            • Martin
              Martin Fuze Team last edited by Martin

              Function pointers do not exist in Fuze, therefore you cannot pass a funtion as a parameter to a function.

              Please remember that while not any specific BASIC, Fuze is loosely based on BASIC. There are a lot of people that seem to want to have vastly complex things in Fuze but this is not what it is about. It's not C, C++, C# or Swift.

              1 Reply Last reply Reply Quote 0
              • PB____
                PB____ last edited by

                I would agree that FUZE at this point is not at all ready for advanced features like implicit delegation and lambda expressions. I would think there are many different priorities that come before it. And it might never be ready, since it's purpose is recreational and educational, not professional.

                I do disagree with the reasoning that this is because it is in the BASIC family. Since there are BASIC languages that do support those features. In the end, it's more about where you choose to go with this.

                1 Reply Last reply Reply Quote 0
                • vinicity
                  vinicity F last edited by

                  I saw that Jaywalker had a hack that sort of does function references...

                  Here: https://fuzearena.com/forum/topic/642/function-references/4

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