Old 04-06-2014, 12:18 PM   #1
BobC
Human being with feelings
 
Join Date: Mar 2014
Posts: 19
Default Relative Namespaces

Is there documentation anywhere that explains the use of relative namespaces in JS. What's written at http://reaper.fm/sdk/js/userfunc.php#js_userfunc is merely a mention and I can't figure out much of anything from it.

Thanks

Last edited by BobC; 04-06-2014 at 12:36 PM.
BobC is offline   Reply With Quote
Old 04-07-2014, 04:43 AM   #2
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

There's not much to it. this. refers to variables/functions in the current namespace. this.. refers to stuff in the parent namespace. this... refers to stuff in the grandparent namespace and so on.
IXix is offline   Reply With Quote
Old 04-09-2014, 05:22 PM   #3
BobC
Human being with feelings
 
Join Date: Mar 2014
Posts: 19
Default

Quote:
Originally Posted by IXix View Post
There's not much to it. this. refers to variables/functions in the current namespace. this.. refers to stuff in the parent namespace. this... refers to stuff in the grandparent namespace and so on.
Uh, thanks, I think. :-)

Unfortunately that makes it no clearer at all for me. Got a few more words on the subject?
BobC is offline   Reply With Quote
Old 04-10-2014, 01:13 AM   #4
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
Default

Just in case, you di see this?

http://www.cockos.com/reaper/sdk/js/...hp#js_userfunc

I just tried a few experiments of my own to understand it (but have not used it so far )
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar is online now   Reply With Quote
Old 04-10-2014, 09:20 AM   #5
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Quote:
Originally Posted by BobC View Post
Got a few more words on the subject?
There's not much to it really. Just try it for yourself until it makes sense.
IXix is offline   Reply With Quote
Old 04-10-2014, 09:31 AM   #6
Banned
Human being with feelings
 
Banned's Avatar
 
Join Date: Mar 2008
Location: Unwired (probably in the proximity of Amsterdam)
Posts: 4,868
Default

Quote:
Originally Posted by DarkStar View Post
Just in case, you di see this?

http://www.cockos.com/reaper/sdk/js/...hp#js_userfunc

I just tried a few experiments of my own to understand it (but have not used it so far )
Well, apart from namespaces, being able to define functions is *awesome*. Tediously copy/pasting repetitive code not so much.
__________________
˙lɐd 'ʎɐʍ ƃuoɹʍ ǝɥʇ ǝɔıʌǝp ʇɐɥʇ ƃuıploɥ ǝɹ,noʎ
Banned is offline   Reply With Quote
Old 04-10-2014, 01:46 PM   #7
BobC
Human being with feelings
 
Join Date: Mar 2014
Posts: 19
Default

Quote:
Originally Posted by IXix View Post
There's not much to it really. Just try it for yourself until it makes sense.
The doc section on this is a bit to "economical" to help me. I don't even know what to try. (and "trying" with this thing is tedious at best)

I also see mention of @ and * operators here and there but there is no mention in the document of them. Are they for something other than JS?
BobC is offline   Reply With Quote
Old 04-11-2014, 12:53 AM   #8
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Quote:
Originally Posted by BobC View Post
The doc section on this is a bit to "economical" to help me. I don't even know what to try. (and "trying" with this thing is tedious at best)

I also see mention of @ and * operators here and there but there is no mention in the document of them. Are they for something other than JS?
@ is only for the code sections @sample, @block etc.

* is multiplication (ie. x * y) but is also used in function declarations to denote that an argument is a namspace...
Code:
function SetFoo(n*)
(
  n.foo = 1;
);

SetFoo(a); // sets a.foo
SetFoo(b); // sets b.foo
The relative namespaces work like this...
Code:
function SetParentFoo()
(
  this..foo = 1;
);

c.d.SetParentFoo(); // sets c.foo
Does that make sense?
IXix is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 09:01 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.