General Questions/Statements
eldonb46
Posts: 70
As a new user of the Propeller, I think I have come to the following general conclusions:
Please help; Are the following statements true for a general Spin Programming strategy?
Note: Considering the above, I suspect the COG #8 is almost never used by most Spin Programmers.
Please help my (our) understanding as a new user.
Thanks
eldonb46
Please help; Are the following statements true for a general Spin Programming strategy?
- A Parent Object can call any Child Object's PUB Method.
- A Parent Object can NOT "directly" call a Grandchild's PUB Method.
- A Child Object can NOT call a Parent or Grandparent's Method.
- An Object can NOT contain a Parent or Grandparent Object (error: circular reference).
- A Child Object can NOT call a Sibling's Method.
- A COG can NOT call it's Parent's Child COG's Method (see previous point).
- A COG can call it's spawning-Objects Methods
- A COG can call it't spawning-Objects Child Methods
- Except for a single task, Child COG needs to be set up as a Server.
- An Object contained in Two other Objects is not a single Object, but will be clones with separate variable space.
Note: Considering the above, I suspect the COG #8 is almost never used by most Spin Programmers.
Please help my (our) understanding as a new user.
Thanks
eldonb46
Comments
1,2,3 yes
4 why should I code this way?
5 what's a sibling's method?
6 what's a spawning object?
9 what's in this case a server and what's the difference to a "client"
best regards
Stefan
Welcome to the forum!
1,2,3,4: true
5: false You can call a sibling's public methods if the sibling object is declared in the OBJ section, as long as the sibling does not call yours, since there's no circular dependency.
6: false, under the same circumstances that 5 is false. (They're actually the selfsame statements.)
7, 8: I don't understand "spawning" in this context.
9: Half true. An object's VAR variables are cloned. Everything else exists as a single instance.
-Phil
Thanks, I think I see the problem with my statement, and
Perhaps I am using the wrong word here: spawn ~= A method that calls cognew
main
+ child obj
+++ cognew A
+++++ cognew B
I think I understand, because both cogs would be from the same Parent Object, they would be siblings regardless of how they were created (spawned). And they can call their Parent Object Methods?
Are these now correct?
7. A COG can call it's Parent-Objects Methods
7.5. A COG that creates a new COG, creates a Sibling
8. A COG can call it't Sibling's Methods
Obviously this is still a little confusing to me.
Thanks for all of helpful comments
eldonb46
Can code running in one cog access data or code (methods) in another.
If you start up an assembly language program in a cog, that program has complete access to the cog, its memory, its I/O registers, and all of the hub RAM and ROM. It has no access to the memory of any other cog. The only thing it can do to another cog is reset it (using COGSTOP) or start up a new assembly or Spin program in that cog.