HISE Logo Forum
    • Categories
    • Register
    • Login

    Local variables reset

    Scheduled Pinned Locked Moved Feature Requests
    5 Posts 2 Posters 856 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.
    • d.healeyD
      d.healey
      last edited by

      Could we have a way, perhaps a keyword, that would allow variables declared within functions to retain their value. Currently the only way I see to do this is to declare the variables outside of the function.

      Libre Wave - Freedom respecting instruments and effects
      My Patreon - HISE tutorials
      YouTube Channel - Public HISE tutorials

      1 Reply Last reply Reply Quote 0
      • Christoph HartC
        Christoph Hart
        last edited by

        Why would you want to do that? It introduces all kinds of problems with reference counting which could lead to memory leaking if the local scope doesn't get cleaned (I explicitly added resetting local variables to prevent this).

        For what scenario would you need to retain the local values?

        1 Reply Last reply Reply Quote 0
        • d.healeyD
          d.healey
          last edited by

          It's not a big deal, I can definitely live without it but thought I'd ask in case it was something simple to add. For example I have a legato function that stores the time the last legato note was played and checks it when the next legato note is played to determine what action to take. This variable is only needed within the legato function so declaring it globally just adds a bit of clutter.

          Libre Wave - Freedom respecting instruments and effects
          My Patreon - HISE tutorials
          YouTube Channel - Public HISE tutorials

          1 Reply Last reply Reply Quote 0
          • d.healeyD
            d.healey
            last edited by

            I've actually rethought this and decided to take a more modular approach to my script so this feature is probably not important at all, unless someone else needs it.

            Libre Wave - Freedom respecting instruments and effects
            My Patreon - HISE tutorials
            YouTube Channel - Public HISE tutorials

            1 Reply Last reply Reply Quote 0
            • Christoph HartC
              Christoph Hart
              last edited by

              Well, there is only you and me until now :)

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

              53

              Online

              1.7k

              Users

              11.7k

              Topics

              101.8k

              Posts