Ada: declarative part, function and packages

I have a query with declarative part, function and packages. I have a package as shown next. Due to the complexity of the Compute_X1 function, I have create a "is separate" for computing this function. The value returned from Compute_X1 is X1 and is to be used in the function J21 (J21 takes X1 as a first argument).

Package specification:

package Compute_Jacobian is

--compute X1
function Compute_X1 ( Force_Applied, Forcing_Frequency: Long_Float) return Long_Float;

--- use X1 in J21
function J21 ( X1, Forcing_Frequency, Natural_Frequency : Long_Float) return Long_Float;

end Compute_Jacobian;

The package body is:

package body Compute_Jacobian is
 --compute X1

function Compute_X1 ( Force_Applied, Forcing_Frequency: Long_Float) return Long_Float is separate;

X1 := Compute_X1 ( Force_Applied, Forcing_Frequency);


function J21 ( X1, Forcing_Frequency, Natural_Frequency : Long_Float) return Long_Float is separate;

end Compute_Jacobian;

and I have created stubs for Compute_X1 and J21.

On compiling the package body Compute_Jacobian.adb, I get this error message:

12.    X1 := Compute_X1 ( Force_Applied, Forcing_Frequency);
       |
    >>> statement not allowed in declarative part

My question is how to compute X1 and use it in the computation of function J21.

I could try to compute X1 in the "main" code (not shown here) directly (making a "is separate" from there) and then use it as a normal argument in computing J21. But I wanted the above structure (in my above post here) with computation of X1 in the Compute_Jacobian package.

Thanks a lot...

1
задан yCalleecharan 23 September 2010 в 11:49
поделиться