Shop OBEX P1 Docs P2 Docs Learn Events
Do modules have a separate namespace ? — Parallax Forums

Do modules have a separate namespace ?

peterzpeterz Posts: 59
edited 2007-01-08 21:17 in Propeller 1
I have tried to use a module twice just keeping the same code.
I want·to have the same initialization and configuration routines in both modules.
Each module launches an ASM routine with a call to cognew that is different for each module.
All functions and names are the same on both modules.

It compiles ok but it does not work. If I remove one of the modules the other works okay.
So, I am guesing there is some relation between both modules.

Are the names (functions, vars, labels, etc) separate spaces for each module ?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-01-08 21:12
    There are separate namespaces for each module. There is a comparison of the binary code for each module such that, if the binary is a match, only one copy is loaded (at least that's how I understand it). Since there's a different call to cognew, the binaries will be different.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-01-08 21:17
    If you are loading two instances of the same object, each object will create it's own copy of the VAR space, however any variables declared in DAT are shared. Any variables which are not part of an assembly code space (ie they are not loaded into a cog before values are manipulated) will be shared among all instances, this can have unintended consequences if your code doesn't expect this behaviour.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
Sign In or Register to comment.