# 错误(3638)
# 3638-1
# 错误信息
函数参数 "%1!s!" 的绑定参数 "%2!s!" 不合法, "%3!s!" 需要是命名参数.
# 产生原因
Modelica 语义规定函数参数的绑定参数必须是命名参数, 否则报出错误 3638.
# 解决方法
将绑定参数改为命名参数.
# 示例
model _3638_1_BindingArguMustBeNamedArgu
partial function Integrand
input Real x;
output Real y;
end Integrand;
function quadrature
input Real x2;
input Integrand integrand;
output Real integral;
algorithm
integral := (x2 - x1) * (integrand(x1) + integrand(x2)) / 2;
end quadrature;
function Sine
extends Integrand;
input Real A;
input Real w;
algorithm
y := A * w * x;
end Sine;
Real b = quadrature(0, integrand = function Sine(2, 3)); // Error: 非命名参数
//Real b = quadrature(0, integrand = function Sine(A = 2, w = 3)); // OK
end _3638_1_BindingArguMustBeNamedArgu;
# 3638-2
# 错误信息
函数类型参数 "%1!s!" 的绑定参数 "%2!s!" 不合法, 不可以对接口函数 "%3!s!" 中的成员赋值.
# 产生原因
函数中有i nput 前缀的函数组件的类型就是接口函数. 在传递函数参数时, 函数类型参数的绑定参数中不能对接口函数中的成员赋值. 否则报出错误 3638.
# 解决方法
将对接口函数中成员赋值改为对实现函数中成员( 不包含接口函数成员) 赋值.
# 3638-3
# 错误信息
函数类型参数 "%1!s!" 的绑定参数 "%2!s!" 不合法, 不可以对形式参数 "%3!s!" 多次赋值.
# 产生原因
绑定参数对同一个形参只能赋值一次, 否则报出错误 3638.
# 解决方法
只保留一次赋值,去掉其他.
# 3638-4
# 错误信息
函数参数 "%1!s!" 的绑定参数 "%2!s!" 不合法, "%3!s!" 不是有效的形参名.
# 产生原因
绑定参数赋值的变量在函数参数的类型函数中找不到, 则报出错误 3638.
# 解决方法
将绑定参数赋值的变量改为函数参数的类型函数中的输入组件.
# 示例
model _3638_4_BindingArguIsInvalidNamedArgu
partial function Integrand
input Real x;
output Real y;
end Integrand;
function quadrature
input Real x1;
input Real x2;
input Integrand integrand;
output Real integral;
algorithm
integral := (x2 - x1) * (integrand(x1) + integrand(x2)) / 2;
end quadrature;
function Sine
extends Integrand;
input Real A;
input Real w;
algorithm
y := A * w * x;
end Sine;
Real b = quadrature(0, 1, integrand = function Sine(a = 2, w = 3));//Error:形参a找不到
//Real b = quadrature(0, 1, integrand = function Sine(A = 2, w = 3));//OK
end _3638_4_BindingArguIsInvalidNamedArgu;