HISE Logo Forum
    • Categories
    • Register
    • Login

    Namespaces in Javascript

    Scheduled Pinned Locked Moved Blog Entries
    13 Posts 2 Posters 3.2k 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

      I thought so but wanted to check before I re-downloaded the current build

      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

        Alright, Build 646 is online.

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

          That was quick :D

          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

            Can this be used within a namespace to refer to its own functions?

            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

              Nope, this is reserved for object properties.

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

                What about creating another keyword like self?

                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

                  Adding Python to the melting pot, I like it :)

                  Why do you need this? I would indeed prefer adding a new keyword like self, but I can't see any advantage yet.

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

                    If we're at it, what do you think about a private keyword?

                    namespace MyEncapsulatedStuff
                    {
                        private var internals = "Hidden";
                    
                        inline function getHiddenProperty()
                        {
                            return self.internals; // :)
                        };
                    };
                    
                    Console.print(MyEncapsulatedStuff.internals); // undefined
                    Console.print(MyEncapsulatedStuff.getHiddenProperty()); // "Hidden"
                    

                    It would solve the problem of the weird Javascript encapsulation tactics.

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

                      A self keyword will be helpful for example when I have functions within a namespace that refer to each other and to private namespaced variables. Rather than writing out the namespace's name I could just put self and if I decide to change the namespace name I won't need to adjust the function and variable references within the namespace. The private keyword is a good idea :)

                      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

                        You could also skip the namespace. and write the variable name without prefix. This will work even if there are global variables with the same name.

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

                        22

                        Online

                        1.7k

                        Users

                        11.8k

                        Topics

                        102.8k

                        Posts