|
|
Leo80s <nomail@nomail> wrote:
> I tried your piece of code and it works but I need to use recursion with
> element of an array...so I've modified your code in this way:
Again, you are trying to use SDL in user-defined functions, even though
I just explained that you can't do that.
You can use SDL to *build* functions, but you can't use SDL *from*
functions. In this specific case, you can't make a function which uses
an SDL array because an array is an SDL element and user-defined functions
do not support arrays.
It's a bummer, but it's just the way it works.
(There's a *reason* for it to work this way, though: Unlike the SDL,
user-defined functions are internally byte-compiled, which makes their
evaluation extremely fast. I estimate that evaluating a user-defined
function is more than 10 times faster than evaluating eg. an equivalent
#macro.)
> #declare Factorial =
> function(A) { select(A, 1, 1, w[A]*Factorial(A-1)) };
> compiling, I've obtained this error (related on w[A]):
> Parse Error: Expected 'numeric expression', undeclared identified 'A' found
> instead ...
> But why??? A is sure not initialited (but it's a parameter...) but why
> undeclared?!?!
Because in this case "A" is not SDL and the SDL parser doesn't see it.
When you make the "w[A]" call, the SDL tries to substitute that call
with its value, but it can't because A is not defined (in the SDL level).
--
- Warp
Post a reply to this message
|
|