diff options
Diffstat (limited to 'lib/erl_interface/doc/src/erl_format.xml')
-rw-r--r-- | lib/erl_interface/doc/src/erl_format.xml | 102 |
1 files changed, 49 insertions, 53 deletions
diff --git a/lib/erl_interface/doc/src/erl_format.xml b/lib/erl_interface/doc/src/erl_format.xml index 6e3ac4f0c9..5b8b7b5e78 100644 --- a/lib/erl_interface/doc/src/erl_format.xml +++ b/lib/erl_interface/doc/src/erl_format.xml @@ -11,7 +11,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software @@ -19,7 +19,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - + </legalnotice> <title>erl_format</title> @@ -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.sgml</file> + <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> + in the way <c>printf()</c> works.</p> + <p><c>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>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>FormatStr</c>. An Erlang term is built according to + <c>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,40 @@ 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: - <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>This creates an <c>(ETERM *)</c> structure corresponding + to the Erlang term + <c>[{name,madonna},{age,21},{data,[{adr,"E-street",42}]}]</c></p> + <p>The function returns an Erlang term, or <c>NULL</c> if + <c>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> <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 examples, see + section <seealso marker="doc/reference_manual:patterns"> + Pattern Matching</seealso> in the Erlang Reference Manual.</p> + <list type="bulleted"> + <item><c>Pattern</c> is an Erlang term, possibly + containing unbound variables.</item> + <item><c>Term</c> is an Erlang term that we wish to match + against <c>Pattern</c>.</item> + </list> + <p><c>Term</c> and <c>Pattern</c> are compared + and any unbound variables in <c>Pattern</c> are bound to + corresponding values in <c>Term</c>.</p> + <p>If <c>Term</c> and <c>Pattern</c> can be + matched, the function returns a non-zero value and binds any unbound + variables in <c>Pattern</c>. If <c>Term</c> + and <c>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}"); @@ -132,11 +129,10 @@ if (erl_match(pattern2, term2)) { ... } ]]></code> - <p><c><![CDATA[erl_var_content()]]></c> can be used to retrieve the + <p><c>erl_var_content()</c> can be used to retrieve the content of any variables bound as a result of a call to - <c><![CDATA[erl_match()]]></c>.</p> + <c>erl_match()</c>.</p> </desc> </func> </funcs> </cref> - |