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?

]]>

5 Commentsto Scope

  1. Anonymous says:

    < ![CDATA[

    Are we not still in beta?

    ]]>

  2. Anonymous says:

    < ![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.

    ]]>

  3. Anonymous says:

    < ![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.

    ]]>

  4. Anonymous says:

    < ![CDATA[

    May there be any problems runScript(‘name’, data)… if script name can be same with different internal id?

    ]]>

  5. Anonymous says:

    < ![CDATA[

    Yes indeed, the first one will be executed, so this is somewhat random

    ]]>

Leave a Reply

Your email address will not be published. Required fields are marked *