Shop OBEX P1 Docs P2 Docs Learn Events
Recursion — Parallax Forums

Recursion

KyeKye Posts: 2,200
edited 2009-04-10 09:22 in Propeller 1
Can the propeller chip do this? I mean it has a stack, so...

I'm thinking not from hints I've gathered but does anyone have the definitive word.

Thanks,

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Comments

  • MagIO2MagIO2 Posts: 2,243
    edited 2009-04-09 19:35
    Of course ... if you have stack than you can have recursion. But the number of recursive calls is limited by the stack size - which is -as you know- very limited especially when your program gets bigger.

    And to be honest, I'd never use recursion on a limited system like the propeller. You can always change recursive code to be iterative.
  • rokickirokicki Posts: 1,000
    edited 2009-04-09 19:46
    Femtobasic uses recursion in its expression parser.
  • KyeKye Posts: 2,200
    edited 2009-04-09 23:18
    Okay, I just wanted to know, thanks.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • scottascotta Posts: 168
    edited 2009-04-10 04:36
    Kye,

    I've used it a few times, the Spin interpreter gets it correct as always but the
    stack limits your function recursion level.

    Scott
  • virtuPICvirtuPIC Posts: 193
    edited 2009-04-10 09:22
    Kye,

    the propeller does not provide a hardware stack. We have a very RISCy machine. For recursion in assembler you have to implement it in software. Recursion in compiled code depends on the compiler - does it implement the stack or not? (Yes, I'm told that the C-compiler does.) Recursion in interpreted code depends on the interpreter. Here you need an explicit stack data structure anyway. Yes, SPIN provides it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Airspace V - international hangar flying!
    www.airspace-v.com/ggadgets for tools & toys
Sign In or Register to comment.