HISE Logo Forum
    • Categories
    • Register
    • Login

    Limits on Recursion?

    Scheduled Pinned Locked Moved Solved Scripting
    3 Posts 2 Posters 126 Views
    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.
    • clevername27C
      clevername27
      last edited by

      Does anyone know the limit on recursion for inline functions? Are there exceptions, or can an inline function never (ever) call itself?

      Thanks!

      oskarshO 1 Reply Last reply Reply Quote 0
      • oskarshO
        oskarsh @clevername27
        last edited by

        @clevername27

        recursion works. try at your own risk.

        I believe it is also dependant on what parameters you pass, for a simple int it should not be that bad but passing down huge objects might cause it to give up sooner since in theory it consumes more memory.

        
        inline function count(currentNumber)
        {
            if(currentNumber <= 100)
            {
                Console.print("Count: " + currentNumber);
                count(currentNumber + 1); // Recursive call
            }
        }
        
        // Start the recursion with 1
        count(1);
        
        clevername27C 1 Reply Last reply Reply Quote 1
        • clevername27C
          clevername27 @oskarsh
          last edited by

          @oskarsh Thank you - that makes sense. This simplifies my code immensely.

          I was thinking that a lot of recursion - like a recursive descent parser - would be too much. I know there are some error messages that HISE throws to protect against recursion (which is a good thing), but apparently doing it one layer deep is cool.

          1 Reply Last reply Reply Quote 0
          • clevername27C clevername27 has marked this topic as solved on
          • First post
            Last post

          15

          Online

          1.8k

          Users

          12.0k

          Topics

          104.8k

          Posts