Shop OBEX P1 Docs P2 Docs Learn Events
Question about Calling Objects — Parallax Forums

Question about Calling Objects

grasshoppergrasshopper Posts: 438
edited 2008-06-22 13:57 in Propeller 1
If I used several objects and some of the objects call the "same object" more than once will this chew up double the space in memory?

For example


OBJ

H1 : "math"
Flo : "Float32"





And in my math object it would have


f  : "Float32"





This is only 2 examples but what if i were to have some 13 or more objects that called some other objects over and over?

Comments

  • hippyhippy Posts: 1,981
    edited 2008-06-22 05:24
    No, each "same object" code is only included once in the final image.
  • BradCBradC Posts: 2,601
    edited 2008-06-22 06:22
    Multiple instances of the same object are also useful.. A neat trick I only recently discovered

    OBJ
    ow : "One_Wire_P_003"

    PUB Start | i
    repeat i from 0 to 2
    ow.Start(pin+i)

    The compiler is quite intelligent in the way it allocates object space. Anything in VAR is duplicated as required, while the object code and DAT space are simply used once and called as is desired.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Pull my finger!

  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-06-22 06:52
    If you want to use 1 copy of float32 in more than 1 object than you will have to change the var section to a dat section. If you do this you will also need to ensure that you don't call it from two cogs at the same time. If you do than you may mess up some of the results smile.gif
  • grasshoppergrasshopper Posts: 438
    edited 2008-06-22 13:57
    hippy said...
    No, each "same object" code is only included once in the final image.

    Thanks this is what I was hoping the case would be.
Sign In or Register to comment.