Scope
Scope
I’m making Window7 mocking template for uploading Play Store. Mine uses several scripts.
Questions:
1.
If a user already used self.foo variable in his scripts, and my template does too, then two self.foo variables interferes?
2.
How about script name?
(I could create a script with same name)
So if I want to distribute a temple with scripts, then should I myself consider something like specific name prefix?
]]>« https://app.box.com/s/0wyy94qs6mtaatds5r9v (Previous Post)
< ![CDATA[
Are we not still in beta?
]]>
< ![CDATA[
I also think that upload the template now is not a good idea.
However they are good questions for Pierre Hébert to answer.
]]>
< ![CDATA[
1) Yes, variables may interfere because self is shared (this is the root object). If you fear a name clash, then a possibility to reduce conflicts is to store a single object in self, with a complex enough name, and store local properties in it, for instance:
self._kjl = new Object();
self._kjl.foo=3;
self._kjl.bar=”e”;
2) script names are not unique but they have an internal unique id. When merging templates, scripts will be merged only if their name and content are equals. Otherwise you may have several scripts with the same name but different content. If you plan to share a template, it may be a good idea to use a prefix indeed.
]]>
< ![CDATA[
May there be any problems runScript(‘name’, data)… if script name can be same with different internal id?
]]>
< ![CDATA[
Yes indeed, the first one will be executed, so this is somewhat random
]]>