# 
msgid ""
msgstr ""
"Project-Id-Version: Modelica by Example 0.2.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-04-14 10:14-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: ../../source/behavior/functions/func_def.rst:4
msgid "Function Definitions"
msgstr ""
"函数定义"

#: ../../source/behavior/functions/func_def.rst:6
msgid ""
"As we've already seen, Modelica includes many useful functions for "
"describing mathematical behavior.  But, inevitably, it is necessary to "
"create new functions for specific purposes.  Defining such functions is "
"similar, syntactically, to a :ref:`model-definition`."
msgstr ""
"如前所述，Modelica语言已经包含了很多有用的函数，可以方便地描述物体的数学特性。\ "
"但不可避免地，有时候有必要"
"创建用于特殊目的的新函数。\ "
"定义这些新函数的方式及语法与\ :ref:`model-definition`\ 相似。\ "

#: ../../source/behavior/functions/func_def.rst:12
msgid "Basic Syntax"
msgstr ""
"基本语法"

#: ../../source/behavior/functions/func_def.rst:14
msgid ""
"A basic Modelica function includes one or more arguments, a return value and"
" an ``algorithm`` section to compute the return value in terms of the "
"arguments.  The arguments to the function are preceded by the ``input`` "
"qualifier and the return value is preceded by the ``output`` qualifier.  For"
" example, consider the following simple function that squares its input "
"argument:"
msgstr ""
"基本的Modelica函数都包含一个或多个参数、一个函数返回值以及根据参数计算函数返回值的\ ``algorithm``\ 。\ "
"函数的输入参数以限定词\ ``input``\ 进行声明。\ "
"函数的返回值以限定词\ ``output``\ 进行声明。\ "
"例如，以下述简单函数为例，函数计算输入参数的平方值："

#: ../../source/behavior/functions/func_def.rst:30
msgid ""
"Here the input argument ``x`` has the type ``Real``.  The output variable "
"``y`` also has the ``Real`` type.  Arguments and return values can be "
"scalars or arrays (or even records, although we won't introduce records "
"until :ref:`later <components>`)."
msgstr ""
"在上述例子中，输入变量\ ``x``\ 的类型为\ ``Real``\ 。\ "
"输出变量\ ``y``\ 同样也是\ ``Real``\ 类型。\ "
"函数的参数和返回值可以是标量或数组（甚至是记录类型，\ :ref:`later <components>`\ 章节才介绍记录类型）。\ "

#: ../../source/behavior/functions/func_def.rst:36
msgid "Intermediate Variables"
msgstr ""
"中间变量"

#: ../../source/behavior/functions/func_def.rst:38
msgid ""
"For complex calculations, it is sometimes useful to define variables to hold"
" intermediate results.  Such variables must be clearly distinguished from "
"arguments and return values.  To declare such intermediate variables, make "
"their declarations ``protected``.  Making the variables ``protected`` "
"indicates to the Modelica compiler that these variables are not arguments or"
" return values, but are instead used internally by the function.  For "
"example, if we wished to write a function to compute the circumference of a "
"circle, we might utilize an intermediate variable to store the diameter:"
msgstr ""
"对于复杂的计算过程，通过定义变量保存中间结果将会非常有帮助。\ "
"这些变量必须与函数的参数和返回值明确的区分。\ "
"为了声明这些中间变量，我们以限定词\ ``protected``\ 进行声明。\ "
"以\ ``protected``\ 形式声明这些变量是为了"
"告诉Modelica编译器这些变量既不是函数的参数也不是函数的返回值，而是函数计算过程中内部使用的变量。\ "
"例如，如果我们希望编写一个函数来计算圆的周长，那就可能需要一个中间变量来储存圆的直径，即："

#: ../../source/behavior/functions/func_def.rst:59
msgid ""
"Here we see how some intermediate result or common sub-expression can be "
"associated with an internal variable."
msgstr ""
"在上述例子中，我们可以看到中间结果或公用子表达式可以与某个中间变量相关联。\ "

#: ../../source/behavior/functions/func_def.rst:63
msgid "Default Input Arguments"
msgstr ""
"默认的输入参数"

#: ../../source/behavior/functions/func_def.rst:65
msgid ""
"In some cases, it makes sense to include default values for some input "
"arguments.  In these cases, it is possible to include a default value in the"
" declaration of the input variable.  Consider the following function to "
"compute the potential energy of a mass in a gravitational field:"
msgstr ""
"在某些情况下，有必要为某些输入参数设置默认值。\ "
"这种情况下，在声明输入参数时"
"就可以包含了默认值。\ "
"考虑如下计算物体势能的函数："

#: ../../source/behavior/functions/func_def.rst:82
msgid ""
"By providing a default value for ``g``, we do not force users of this "
"function to provide a value for ``g`` each time.  Of course, this kind of "
"approach should only be used when there is a reasonable default value for a "
"given argument and it should never be used if you want to force users to "
"provide a value."
msgstr ""
"为参数\ ``g``\ 设定默认值后，用户调用此函数时就不必每次都为\ ``g``\ 赋值了。\ "
"当然，这种情况只适用于给定参数具有合理默认值的情况。\ "
"如果你期望用户为参数提供数值的话，此种方法不适用。\ "

#: ../../source/behavior/functions/func_def.rst:88
msgid ""
"These default values have some important effects when :ref:`calling-"
"functions` that we shall discuss shortly."
msgstr ""
"在\ :ref:`calling-functions`\ 时，这些具有默认值的参数将产生重要的影响。\ "
"我们将稍后讨论这点。\ "

#: ../../source/behavior/functions/func_def.rst:92
msgid "Multiple Return Values"
msgstr ""
"多个返回值"

#: ../../source/behavior/functions/func_def.rst:94
msgid ""
"Note that a function can have multiple return values (*i.e.,* multiple "
"declarations with the ``output`` qualifier).  For example, to consider a "
"function that computes both the circumference and area of a circle:"
msgstr ""
"其实，一个函数可以有多个返回值（即多个带有\ ``output``\ 限定词的变量声明）。\ "
"例如，我们可以利用一个函数同时计算圆的周长和面积："

#: ../../source/behavior/functions/func_def.rst:111
msgid ""
"Our upcoming discussion on :ref:`calling-functions` will cover how to "
"address multiple return values."
msgstr ""
"我们接下来将在\ :ref:`calling-functions`\ 部分讨论如何设置函数的多个返回值。\ "

#: ../../source/behavior/functions/func_def.rst:117
msgid "Calling Functions"
msgstr ""
"调用函数"

#: ../../source/behavior/functions/func_def.rst:119
msgid ""
"So far, we've covered how to define new functions.  But it is also worth "
"spending some time discussing the various ways of calling functions.  In "
"general, functions are invoked in a way that would be expected by both "
"mathematicians and programmers, *e.g.,*"
msgstr ""
"目前为止，我们已经介绍了如何去定义一个新的函数。\ "
"接下来，我们将讨论各种调用函数的方法。\ "
"一般的，函数调用的方式应该同时满足数学工作者和程序员的需求，例如："

#: ../../source/behavior/functions/func_def.rst:128
msgid ""
"Here we see the typical syntax name of the function name followed by a comma"
" separated list of arguments surrounded by parentheses.  But there are "
"several interesting cases to discuss."
msgstr ""
"如上，我们可以看到典型语法函数调用语法：函数名称后带有括号，而里面的参数列表则由逗号进行分隔。\ "
"但是，也有一些有趣的个例需要讨论。\ "

#: ../../source/behavior/functions/func_def.rst:132
msgid ""
"The syntax above is \"positional\".  That means that values in the function "
"call are assigned to arguments based on the order.  But since Modelica "
"function arguments have names, it is also possible to call functions using "
"named arguments.  Consider the following function for computing the volume "
"of a cube:"
msgstr ""
"上述语法需注意的是“参数位置”。\ "
"这意味着，在调用此函数进行参数赋值时，要注意参数顺序。\ "
"由于Modelica语言定义了函数的参数名称，因此也可以通过参数名调用函数。\ "
"例如，参考下面计算立方体体积的函数："

#: ../../source/behavior/functions/func_def.rst:148
msgid ""
"When calling this function, it is important not to confuse the radius and "
"the volume.  To avoid any possible confusion regarding their order, it is "
"possible to call the function used named arguments.  In that case, the "
"function call would look something like:"
msgstr ""
"当调用此函数时，一定要注意不要混淆参数radius和length的顺序。\ "
"为了避免由于参数顺序引起的混淆，"
"我们可以使用参数名称来调用此函数。\ "
"以这种方式实现函数调用的写法如下所示："

#: ../../source/behavior/functions/func_def.rst:157
msgid ""
"Named arguments are particularly useful in conjunction with default argument"
" values.  Recall the ``PotentialEnergy`` function introduced earlier.  It "
"can be invoked in several ways:"
msgstr ""
"当调用具有默认参数值的函数时，使用参数名称调用将尤其方便。\ "
"对于前面介绍的\ ``PotentialEnergy``\ 函数，"
"可以有以下多种调用方式："

#: ../../source/behavior/functions/func_def.rst:169
msgid ""
"The reason named arguments are so important for arguments with default "
"values is if a function has many arguments with default arguments, you can "
"selectively override values for those arguments by referring to them by "
"name."
msgstr ""
"之所以对于具有默认参数值的函数，应使用参数名称实现函数调用，最重要的原因是：对于具有多个默认参数值的函数，"
"你可以通过指定这些参数的名称以选择性地覆盖其默认值。\ "

#: ../../source/behavior/functions/func_def.rst:174
msgid ""
"Finally, we previously pointed out the fact that it is possible for a "
"function to have multiple return values.  But the question remains, how do "
"we address multiple return values?  To see how this is done in practice, let"
" us revisit the ``CircleProperties`` function we defined earlier in this "
"section.  The following statement shows how we can reference both return "
"values:"
msgstr ""
"现在，我们讨论一下前面提到的一个函数可能具有多个返回值的情况。\ "
"但问题是，我们该如何引用函数的多个返回值？"
"让我们回顾一下本节前面部分定义的函数\ ``CircleProperties``\ ，下面的表达式展现了在实际使用时，我们应如何引用函数的多个返回值："

#: ../../source/behavior/functions/func_def.rst:185
msgid ""
"In other words, the left hand side is a comma separated list of the "
"variables to be assigned to (or equated to, in the case of an ``equation`` "
"section) wrapped by a pair of parentheses."
msgstr ""
"换句话说，等号左边括号内用逗号分隔开的参数值是由函数的相应返回值进行赋值的（或在函数内部使用了\ ``equation``\ 区域时，等于相应值）。\ "

#: ../../source/behavior/functions/func_def.rst:189
msgid ""
"As this discussion demonstrates, there are many different ways to call a "
"function in Modelica."
msgstr ""
"根据上述讨论的结果，在Modelica语言中，有多种方式可以实现函数调用。\ "

#: ../../source/behavior/functions/func_def.rst:193
msgid "Important Restrictions"
msgstr ""
"重要的限制条件"

#: ../../source/behavior/functions/func_def.rst:195
msgid ""
"In general, we can perform the same kinds of calculations in functions as we"
" can in models.  But there are some important restrictions."
msgstr ""
"一般来说，我们可以利用函数或模型实现相同的计算功能。\ "
"但是，两者之间存在一些重要的限制条件。\ "

#: ../../source/behavior/functions/func_def.rst:198
msgid ""
"Input arguments are read only - You are not allowed to assign a value to a "
"variable which is an input argument to the function."
msgstr ""
"输入变量都是只读的——不可以对函数的输入变量进行赋值。\ "

#: ../../source/behavior/functions/func_def.rst:201
msgid ""
"You are not allowed to reference the global variable `time` from within a "
"function."
msgstr ""
"在函数中，不允许引用全局变量\ ``time``\ 。\ "

#: ../../source/behavior/functions/func_def.rst:204
msgid ""
"No equations or when statements - A function can have no more than one "
"``algorithm`` section and it cannot contain ``when`` statements."
msgstr ""
"不允许存在多个方程或when语句——函数中只允许包含一个\ ``algorithm``\ 区域，并且不能包含\ ``when``\ 语句。\ "

#: ../../source/behavior/functions/func_def.rst:207
msgid ""
"The following functions cannot be invoked from a function: ``der``, "
"``initial``, ``terminal``, ``sample``, ``pre``, ``edge``, ``change``, "
"``reinit``, ``delay``, ``cardinality``, ``inStream``, ``actualStream``"
msgstr ""
"以下功能不能从函数中进行调用：\ ``der``\ 、\ ``initial``\ 、\ ``terminal``\ 、\ ``sample``\ 、\ ``pre``\ 、\ ``edge``\ 、\ ``change``\ 、 "
"\ ``reinit``\ 、\ ``delay``\ 、\ ``cardinality``\ 、\ ``inStream``\ 、\ ``actualStream``\ 。\ "

#: ../../source/behavior/functions/func_def.rst:212
msgid ""
"Arguments, results and intermediate (``protected``) variables cannot be "
"models or blocks."
msgstr ""
"参数、结果以及中间变量（\ ``protected``\ ）不能是模型或块。\ "

#: ../../source/behavior/functions/func_def.rst:215
msgid ""
"Array sizes are restricted - Arguments that are arrays can have :ref"
":`unspecd-dim` and the size will be implicitly determined by the context in "
"which the function is invoked.  Results that are arrays must have their "
"sizes specified in terms of constants or in relation to the sizes of input "
"arguments."
msgstr ""
"数组的大小受限——参数是数组类型的可不指定其维数（请参考\ :ref:`unspecd-dim`\ 部分）并且其"
"大小由引用它的函数隐性确定。\ "
"函数返回值是数组类型的，其大小必须由常数或与其相关联的输入参数的大小来定义。\ "

#: ../../source/behavior/functions/func_def.rst:221
msgid ""
"One important thing to note is that functions are **not** restricted in "
"terms of recursion (*i.e.,* a function **is** allowed to call itself)."
msgstr ""
"需要非常注意的一点是，函数能\ **不受**\ 限制地实现递归运算（ 即函数\ **允许**\ 调用自身）。\ "

#: ../../source/behavior/functions/func_def.rst:247
msgid "Side Effects"
msgstr ""
"副作用"

#: ../../source/behavior/functions/func_def.rst:249
msgid ""
"In the :ref:`sil-controller` example, we introduced external functions that "
"had side effects.  This means that the value returned by the function was "
"not strictly a function of its arguments.  Such a function is said to have "
"\"side effects\".  Functions with side effects, should be qualified with the"
" ``impure`` keyword.  This tells the Modelica compiler that these functions "
"cannot be treated as purely mathematical functions."
msgstr ""
"在\ :ref:`sil-controller`\ 例子中，我们对外部函数的副作用进行了介绍。\ "
"也就是说，函数的返回值并不是其参数在严格意义上的函数。\ "
"像这类函数就具有所谓的“副作用”。\ "
"具有副作用的函数应该以关键字\ ``impure``\ 进行声明。\ "
"这就告诉Modelica编译器，这些函数不能被视为纯粹的数学函数。\ "

#: ../../source/behavior/functions/func_def.rst:257
msgid ""
"The use of ``impure`` functions is restricted.  They can only be invoked "
"from within a ``when`` statement or another ``impure`` function."
msgstr ""
"这些以\ ``impure``\ 函数在使用时有其限制。\ "
"它们只能被其他\ ``impure``\ 函数调用或在\ ``when``\ 语句中使用。\ "

#: ../../source/behavior/functions/func_def.rst:262
msgid "Function Template"
msgstr ""
"函数模板"

#: ../../source/behavior/functions/func_def.rst:264
msgid ""
"Taking all of this into account, the following can be considered a "
"generalized function definition:"
msgstr ""
"考虑上述所有情况，下面的例子可以认为是一个广义函数定义的模板："
