diff options
Diffstat (limited to 'lib/erl_interface/doc/src/erl_format.xml')
-rw-r--r-- | lib/erl_interface/doc/src/erl_format.xml | 88 |
1 files changed, 43 insertions, 45 deletions
diff --git a/lib/erl_interface/doc/src/erl_format.xml b/lib/erl_interface/doc/src/erl_format.xml index ce5163fbc7..9fe405d51c 100644 --- a/lib/erl_interface/doc/src/erl_format.xml +++ b/lib/erl_interface/doc/src/erl_format.xml @@ -28,51 +28,42 @@ <docno></docno> <approved>Bjarne Däcker</approved> <checked>Torbjörn Törnkvist</checked> - <date>961016</date> + <date>1996-10-16</date> <rev>A</rev> <file>erl_format.xml</file> </header> <lib>erl_format</lib> - <libsummary>Create and Match Erlang Terms</libsummary> + <libsummary>Create and match Erlang terms.</libsummary> <description> - <p>This module contains two routines - one general function for + <p>This module contains two routines: one general function for creating Erlang terms and one for pattern matching Erlang terms.</p> </description> + <funcs> <func> - <name><ret>ETERM *</ret><nametext>erl_format(FormatStr, ... )</nametext></name> - <fsummary>Creates an Erlang term.</fsummary> + <name><ret>ETERM *</ret><nametext>erl_format(FormatStr, ...)</nametext></name> + <fsummary>Create an Erlang term.</fsummary> <type> <v>char *FormatStr;</v> </type> <desc> - <p>This is a general function for creating Erlang terms using + <p>A general function for creating Erlang terms using a format specifier and a corresponding set of arguments, much in the way <c><![CDATA[printf()]]></c> works.</p> - <p><c><![CDATA[FormatStr]]></c> is a format specification string. The set - of valid format specifiers is as follows:</p> + <p><c><![CDATA[FormatStr]]></c> is a format specification string. + The valid format specifiers are as follows:</p> <list type="bulleted"> - <item> - <p>~i - Integer</p> - </item> - <item> - <p>~f - Floating point</p> - </item> - <item> - <p>~a - Atom</p> - </item> - <item> - <p>~s - String</p> - </item> - <item> - <p>~w - Arbitrary Erlang term</p> - </item> + <item><c>~i</c> - Integer</item> + <item><c>~f</c> - Floating point</item> + <item><c>~a</c> - Atom</item> + <item><c>~s</c> - String</item> + <item><c>~w</c> - Arbitrary Erlang term</item> </list> - <p>For each format specifier that appears in <c><![CDATA[FormatStr]]></c>, + <p>For each format specifier included in <c><![CDATA[FormatStr]]></c>, there must be a corresponding argument following - <c><![CDATA[FormatStr]]></c>. An Erlang term is built according to the - <c><![CDATA[FormatStr]]></c> with values and Erlang terms substituted from - the corresponding arguments and according to the individual + <c><![CDATA[FormatStr]]></c>. An Erlang term is built according to + <c><![CDATA[FormatStr]]></c> with values and Erlang terms substituted + from the corresponding arguments, and according to the individual format specifiers. For example:</p> <code type="none"><![CDATA[ erl_format("[{name,~a},{age,~i},{data,~w}]", @@ -80,34 +71,41 @@ erl_format("[{name,~a},{age,~i},{data,~w}]", 21, erl_format("[{adr,~s,~i}]","E-street",42)); ]]></code> - <p>This will create an <c><![CDATA[(ETERM *)]]></c> structure corresponding - to the Erlang term: + <p>This creates an <c><![CDATA[(ETERM *)]]></c> structure corresponding + to the Erlang term <c><![CDATA[[{name,madonna},{age,21},{data,[{adr,"E-street",42}]}]]]></c></p> - <p>The function returns an Erlang term, or NULL if - <c><![CDATA[FormatStr]]></c> does not describe a valid Erlang term.</p> + <p>The function returns an Erlang term, or <c>NULL</c> if + <c><![CDATA[FormatStr]]></c> does not describe a valid Erlang + term.</p> </desc> </func> + <func> <name><ret>int</ret><nametext>erl_match(Pattern, Term)</nametext></name> - <fsummary>Performs pattern matching.</fsummary> + <fsummary>Perform pattern matching.</fsummary> + <marker id="erl_match"/> <type> <v>ETERM *Pattern,*Term;</v> </type> <desc> <p>This function is used to perform pattern matching similar - to that done in Erlang. Refer to an Erlang manual for matching - rules and more examples.</p> - <p><c><![CDATA[Pattern]]></c> is an Erlang term, possibly containing unbound - variables. </p> - <p><c><![CDATA[Term]]></c> is an Erlang term that we wish to match against - <c><![CDATA[Pattern]]></c>.</p> - <p><c><![CDATA[Term]]></c> and <c><![CDATA[Pattern]]></c> are compared, and any - unbound variables in <c><![CDATA[Pattern]]></c> are bound to corresponding - values in <c><![CDATA[Term]]></c>. </p> - <p>If <c><![CDATA[Term]]></c> and <c><![CDATA[Pattern]]></c> can be matched, the - function returns a non-zero value and binds any unbound - variables in <c><![CDATA[Pattern]]></c>. If <c><![CDATA[Term]]></c> <c><![CDATA[Pattern]]></c> do - not match, the function returns 0. For example:</p> + to that done in Erlang. For matching rules and more exemples, see + section <seealso marker="doc/reference_manual#patterns"> + Pattern Matching</seealso> in the Erlang Reference Manual.</p> + <list type="bulleted"> + <item><c><![CDATA[Pattern]]></c> is an Erlang term, possibly + containing unbound variables.</item> + <item><c><![CDATA[Term]]></c> is an Erlang term that we wish to match + against <c><![CDATA[Pattern]]></c>.</item> + </list> + <p><c><![CDATA[Term]]></c> and <c><![CDATA[Pattern]]></c> are compared + and any unbound variables in <c><![CDATA[Pattern]]></c> are bound to + corresponding values in <c><![CDATA[Term]]></c>.</p> + <p>If <c><![CDATA[Term]]></c> and <c><![CDATA[Pattern]]></c> can be + matched, the function returns a non-zero value and binds any unbound + variables in <c><![CDATA[Pattern]]></c>. If <c><![CDATA[Term]]></c> + and <c><![CDATA[Pattern]]></c> do + not match, <c>0</c> is returned. For example:</p> <code type="none"><![CDATA[ ETERM *term, *pattern, *pattern2; term1 = erl_format("{14,21}"); |