--- mattschinkel <[email protected]> schrieb am Mo, 13.12.2010:
> Von: mattschinkel <[email protected]> > Betreff: [jallib] Re: Delivery Status Notification (Failure) > An: "jallib" <[email protected]> > Datum: Montag, 13. Dezember, 2010 03:56 Uhr > There is something that could be used > like a goto. Here you can see > that I call a procedure within it's own procedure: > > var byte my_var = 0 > procedure test() is > for 10 loop > my_var = my_var + 1 > if my_var == 5 then > test() > end if > end loop > end procedure > > test() > > It does make it had to follow. Can you tell what the end > value of > my_var will be? :) It's not called "goto", but recursion. The documentation of JALv2 mentions that this is possible, but it is discouraged becatse it can use a lut of return stack. PICs are generally limited regarding return stack. my_var should be 20, I think. A popular example of recursion is the calculation of the factorial. x!= x*(x-1)*(x-2)*...*2*1 function factorial (byte in x) return byte*65 is if x==0 then return 1 else return factorial(x-1) * x end if end function Its very elegant. Though neither fast nor cheap on resources. Especially because it needs a stack depth of "x+2", it will not make much sense on PIC controllers. Greets, Kiste -- You received this message because you are subscribed to the Google Groups "jallib" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/jallib?hl=en.
