<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Scilab ( https://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) 2008 - INRIA
 *
 * 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="ja" xml:id="clear">
    <refnamediv>
        <refname>clear</refname>
        <refpurpose>変数を消去する</refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>呼出し手順</title>
        <synopsis>
            clear a b c
            clear('a', 'b', 'c')
            clear(['a' 'b' 'c'])
        </synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>引数</title>
        <variablelist>
            <varlistentry>
                <term>a, b, c...</term>
                <listitem>
                    <para>任意の型および大きさの変数, ただし,保護されていないこと</para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>説明</title>
        <para>
            このコマンドは保護されていない変数を消去します.
            変数は環境から削除されます.
            <code>clear</code> は<code>predef</code>で保護された
            変数以外の全ての変数を消去します.
            このため,2つのコマンド  <code>predef(0)</code> および<code>clear</code>
            により全ての変数が削除されます.
        </para>
        <para>
            通常,保護される変数は標準ライブラリとパーセント構文の変数です.
        </para>
        <para>
            <note>
                正しい構文は<code>clear a</code>および<code>clear('a')</code>であり,
                <code>clear(a)</code>ではないことに注意してください.
                <code>a=[]</code> は <varname>a</varname> を消去しませんが,
                <varname>a</varname>を空の行列にすることに注意してください.
            </note>
        </para>
        <para>
            If a name <emphasis>Var</emphasis> matches no variable, <literal>clear Var</literal>
            does nothing silently.
        </para>
      <note>
        <literal>clear()</literal> can be overloaded for any <literal>mlist("foo")</literal> type,
        by defining a <literal>%foo_clear()</literal> macro. It will be called either when
        <literal>clear</literal> is explicitly applied to any mlist of this type, or implicitly
        when any mlist of this type is deleted when leaving the environment where it has been
        defined.
      </note>
    </refsection>
    <refsection>
        <title>例</title>
        <programlisting role="example"><![CDATA[
a = 2;
b = 3;
c = 4;
clear a
isdef("a") // F
isdef("b") // T
clear("b");
isdef("b") // F
a = 2;
b = 3;
c = 4;
clear(['a' 'b' 'c'])
isdef("a") | isdef("b") | isdef("c") // F
        ]]></programlisting>
        <programlisting role="example"><![CDATA[
function %foo_clear(o)
    disp("deleted");
endfunction

value = mlist("foo");
clear value // will print "deleted"
]]></programlisting>
    </refsection>
    <refsection role="see also">
        <title>参照</title>
        <simplelist type="inline">
            <member>
                <link linkend="predef">predef</link>
            </member>
            <member>
                <link linkend="clearglobal">clearglobal</link>
            </member>
            <member>
                <link linkend="funcprot">funcprot</link>
            </member>
            <member>
                <link linkend="who">who</link>
            </member>
            <member>
                <link linkend="xmlDelete">xmlDelete</link>
            </member>
        </simplelist>
    </refsection>
    <refsection>
        <title>履歴</title>
        <revhistory>
            <revision>
                <revnumber>5.5.0</revnumber>
                <revdescription>引数を文字列の行列とすることができるようになりました</revdescription>
            </revision>
            <revision>
                <revnumber>6.0.0</revnumber>
                <revdescription>
                  <literal>clear</literal> is now protected:
                  Assignments like <literal>clear=1</literal> are no longer possible.
                </revdescription>
            </revision>
            <revision>
                <revnumber>6.1.0</revnumber>
                <revdescription>
                    <literal>clear</literal> becomes overloadable for any
                    <literal>mlist("foo")</literal>, with <literal>%foo_clear()</literal>.
                </revdescription>
            </revision>
        </revhistory>
    </refsection>
</refentry>
