<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) XXXX-2008 - INRIA
 * Copyright (C) 2018 - Samuel GOUGEON
 *
 * Copyright (C) 2012 - 2016 - Scilab Enterprises
 *
 * This file is hereby licensed under the terms of the GNU GPL v2.0,
 * pursuant to article 5.3.4 of the CeCILL v.2.1.
 * This file was originally licensed under the terms of the CeCILL v2.1,
 * and continues to be available under such terms.
 * For more information, see the COPYING file which you should have received
 * along with this program.
 *
 -->
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
          xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML"
          xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"
          xml:lang="en" xml:id="deff">
    <refnamediv>
        <refname>deff</refname>
        <refpurpose>in-line definition of a function in Scilab language</refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Syntax</title>
        <synopsis>deff('[s1, s2, ...] = newfunction(e1, e2, ...)',text)</synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>Arguments</title>
        <variablelist>
            <varlistentry>
                <term>e1, e2, ...</term>
                <listitem>
                    <para>input variables.</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>s1, s2, ...</term>
                <listitem>
                    <para>output variables.</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>text</term>
                <listitem>
                    <para>a matrix of character strings.</para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Description</title>
        <para>
            <function>deff</function> can be used to define functions from sequences of instructions
            written in text strings. The resulting function object has the same properties
            of any other function defined in a text file and loaded with <function>exec</function>.
        </para>
        <warning>
            Quotes included in instructions given in strings must be doubled to be protected.
        </warning>
    </refsection>
    <refsection>
        <title>Examples</title>
        <programlisting role="example"><![CDATA[
deff('x = myplus(y,z)', 'x = y+z')
myplus(1,%i)

deff('[y, z] = mymacro(x)', ['y = 3*x+1'; 'z = a*x + x.^2'])
a = 3;
[u, v] = mymacro(2)
 ]]></programlisting>
    <screen><![CDATA[
--> deff('x = myplus(y,z)', 'x = y+z')
--> myplus(1,%i)
 ans  =
   1. + i

--> deff('[y, z] = mymacro(x)', ['y = 3*x+1'; 'z = a*x + x.^2'])
--> a = 3;
--> [u, v] = mymacro(2)
 v  =
   10.

 u  =
   7.
]]></screen>
    </refsection>
    <refsection role="see also">
        <title>See also</title>
        <simplelist type="inline">
            <member>
                <link linkend="function">function</link>
            </member>
            <member>
                <link linkend="exec">exec</link>
            </member>
            <member>
                <link linkend="getd">getd</link>
            </member>
            <member>
                <link linkend="genlib">genlib</link>
            </member>
            <member>
                <link linkend="jdeff">jdeff</link>
            </member>
            <member>
                <link linkend="jcompile">jcompile</link>
            </member>
        </simplelist>
    </refsection>
    <refsection role="history">
        <title>History</title>
        <revhistory>
            <revision>
                <revnumber>6.0.0</revnumber>
                <revdescription>
                   <itemizedlist>
                     <listitem>
                       The input option
                       <ulink url="https://help.scilab.org/docs/5.5.2/en_US/deff.html">
                         <varname>opt="c"|"p"|"n"</varname>
                       </ulink> is no longer available.
                     </listitem>
                     <listitem>
                        The defined <varname>newfunction</varname> is now of type 13 (instead of 11).
                     </listitem>
                  </itemizedlist>
                </revdescription>
            </revision>
        </revhistory>
    </refsection>
</refentry>
