diff options
Diffstat (limited to 'lib/stdlib/doc')
68 files changed, 6659 insertions, 6801 deletions
diff --git a/lib/stdlib/doc/specs/.gitignore b/lib/stdlib/doc/specs/.gitignore new file mode 100644 index 0000000000..322eebcb06 --- /dev/null +++ b/lib/stdlib/doc/specs/.gitignore @@ -0,0 +1 @@ +specs_*.xml diff --git a/lib/stdlib/doc/src/Makefile b/lib/stdlib/doc/src/Makefile index 13b9b2ff18..16e0a86e3b 100644 --- a/lib/stdlib/doc/src/Makefile +++ b/lib/stdlib/doc/src/Makefile @@ -1,19 +1,19 @@ # # %CopyrightBegin% -# -# Copyright Ericsson AB 1997-2009. All Rights Reserved. -# +# +# Copyright Ericsson AB 1997-2011. All Rights Reserved. +# # The contents of this file are subject to the Erlang Public License, # Version 1.1, (the "License"); you may not use this file except in # compliance with the License. You should have received a copy of the # Erlang Public License along with this software. If not, it can be # retrieved online at http://www.erlang.org/. -# +# # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See # the License for the specific language governing rights and limitations # under the License. -# +# # %CopyrightEnd% # include $(ERL_TOP)/make/target.mk @@ -40,6 +40,7 @@ XML_REF3_FILES = \ array.xml \ base64.xml \ beam_lib.xml \ + binary.xml \ c.xml \ calendar.xml \ dets.xml \ @@ -124,18 +125,24 @@ HTML_REF_MAN_FILE = $(HTMLDIR)/index.html TOP_PDF_FILE = $(PDFDIR)/$(APPLICATION)-$(VSN).pdf +SPECS_FILES = $(XML_REF3_FILES:%.xml=$(SPECDIR)/specs_%.xml) + +TOP_SPECS_FILE = specs.xml + # ---------------------------------------------------- # FLAGS # ---------------------------------------------------- XML_FLAGS += +SPECS_FLAGS = -I../../include -I../../../kernel/include + # ---------------------------------------------------- # Targets # ---------------------------------------------------- $(HTMLDIR)/%.gif: %.gif $(INSTALL_DATA) $< $@ -docs: pdf html man +docs: man pdf html $(TOP_PDF_FILE): $(XML_FILES) @@ -154,8 +161,13 @@ clean clean_docs: rm -f $(MAN3DIR)/* rm -f $(MAN6DIR)/* rm -f $(TOP_PDF_FILE) $(TOP_PDF_FILE:%.pdf=%.fo) + rm -f $(SPECDIR)/* rm -f errs core *~ +$(SPECDIR)/specs_erl_id_trans.xml: + escript $(SPECS_EXTRACTOR) $(SPECS_FLAGS) \ + -o$(dir $@) -module erl_id_trans + # ---------------------------------------------------- # Release Target # ---------------------------------------------------- diff --git a/lib/stdlib/doc/src/array.xml b/lib/stdlib/doc/src/array.xml index 5c3ac6a2a9..a79fcd487e 100644 --- a/lib/stdlib/doc/src/array.xml +++ b/lib/stdlib/doc/src/array.xml @@ -3,7 +3,7 @@ <erlref> <header> <copyright> - <year>2007</year><year>2009</year> + <year>2007</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -82,19 +82,35 @@ the default value cannot be confused with the values of set entries.</p> %% allow accesses beyond the last set entry {'EXIT',{badarg,_}} = (catch array:set(18, true, A3)). {'EXIT',{badarg,_}} = (catch array:get(18, A3)).</pre></description> -<section><title>DATA TYPES</title><marker id="types"/> - -<taglist> -<tag><c>array()</c></tag> -<item><marker id="type-array"/> -<p>A functional, extendible array. The representation is - not documented and is subject to change without notice. Note that - arrays cannot be directly compared for equality.</p> -</item> -</taglist></section> +<datatypes> + <datatype> + <name><marker id="type-array">array()</marker></name> + <desc> + <p>A functional, extendible array. The representation is + not documented and is subject to change without notice. Note that + arrays cannot be directly compared for equality.</p> + </desc> + </datatype> + <datatype> + <name name="array_indx"/> + </datatype> + <datatype> + <name name="array_opts"/> + </datatype> + <datatype> + <name name="array_opt"/> + </datatype> + <datatype> + <name name="indx_pairs"/> + </datatype> + <datatype> + <name name="indx_pair"/> + </datatype> +</datatypes> + <funcs> <func> -<name>default(Array::array()) -> term()</name> +<name name="default" arity="1"/> <fsummary>Get the value used for uninitialized entries.</fsummary> <desc><marker id="default-1"/> @@ -104,7 +120,7 @@ the default value cannot be confused with the values of set entries.</p> <p><em>See also:</em> <seealso marker="#new-2">new/2</seealso>.</p> </desc></func> <func> -<name>fix(Array::array()) -> array()</name> +<name name="fix" arity="1"/> <fsummary>Fix the size of the array.</fsummary> <desc><marker id="fix-1"/> @@ -114,105 +130,100 @@ the default value cannot be confused with the values of set entries.</p> <p><em>See also:</em> <seealso marker="#relax-1">relax/1</seealso>.</p> </desc></func> <func> -<name>foldl(Function, InitialAcc::term(), Array::array()) -> term()</name> +<name name="foldl" arity="3"/> <fsummary>Fold the elements of the array using the given function and initial accumulator value.</fsummary> -<type> -<v>Function = (Index::integer(), Value::term(), Acc::term()) -> term()</v></type> <desc><marker id="foldl-3"/> - <p>Fold the elements of the array using the given function and initial accumulator value. The elements are visited in order from the - lowest index to the highest. If <c>Function</c> is not a function, the + lowest index to the highest. If <c><anno>Function</anno></c> is not a function, the call fails with reason <c>badarg</c>. </p> <p><em>See also:</em> <seealso marker="#foldr-3">foldr/3</seealso>, <seealso marker="#map-2">map/2</seealso>, <seealso marker="#sparse_foldl-3">sparse_foldl/3</seealso>.</p> </desc></func> <func> -<name>foldr(Function, InitialAcc::term(), Array::array()) -> term()</name> +<name name="foldr" arity="3"/> <fsummary>Fold the elements of the array right-to-left using the given function and initial accumulator value.</fsummary> -<type> -<v>Function = (Index::integer(), Value::term(), Acc::term()) -> term()</v></type> <desc><marker id="foldr-3"/> <p>Fold the elements of the array right-to-left using the given function and initial accumulator value. The elements are visited in - order from the highest index to the lowest. If <c>Function</c> is not a + order from the highest index to the lowest. If <c><anno>Function</anno></c> is not a function, the call fails with reason <c>badarg</c>. </p> <p><em>See also:</em> <seealso marker="#foldl-3">foldl/3</seealso>, <seealso marker="#map-2">map/2</seealso>.</p> </desc></func> <func> -<name>from_list(List::list()) -> array()</name> +<name name="from_list" arity="1"/> <fsummary>Equivalent to from_list(List, undefined). </fsummary> <desc><marker id="from_list-1"/> -<p>Equivalent to <seealso marker="#from_list-2">from_list(List, undefined)</seealso>.</p> +<p>Equivalent to <seealso marker="#from_list-2">from_list(<anno>List</anno>, undefined)</seealso>.</p> </desc></func> <func> -<name>from_list(List::list(), Default::term()) -> array()</name> +<name name="from_list" arity="2"/> <fsummary>Convert a list to an extendible array.</fsummary> <desc><marker id="from_list-2"/> -<p>Convert a list to an extendible array. <c>Default</c> is used as the value - for uninitialized entries of the array. If <c>List</c> is not a proper list, +<p>Convert a list to an extendible array. <c><anno>Default</anno></c> is used as the value + for uninitialized entries of the array. If <c><anno>List</anno></c> is not a proper list, the call fails with reason <c>badarg</c>. </p> <p><em>See also:</em> <seealso marker="#new-2">new/2</seealso>, <seealso marker="#to_list-1">to_list/1</seealso>.</p> </desc></func> <func> -<name>from_orddict(Orddict::list()) -> array()</name> +<name name="from_orddict" arity="1"/> <fsummary>Equivalent to from_orddict(Orddict, undefined). </fsummary> <desc><marker id="from_orddict-1"/> -<p>Equivalent to <seealso marker="#from_orddict-2">from_orddict(Orddict, undefined)</seealso>.</p> +<p>Equivalent to <seealso marker="#from_orddict-2">from_orddict(<anno>Orddict</anno>, undefined)</seealso>.</p> </desc></func> <func> -<name>from_orddict(List::list(), Default::term()) -> array()</name> +<name name="from_orddict" arity="2"/> <fsummary>Convert an ordered list of pairs {Index, Value} to a corresponding extendible array.</fsummary> <desc><marker id="from_orddict-2"/> <p>Convert an ordered list of pairs <c>{Index, Value}</c> to a - corresponding extendible array. <c>Default</c> is used as the value for - uninitialized entries of the array. If <c>List</c> is not a proper, + corresponding extendible array. <c><anno>Default</anno></c> is used as the value for + uninitialized entries of the array. If <c><anno>Orddict</anno></c> is not a proper, ordered list of pairs whose first elements are nonnegative integers, the call fails with reason <c>badarg</c>. </p> <p><em>See also:</em> <seealso marker="#new-2">new/2</seealso>, <seealso marker="#to_orddict-1">to_orddict/1</seealso>.</p> </desc></func> <func> -<name>get(I::integer(), Array::array()) -> term()</name> +<name name="get" arity="2"/> <fsummary>Get the value of entry I.</fsummary> <desc><marker id="get-2"/> -<p>Get the value of entry <c>I</c>. If <c>I</c> is not a nonnegative - integer, or if the array has fixed size and <c>I</c> is larger than the +<p>Get the value of entry <c><anno>I</anno></c>. If <c><anno>I</anno></c> is not a nonnegative + integer, or if the array has fixed size and <c><anno>I</anno></c> is larger than the maximum index, the call fails with reason <c>badarg</c>.</p> <p>If the array does not have fixed size, this function will return the - default value for any index <c>I</c> greater than <c>size(Array)-1</c>.</p> + default value for any index <c><anno>I</anno></c> greater than <c>size(<anno>Array</anno>)-1</c>.</p> <p><em>See also:</em> <seealso marker="#set-3">set/3</seealso>.</p> </desc></func> <func> -<name>is_array(X::term()) -> bool()</name> +<name name="is_array" arity="1"/> <fsummary>Returns true if X appears to be an array, otherwise false.</fsummary> <desc><marker id="is_array-1"/> -<p>Returns <c>true</c> if <c>X</c> appears to be an array, otherwise <c>false</c>. - Note that the check is only shallow; there is no guarantee that <c>X</c> +<p>Returns <c>true</c> if <c><anno>X</anno></c> appears to be an array, otherwise <c>false</c>. + Note that the check is only shallow; there is no guarantee that <c><anno>X</anno></c> is a well-formed array representation even if this function returns <c>true</c>.</p> </desc></func> <func> -<name>is_fix(Array::array()) -> bool()</name> +<name name="is_fix" arity="1"/> <fsummary>Check if the array has fixed size.</fsummary> <desc><marker id="is_fix-1"/> @@ -222,20 +233,18 @@ the default value cannot be confused with the values of set entries.</p> <p><em>See also:</em> <seealso marker="#fix-1">fix/1</seealso>.</p> </desc></func> <func> -<name>map(Function, Array::array()) -> array()</name> +<name name="map" arity="2"/> <fsummary>Map the given function onto each element of the array.</fsummary> -<type> -<v>Function = (Index::integer(), Value::term()) -> term()</v></type> <desc><marker id="map-2"/> <p>Map the given function onto each element of the array. The elements are visited in order from the lowest index to the highest. - If <c>Function</c> is not a function, the call fails with reason <c>badarg</c>. + If <c><anno>Function</anno></c> is not a function, the call fails with reason <c>badarg</c>. </p> <p><em>See also:</em> <seealso marker="#foldl-3">foldl/3</seealso>, <seealso marker="#foldr-3">foldr/3</seealso>, <seealso marker="#sparse_map-2">sparse_map/2</seealso>.</p> </desc></func> <func> -<name>new() -> array()</name> +<name name="new" arity="0"/> <fsummary>Create a new, extendible array with initial size zero.</fsummary> <desc><marker id="new-0"/> @@ -244,7 +253,7 @@ the default value cannot be confused with the values of set entries.</p> <p><em>See also:</em> <seealso marker="#new-1">new/1</seealso>, <seealso marker="#new-2">new/2</seealso>.</p> </desc></func> <func> -<name>new(Options::term()) -> array()</name> +<name name="new" arity="1"/> <fsummary>Create a new array according to the given options.</fsummary> <desc><marker id="new-1"/> @@ -253,10 +262,10 @@ the default value cannot be confused with the values of set entries.</p> the array is extendible and has initial size zero. Array indices start at 0.</p> - <p><c>Options</c> is a single term or a list of terms, selected from the + <p><c><anno>Options</anno></c> is a single term or a list of terms, selected from the following: </p><taglist> - <tag><c>N::integer()</c> or <c>{size, N::integer()}</c></tag> + <tag><c>N::integer() >= 0</c> or <c>{size, N::integer() >= 0}</c></tag> <item><p>Specifies the initial size of the array; this also implies <c>{fixed, true}</c>. If <c>N</c> is not a nonnegative integer, the call fails with reason <c>badarg</c>.</p></item> @@ -283,19 +292,19 @@ cannot be changed once the array has been created.</p> <p><em>See also:</em> <seealso marker="#fix-1">fix/1</seealso>, <seealso marker="#from_list-2">from_list/2</seealso>, <seealso marker="#get-2">get/2</seealso>, <seealso marker="#new-0">new/0</seealso>, <seealso marker="#new-2">new/2</seealso>, <seealso marker="#set-3">set/3</seealso>.</p> </desc></func> <func> -<name>new(Size::integer(), Options::term()) -> array()</name> +<name name="new" arity="2"/> <fsummary>Create a new array according to the given size and options.</fsummary> <desc><marker id="new-2"/> <p>Create a new array according to the given size and options. If - <c>Size</c> is not a nonnegative integer, the call fails with reason + <c><anno>Size</anno></c> is not a nonnegative integer, the call fails with reason <c>badarg</c>. By default, the array has fixed size. Note that any size - specifications in <c>Options</c> will override the <c>Size</c> parameter.</p> + specifications in <c><anno>Options</anno></c> will override the <c><anno>Size</anno></c> parameter.</p> - <p>If <c>Options</c> is a list, this is simply equivalent to <c>new([{size, - Size} | Options]</c>, otherwise it is equivalent to <c>new([{size, Size} | - [Options]]</c>. However, using this function directly is more efficient.</p> + <p>If <c><anno>Options</anno></c> is a list, this is simply equivalent to <c>new([{size, + <anno>Size</anno>} | <anno>Options</anno>]</c>, otherwise it is equivalent to <c>new([{size, <anno>Size</anno>} | + [<anno>Options</anno>]]</c>. However, using this function directly is more efficient.</p> <p>Example: </p><pre> array:new(100, {default,0})</pre><p> creates a fixed-size array of size @@ -304,7 +313,7 @@ cannot be changed once the array has been created.</p> <p><em>See also:</em> <seealso marker="#new-1">new/1</seealso>.</p> </desc></func> <func> -<name>relax(Array::array()) -> array()</name> +<name name="relax" arity="1"/> <fsummary>Make the array resizable.</fsummary> <desc><marker id="relax-1"/> @@ -313,24 +322,24 @@ cannot be changed once the array has been created.</p> <p><em>See also:</em> <seealso marker="#fix-1">fix/1</seealso>.</p> </desc></func> <func> -<name>reset(I::integer(), Array::array()) -> array()</name> +<name name="reset" arity="2"/> <fsummary>Reset entry I to the default value for the array.</fsummary> <desc><marker id="reset-2"/> -<p>Reset entry <c>I</c> to the default value for the array. - If the value of entry <c>I</c> is the default value the array will be +<p>Reset entry <c><anno>I</anno></c> to the default value for the array. + If the value of entry <c><anno>I</anno></c> is the default value the array will be returned unchanged. Reset will never change size of the array. Shrinking can be done explicitly by calling <seealso marker="#resize-2">resize/2</seealso>.</p> - <p>If <c>I</c> is not a nonnegative integer, or if the array has fixed size - and <c>I</c> is larger than the maximum index, the call fails with reason + <p>If <c><anno>I</anno></c> is not a nonnegative integer, or if the array has fixed size + and <c><anno>I</anno></c> is larger than the maximum index, the call fails with reason <c>badarg</c>; cf. <seealso marker="#set-3">set/3</seealso> </p> <p><em>See also:</em> <seealso marker="#new-2">new/2</seealso>, <seealso marker="#set-3">set/3</seealso>.</p> </desc></func> <func> -<name>resize(Array::array()) -> array()</name> +<name name="resize" arity="1"/> <fsummary>Change the size of the array to that reported by sparse_size/1.</fsummary> <desc><marker id="resize-1"/> @@ -340,90 +349,84 @@ cannot be changed once the array has been created.</p> <p><em>See also:</em> <seealso marker="#resize-2">resize/2</seealso>, <seealso marker="#sparse_size-1">sparse_size/1</seealso>.</p> </desc></func> <func> -<name>resize(Size::integer(), Array::array()) -> array()</name> +<name name="resize" arity="2"/> <fsummary>Change the size of the array.</fsummary> <desc><marker id="resize-2"/> -<p>Change the size of the array. If <c>Size</c> is not a nonnegative +<p>Change the size of the array. If <c><anno>Size</anno></c> is not a nonnegative integer, the call fails with reason <c>badarg</c>. If the given array has fixed size, the resulting array will also have fixed size.</p> </desc></func> <func> -<name>set(I::integer(), Value::term(), Array::array()) -> array()</name> +<name name="set" arity="3"/> <fsummary>Set entry I of the array to Value.</fsummary> <desc><marker id="set-3"/> -<p>Set entry <c>I</c> of the array to <c>Value</c>. If <c>I</c> is not a - nonnegative integer, or if the array has fixed size and <c>I</c> is larger +<p>Set entry <c><anno>I</anno></c> of the array to <c><anno>Value</anno></c>. If <c><anno>I</anno></c> is not a + nonnegative integer, or if the array has fixed size and <c><anno>I</anno></c> is larger than the maximum index, the call fails with reason <c>badarg</c>.</p> - <p>If the array does not have fixed size, and <c>I</c> is greater than - <c>size(Array)-1</c>, the array will grow to size <c>I+1</c>. + <p>If the array does not have fixed size, and <c><anno>I</anno></c> is greater than + <c>size(<anno>Array</anno>)-1</c>, the array will grow to size <c><anno>I</anno>+1</c>. </p> <p><em>See also:</em> <seealso marker="#get-2">get/2</seealso>, <seealso marker="#reset-2">reset/2</seealso>.</p> </desc></func> <func> -<name>size(Array::array()) -> integer()</name> +<name name="size" arity="1"/> <fsummary>Get the number of entries in the array.</fsummary> <desc><marker id="size-1"/> <p>Get the number of entries in the array. Entries are numbered - from 0 to <c>size(Array)-1</c>; hence, this is also the index of the first + from 0 to <c>size(<anno>Array</anno>)-1</c>; hence, this is also the index of the first entry that is guaranteed to not have been previously set.</p> <p><em>See also:</em> <seealso marker="#set-3">set/3</seealso>, <seealso marker="#sparse_size-1">sparse_size/1</seealso>.</p> </desc></func> <func> -<name>sparse_foldl(Function, InitialAcc::term(), Array::array()) -> term()</name> +<name name="sparse_foldl" arity="3"/> <fsummary>Fold the elements of the array using the given function and initial accumulator value, skipping default-valued entries.</fsummary> -<type> -<v>Function = (Index::integer(), Value::term(), Acc::term()) -> term()</v></type> <desc><marker id="sparse_foldl-3"/> <p>Fold the elements of the array using the given function and initial accumulator value, skipping default-valued entries. The elements are visited in order from the lowest index to the highest. - If <c>Function</c> is not a function, the call fails with reason <c>badarg</c>. + If <c><anno>Function</anno></c> is not a function, the call fails with reason <c>badarg</c>. </p> <p><em>See also:</em> <seealso marker="#foldl-3">foldl/3</seealso>, <seealso marker="#sparse_foldr-3">sparse_foldr/3</seealso>.</p> </desc></func> <func> -<name>sparse_foldr(Function, InitialAcc::term(), Array::array()) -> term()</name> +<name name="sparse_foldr" arity="3"/> <fsummary>Fold the elements of the array right-to-left using the given function and initial accumulator value, skipping default-valued entries.</fsummary> -<type> -<v>Function = (Index::integer(), Value::term(), Acc::term()) -> term()</v></type> <desc><marker id="sparse_foldr-3"/> <p>Fold the elements of the array right-to-left using the given function and initial accumulator value, skipping default-valued entries. The elements are visited in order from the highest index to - the lowest. If <c>Function</c> is not a function, the call fails with + the lowest. If <c><anno>Function</anno></c> is not a function, the call fails with reason <c>badarg</c>. </p> <p><em>See also:</em> <seealso marker="#foldr-3">foldr/3</seealso>, <seealso marker="#sparse_foldl-3">sparse_foldl/3</seealso>.</p> </desc></func> <func> -<name>sparse_map(Function, Array::array()) -> array()</name> +<name name="sparse_map" arity="2"/> <fsummary>Map the given function onto each element of the array, skipping default-valued entries.</fsummary> -<type> -<v>Function = (Index::integer(), Value::term()) -> term()</v></type> <desc><marker id="sparse_map-2"/> <p>Map the given function onto each element of the array, skipping default-valued entries. The elements are visited in order from the - lowest index to the highest. If <c>Function</c> is not a function, the + lowest index to the highest. If <c><anno>Function</anno></c> is not a function, the call fails with reason <c>badarg</c>. </p> <p><em>See also:</em> <seealso marker="#map-2">map/2</seealso>.</p> </desc></func> <func> -<name>sparse_size(A::array()) -> integer()</name> +<name name="sparse_size" arity="1"/> <fsummary>Get the number of entries in the array up until the last non-default valued entry.</fsummary> @@ -436,7 +439,7 @@ cannot be changed once the array has been created.</p> <p><em>See also:</em> <seealso marker="#resize-1">resize/1</seealso>, <seealso marker="#size-1">size/1</seealso>.</p> </desc></func> <func> -<name>sparse_to_list(Array::array()) -> list()</name> +<name name="sparse_to_list" arity="1"/> <fsummary>Converts the array to a list, skipping default-valued entries.</fsummary> <desc><marker id="sparse_to_list-1"/> @@ -446,7 +449,7 @@ cannot be changed once the array has been created.</p> <p><em>See also:</em> <seealso marker="#to_list-1">to_list/1</seealso>.</p> </desc></func> <func> -<name>sparse_to_orddict(Array::array()) -> [{Index::integer(), Value::term()}]</name> +<name name="sparse_to_orddict" arity="1"/> <fsummary>Convert the array to an ordered list of pairs {Index, Value}, skipping default-valued entries.</fsummary> @@ -458,7 +461,7 @@ cannot be changed once the array has been created.</p> <p><em>See also:</em> <seealso marker="#to_orddict-1">to_orddict/1</seealso>.</p> </desc></func> <func> -<name>to_list(Array::array()) -> list()</name> +<name name="to_list" arity="1"/> <fsummary>Converts the array to a list.</fsummary> <desc><marker id="to_list-1"/> @@ -468,7 +471,7 @@ cannot be changed once the array has been created.</p> <p><em>See also:</em> <seealso marker="#from_list-2">from_list/2</seealso>, <seealso marker="#sparse_to_list-1">sparse_to_list/1</seealso>.</p> </desc></func> <func> -<name>to_orddict(Array::array()) -> [{Index::integer(), Value::term()}]</name> +<name name="to_orddict" arity="1"/> <fsummary>Convert the array to an ordered list of pairs {Index, Value}.</fsummary> <desc><marker id="to_orddict-1"/> diff --git a/lib/stdlib/doc/src/base64.xml b/lib/stdlib/doc/src/base64.xml index d3fd7a843b..bfe8494a73 100644 --- a/lib/stdlib/doc/src/base64.xml +++ b/lib/stdlib/doc/src/base64.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>2007</year><year>2009</year> + <year>2007</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -33,32 +33,33 @@ <description> <p>Implements base 64 encode and decode, see RFC2045. </p> </description> + <datatypes> + <datatype> + <name name="ascii_string"/> + </datatype> + </datatypes> <funcs> <func> - <name>encode(Data) -> Base64 </name> - <name>encode_to_string(Data) -> Base64String</name> + <name name="encode" arity="1"/> + <name name="encode_to_string" arity="1"/> <fsummary>Encodes data into base64. </fsummary> - <type> - <v>Data = string() | binary()</v> - <v>Base64 = binary()</v> - <v>Base64String = string()</v> - </type> + <type variable="Data"/> + <type variable="Base64" name_i="1"/> + <type variable="Base64String"/> <desc> <p>Encodes a plain ASCII string into base64. The result will be 33% larger than the data.</p> </desc> </func> <func> - <name>decode(Base64) -> Data</name> - <name>decode_to_string(Base64) -> DataString</name> - <name>mime_decode(Base64) -> Data</name> - <name>mime_decode_to_string(Base64) -> DataString</name> + <name name="decode" arity="1"/> + <name name="decode_to_string" arity="1"/> + <name name="mime_decode" arity="1"/> + <name name="mime_decode_to_string" arity="1"/> <fsummary>Decodes a base64 encoded string to data. </fsummary> - <type> - <v>Base64 = string() | binary()</v> - <v>Data = binary()</v> - <v>DataString = string()</v> - </type> + <type variable="Base64" name_i="1"/> + <type variable="Data" name_i="1"/> + <type variable="DataString" name_i="2"/> <desc> <p>Decodes a base64 encoded string to plain ASCII. See RFC4648. <c>mime_decode/1</c> and <c>mime_decode_to_string/1</c> diff --git a/lib/stdlib/doc/src/beam_lib.xml b/lib/stdlib/doc/src/beam_lib.xml index b9286f1402..db65eb3848 100644 --- a/lib/stdlib/doc/src/beam_lib.xml +++ b/lib/stdlib/doc/src/beam_lib.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>2000</year><year>2010</year> + <year>2000</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -88,7 +88,6 @@ it is recommended that it contains at least 32 characters and that both upper and lower case letters as well as digits and special characters are used.</p> - <p></p> <p>The default type -- and currently the only type -- of crypto algorithm is <c>des3_cbc</c>, three rounds of DES. The key string will be scrambled using <c>erlang:md5/1</c> to generate @@ -154,70 +153,78 @@ </section> </section> - <section> - <title>DATA TYPES</title> - <code type="none"> -beam() -> Module | Filename | binary() - Module = atom() - Filename = string() | atom()</code> - <p>Each of the functions described below accept either the module - name, the filename, or a binary containing the beam module.</p> - <code type="none"> -chunkdata() = {ChunkId, DataB} | {ChunkName, DataT} - ChunkId = chunkid() - DataB = binary() - {ChunkName, DataT} = - {abstract_code, AbstractCode} - | {attributes, [{Attribute, [AttributeValue]}]} - | {compile_info, [{InfoKey, [InfoValue]}]} - | {exports, [{Function, Arity}]} - | {labeled_exports, [{Function, Arity, Label}]} - | {imports, [{Module, Function, Arity}]} - | {indexed_imports, [{Index, Module, Function, Arity}]} - | {locals, [{Function, Arity}]}]} - | {labeled_locals, [{Function, Arity, Label}]}]} - | {atoms, [{integer(), atom()}]} - AbstractCode = {AbstVersion, Forms} | no_abstract_code - AbstVersion = atom() - Attribute = atom() - AttributeValue = term() - Module = Function = atom() - Arity = int() - Label = int()</code> - <p>It is not checked that the forms conform to the abstract format - indicated by <c>AbstVersion</c>. <c>no_abstract_code</c> means - that the <c>"Abst"</c> chunk is present, but empty.</p> - <p>The list of attributes is sorted on <c>Attribute</c>, and each - attribute name occurs once in the list. The attribute values - occur in the same order as in the file. The lists of functions - are also sorted.</p> - <code type="none"> -chunkid() = "Abst" | "Attr" | "CInf" - | "ExpT" | "ImpT" | "LocT" - | "Atom" + <datatypes> + <datatype> + <name name="beam"/> + <desc> + <p>Each of the functions described below accept either the + module name, the filename, or a binary containing the beam + module.</p> + </desc> + </datatype> + <datatype> + <name name="chunkdata"/> + <desc> + <p>The list of attributes is sorted on <c>Attribute</c> + (in attrib_entry()), and each + attribute name occurs once in the list. The attribute values + occur in the same order as in the file. The lists of functions + are also sorted.</p> + </desc> + </datatype> + <datatype> + <name name="chunkid"/> + <desc> + <p>"Abst" | "Attr" | "CInf" | "ExpT" | "ImpT" | "LocT" | "Atom"</p> + </desc> + </datatype> + <datatype> + <name name="dataB"/> + </datatype> + <datatype> + <name name="abst_code"/> + <desc> + <p>It is not checked that the forms conform to the abstract format + indicated by <c><anno>AbstVersion</anno></c>. <c>no_abstract_code</c> means + that the <c>"Abst"</c> chunk is present, but empty.</p> + </desc> + </datatype> + <datatype> + <name name="forms"/> + </datatype> + <datatype> + <name name="compinfo_entry"/> + </datatype> + <datatype> + <name name="attrib_entry"/> + </datatype> + <datatype> + <name name="labeled_entry"/> + </datatype> + <datatype> + <name name="index"/> + </datatype> + <datatype> + <name name="label"/> + </datatype> + <datatype> + <name name="chunkref"/> + </datatype> + <datatype> + <name name="chunkname"/> + </datatype> + <datatype> + <name name="chnk_rsn"/> + </datatype> + <datatype> + <name name="info_rsn"/> + </datatype> + </datatypes> -chunkname() = abstract_code | attributes | compile_info - | exports | labeled_exports - | imports | indexed_imports - | locals | labeled_locals - | atoms - -chunkref() = chunkname() | chunkid()</code> - </section> <funcs> <func> - <name>chunks(Beam, [ChunkRef]) -> {ok, {Module, [ChunkData]}} | {error, beam_lib, Reason}</name> + <name name="chunks" arity="2"/> <fsummary>Read selected chunks from a BEAM file or binary</fsummary> - <type> - <v>Beam = beam()</v> - <v>ChunkRef = chunkref()</v> - <v>Module = atom()</v> - <v>ChunkData = chunkdata()</v> - <v>Reason = {unknown_chunk, Filename, atom()}</v> - <v> | {key_missing_or_invalid, Filename, abstract_code}</v> - <v> | Reason1 -- see info/1</v> - <v> Filename = string()</v> - </type> <desc> <p>Reads chunk data for selected chunks refs. The order of the returned list of chunk data is determined by the order @@ -225,43 +232,26 @@ chunkref() = chunkname() | chunkid()</code> </desc> </func> <func> - <name>chunks(Beam, [ChunkRef], [Option]) -> {ok, {Module, [ChunkResult]}} | {error, beam_lib, Reason}</name> + <name name="chunks" arity="3"/> <fsummary>Read selected chunks from a BEAM file or binary</fsummary> - <type> - <v>Beam = beam()</v> - <v>ChunkRef = chunkref()</v> - <v>Module = atom()</v> - <v>Option = allow_missing_chunks</v> - <v>ChunkResult = {chunkref(), ChunkContents} | {chunkref(), missing_chunk}</v> - <v>Reason = {missing_chunk, Filename, atom()}</v> - <v> | {key_missing_or_invalid, Filename, abstract_code}</v> - <v> | Reason1 -- see info/1</v> - <v> Filename = string()</v> - </type> <desc> <p>Reads chunk data for selected chunks refs. The order of the returned list of chunk data is determined by the order of the list of chunks references.</p> - <p>By default, if any requested chunk is missing in <c>Beam</c>, + <p>By default, if any requested chunk is missing in <c><anno>Beam</anno></c>, an <c>error</c> tuple is returned. However, if the option <c>allow_missing_chunks</c> has been given, a result will be returned even if chunks are missing. In the result list, any missing chunks will be represented as - <c>{ChunkRef,missing_chunk}</c>. + <c>{<anno>ChunkRef</anno>,missing_chunk}</c>. Note, however, that if the <c>"Atom"</c> chunk if missing, that is considered a fatal error and the return value will be an <c>error</c> tuple.</p> </desc> </func> <func> - <name>version(Beam) -> {ok, {Module, [Version]}} | {error, beam_lib, Reason}</name> + <name name="version" arity="1"/> <fsummary>Read the BEAM file's module version</fsummary> - <type> - <v>Beam = beam()</v> - <v>Module = atom()</v> - <v>Version = term()</v> - <v>Reason -- see chunks/2</v> - </type> <desc> <p>Returns the module version(s). A version is defined by the module attribute <c>-vsn(Vsn)</c>. If this attribute is @@ -282,51 +272,30 @@ chunkref() = chunkname() | chunkid()</code> </desc> </func> <func> - <name>md5(Beam) -> {ok, {Module, MD5}} | {error, beam_lib, Reason}</name> + <name name="md5" arity="1"/> <fsummary>Read the BEAM file's module version</fsummary> - <type> - <v>Beam = beam()</v> - <v>Module = atom()</v> - <v>MD5 = binary()</v> - <v>Reason -- see chunks/2</v> - </type> <desc> <p>Calculates an MD5 redundancy check for the code of the module (compilation date and other attributes are not included).</p> </desc> </func> <func> - <name>info(Beam) -> [{Item, Info}] | {error, beam_lib, Reason1}</name> + <name name="info" arity="1"/> <fsummary>Information about a BEAM file</fsummary> - <type> - <v>Beam = beam()</v> - <v>Item, Info -- see below</v> - <v>Reason1 = {chunk_too_big, Filename, ChunkId, ChunkSize, FileSize}</v> - <v> | {invalid_beam_file, Filename, Pos}</v> - <v> | {invalid_chunk, Filename, ChunkId}</v> - <v> | {missing_chunk, Filename, ChunkId}</v> - <v> | {not_a_beam_file, Filename}</v> - <v> | {file_error, Filename, Posix}</v> - <v> Filename = string()</v> - <v> ChunkId = chunkid()</v> - <v> ChunkSize = FileSize = int()</v> - <v> Pos = int()</v> - <v> Posix = posix() -- see file(3)</v> - </type> <desc> <p>Returns a list containing some information about a BEAM file as tuples <c>{Item, Info}</c>:</p> <taglist> - <tag><c>{file, Filename} | {binary, Binary}</c></tag> + <tag><c>{file, <anno>Filename</anno>} | {binary, <anno>Binary</anno>}</c></tag> <item> <p>The name (string) of the BEAM file, or the binary from which the information was extracted.</p> </item> - <tag><c>{module, Module}</c></tag> + <tag><c>{module, <anno>Module</anno>}</c></tag> <item> <p>The name (atom) of the module.</p> </item> - <tag><c>{chunks, [{ChunkId, Pos, Size}]}</c></tag> + <tag><c>{chunks, [{<anno>ChunkId</anno>, <anno>Pos</anno>, <anno>Size</anno>}]}</c></tag> <item> <p>For each chunk, the identifier (string) and the position and size of the chunk data, in bytes.</p> @@ -335,53 +304,36 @@ chunkref() = chunkname() | chunkid()</code> </desc> </func> <func> - <name>cmp(Beam1, Beam2) -> ok | {error, beam_lib, Reason}</name> + <name name="cmp" arity="2"/> <fsummary>Compare two BEAM files</fsummary> - <type> - <v>Beam1 = Beam2 = beam()</v> - <v>Reason = {modules_different, Module1, Module2}</v> - <v> | {chunks_different, ChunkId}</v> - <v> | Reason1 -- see info/1</v> - <v> Module1 = Module2 = atom()</v> - <v> ChunkId = chunkid()</v> - </type> + <type name="cmp_rsn"/> <desc> <p>Compares the contents of two BEAM files. If the module names - are the same, and the chunks with the identifiers - <c>"Code"</c>, <c>"ExpT"</c>, <c>"ImpT"</c>, <c>"StrT"</c>, - and <c>"Atom"</c> have the same contents in both files, + are the same, and all chunks except for the <c>"CInf"</c> chunk + (the chunk containing the compilation information which is + returned by <c>Module:module_info(compile)</c>) + have the same contents in both files, <c>ok</c> is returned. Otherwise an error message is returned.</p> </desc> </func> <func> - <name>cmp_dirs(Dir1, Dir2) -> {Only1, Only2, Different} | {error, beam_lib, Reason1}</name> + <name name="cmp_dirs" arity="2"/> <fsummary>Compare the BEAM files in two directories</fsummary> - <type> - <v>Dir1 = Dir2 = string() | atom()</v> - <v>Different = [{Filename1, Filename2}]</v> - <v>Only1 = Only2 = [Filename]</v> - <v>Filename = Filename1 = Filename2 = string()</v> - <v>Reason1 = {not_a_directory, term()} | -- see info/1</v> - </type> <desc> <p>The <c>cmp_dirs/2</c> function compares the BEAM files in two directories. Only files with extension <c>".beam"</c> are - compared. BEAM files that exist in directory <c>Dir1</c> - (<c>Dir2</c>) only are returned in <c>Only1</c> - (<c>Only2</c>). BEAM files that exist on both directories but + compared. BEAM files that exist in directory <c><anno>Dir1</anno></c> + (<c><anno>Dir2</anno></c>) only are returned in <c><anno>Only1</anno></c> + (<c><anno>Only2</anno></c>). BEAM files that exist on both directories but are considered different by <c>cmp/2</c> are returned as - pairs {<c>Filename1</c>, <c>Filename2</c>} where - <c>Filename1</c> (<c>Filename2</c>) exists in directory - <c>Dir1</c> (<c>Dir2</c>).</p> + pairs {<c><anno>Filename1</anno></c>, <c><anno>Filename2</anno></c>} where + <c><anno>Filename1</anno></c> (<c><anno>Filename2</anno></c>) exists in directory + <c><anno>Dir1</anno></c> (<c><anno>Dir2</anno></c>).</p> </desc> </func> <func> - <name>diff_dirs(Dir1, Dir2) -> ok | {error, beam_lib, Reason1}</name> + <name name="diff_dirs" arity="2"/> <fsummary>Compare the BEAM files in two directories</fsummary> - <type> - <v>Dir1 = Dir2 = string() | atom()</v> - <v>Reason1 = {not_a_directory, term()} | -- see info/1</v> - </type> <desc> <p>The <c>diff_dirs/2</c> function compares the BEAM files in two directories the way <c>cmp_dirs/2</c> does, but names of @@ -390,13 +342,8 @@ chunkref() = chunkname() | chunkid()</code> </desc> </func> <func> - <name>strip(Beam1) -> {ok, {Module, Beam2}} | {error, beam_lib, Reason1}</name> + <name name="strip" arity="1"/> <fsummary>Removes chunks not needed by the loader from a BEAM file</fsummary> - <type> - <v>Beam1 = Beam2 = beam()</v> - <v>Module = atom()</v> - <v>Reason1 -- see info/1</v> - </type> <desc> <p>The <c>strip/1</c> function removes all chunks from a BEAM file except those needed by the loader. In particular, @@ -404,15 +351,8 @@ chunkref() = chunkname() | chunkid()</code> </desc> </func> <func> - <name>strip_files(Files) -> {ok, [{Module, Beam2}]} | {error, beam_lib, Reason1}</name> + <name name="strip_files" arity="1"/> <fsummary>Removes chunks not needed by the loader from BEAM files</fsummary> - <type> - <v>Files = [Beam1]</v> - <v> Beam1 = beam()</v> - <v>Module = atom()</v> - <v>Beam2 = beam()</v> - <v>Reason1 -- see info/1</v> - </type> <desc> <p>The <c>strip_files/1</c> function removes all chunks except those needed by the loader from BEAM files. In particular, @@ -422,30 +362,20 @@ chunkref() = chunkname() | chunkid()</code> </desc> </func> <func> - <name>strip_release(Dir) -> {ok, [{Module, Filename]}} | {error, beam_lib, Reason1}</name> + <name name="strip_release" arity="1"/> <fsummary>Removes chunks not needed by the loader from all BEAM files of a release</fsummary> - <type> - <v>Dir = string() | atom()</v> - <v>Module = atom()</v> - <v>Filename = string()</v> - <v>Reason1 = {not_a_directory, term()} | -- see info/1</v> - </type> <desc> <p>The <c>strip_release/1</c> function removes all chunks except those needed by the loader from the BEAM files of a - release. <c>Dir</c> should be the installation root + release. <c><anno>Dir</anno></c> should be the installation root directory. For example, the current OTP release can be stripped with the call <c>beam_lib:strip_release(code:root_dir())</c>.</p> </desc> </func> <func> - <name>format_error(Reason) -> Chars</name> + <name name="format_error" arity="1"/> <fsummary>Return an English description of a BEAM read error reply</fsummary> - <type> - <v>Reason -- see other functions</v> - <v>Chars = [char() | Chars]</v> - </type> <desc> <p>Given the error returned by any function in this module, the function <c>format_error</c> returns a descriptive string @@ -454,12 +384,11 @@ chunkref() = chunkname() | chunkid()</code> </desc> </func> <func> - <name>crypto_key_fun(CryptoKeyFun) -> ok | {error, Reason}</name> + <name name="crypto_key_fun" arity="1"/> <fsummary>Register a fun that provides a crypto key</fsummary> - <type> - <v>CryptoKeyFun = fun() -- see below</v> - <v>Reason = badfun | exists | term()</v> - </type> + <type name="crypto_fun"/> + <type name="crypto_fun_arg"/> + <type name="mode"/> <desc> <p>The <c>crypto_key_fun/1</c> function registers a unary fun that will be called if <c>beam_lib</c> needs to read an @@ -493,11 +422,8 @@ chunkref() = chunkname() | chunkid()</code> </desc> </func> <func> - <name>clear_crypto_key_fun() -> {ok, Result}</name> + <name name="clear_crypto_key_fun" arity="0"/> <fsummary>Unregister the current crypto key fun</fsummary> - <type> - <v>Result = undefined | term()</v> - </type> <desc> <p>Unregisters the crypto key fun and terminates the process holding it, started by <c>crypto_key_fun/1</c>.</p> diff --git a/lib/stdlib/doc/src/binary.xml b/lib/stdlib/doc/src/binary.xml new file mode 100644 index 0000000000..88ce77e0d0 --- /dev/null +++ b/lib/stdlib/doc/src/binary.xml @@ -0,0 +1,701 @@ +<?xml version="1.0" encoding="latin1" ?> +<!DOCTYPE erlref SYSTEM "erlref.dtd"> + +<erlref> + <header> + <copyright> + <year>2009</year> + <year>2011</year> + <holder>Ericsson AB, All Rights Reserved</holder> + </copyright> + <legalnotice> + The contents of this file are subject to the Erlang Public License, + Version 1.1, (the "License"); you may not use this file except in + compliance with the License. You should have received a copy of the + Erlang Public License along with this software. If not, it can be + retrieved on line at http://www.erlang.org/. + + Software distributed under the License is distributed on an "AS IS" + basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + the License for the specific language governing rights and limitations + under the License. + + The Initial Developer of the Original Code is Ericsson AB. + </legalnotice> + + <title>binary</title> + <prepared>Patrik Nyblom</prepared> + <responsible>Kenneth Lundin</responsible> + <docno>1</docno> + <approved></approved> + <checked></checked> + <date>2010-05-05</date> + <rev>A</rev> + <file>binary.xml</file> + </header> + <module>binary</module> + <modulesummary>Library for handling binary data</modulesummary> + <description> + + <p>This module contains functions for manipulating byte-oriented + binaries. Although the majority of functions could be implemented + using bit-syntax, the functions in this library are highly + optimized and are expected to either execute faster or consume + less memory (or both) than a counterpart written in pure Erlang.</p> + + <p>The module is implemented according to the EEP (Erlang Enhancement Proposal) 31.</p> + + <note> + <p> + The library handles byte-oriented data. Bitstrings that are not + binaries (does not contain whole octets of bits) will result in a <c>badarg</c> + exception being thrown from any of the functions in this + module. + </p> + </note> + </description> + <datatypes> + <datatype> + <name name="cp"/> + <desc><p>Opaque data-type representing a compiled + search-pattern. Guaranteed to be a tuple() to allow programs to + distinguish it from non precompiled search patterns.</p> + </desc> + </datatype> + <datatype> + <name name="part"/> + <desc><p>A representaion of a part (or range) in a binary. Start is a + zero-based offset into a binary() and Length is the length of + that part. As input to functions in this module, a reverse + part specification is allowed, constructed with a negative + Length, so that the part of the binary begins at Start + + Length and is -Length long. This is useful for referencing the + last N bytes of a binary as {size(Binary), -N}. The functions + in this module always return part()'s with positive Length.</p> + </desc> + </datatype> + </datatypes> + <funcs> + <func> + <name>at(Subject, Pos) -> byte()</name> + <fsummary>Returns the byte at a specific position in a binary</fsummary> + <type> + <v>Subject = binary()</v> + <v>Pos = integer() >= 0</v> + </type> + <desc> + + <p>Returns the byte at position <c>Pos</c> (zero-based) in the binary + <c>Subject</c> as an integer. If <c>Pos</c> >= <c>byte_size(Subject)</c>, + a <c>badarg</c> + exception is raised.</p> + + </desc> + </func> + <func> + <name>bin_to_list(Subject) -> [byte()]</name> + <fsummary>Convert a binary to a list of integers</fsummary> + <type> + <v>Subject = binary()</v> + </type> + <desc> + <p>The same as <c>bin_to_list(Subject,{0,byte_size(Subject)})</c>.</p> + </desc> + </func> + <func> + <name>bin_to_list(Subject, PosLen) -> [byte()]</name> + <fsummary>Convert a binary to a list of integers</fsummary> + <type> + <v>Subject = binary()</v> + <v>PosLen = part()</v> + </type> + <desc> + + <p>Converts <c>Subject</c> to a list of <c>byte()</c>s, each representing + the value of one byte. The <c>part()</c> denotes which part of the + <c>binary()</c> to convert. Example:</p> + +<code> +1> binary:bin_to_list(<<"erlang">>,{1,3}). +"rla" +%% or [114,108,97] in list notation. +</code> + <p>If <c>PosLen</c> in any way references outside the binary, a <c>badarg</c> exception is raised.</p> + </desc> + </func> + <func> + <name>bin_to_list(Subject, Pos, Len) -> [byte()]</name> + <fsummary>Convert a binary to a list of integers</fsummary> + <type> + <v>Subject = binary()</v> + <v>Pos = integer() >= 0</v> + <v>Len = integer() >= 0</v> + </type> + <desc> + <p>The same as<c> bin_to_list(Subject,{Pos,Len})</c>.</p> + </desc> + </func> + <func> + <name>compile_pattern(Pattern) -> cp()</name> + <fsummary>Pre-compiles a binary search pattern</fsummary> + <type> + <v>Pattern = binary() | [ binary() ]</v> + </type> + <desc> + + <p>Builds an internal structure representing a compilation of a + search-pattern, later to be used in the <seealso marker="#match-3">match/3</seealso>, + <seealso marker="#matches-3">matches/3</seealso>, + <seealso marker="#split-3">split/3</seealso> or + <seealso marker="#replace-4">replace/4</seealso> + functions. The <c>cp()</c> returned is guaranteed to be a + <c>tuple()</c> to allow programs to distinguish it from non + pre-compiled search patterns</p> + + <p>When a list of binaries is given, it denotes a set of + alternative binaries to search for. I.e if + <c>[<<"functional">>,<<"programming">>]</c> + is given as <c>Pattern</c>, this + means "either <c><<"functional">></c> or + <c><<"programming">></c>". The pattern is a set of + alternatives; when only a single binary is given, the set has + only one element. The order of alternatives in a pattern is not significant.</p> + + <p>The list of binaries used for search alternatives shall be flat and proper.</p> + + <p>If <c>Pattern</c> is not a binary or a flat proper list of binaries with length > 0, + a <c>badarg</c> exception will be raised.</p> + + </desc> + </func> + <func> + <name>copy(Subject) -> binary()</name> + <fsummary>Creates a duplicate of a binary</fsummary> + <type> + <v>Subject = binary()</v> + </type> + <desc> + <p>The same as <c>copy(Subject, 1)</c>.</p> + </desc> + </func> + <func> + <name>copy(Subject,N) -> binary()</name> + <fsummary>Duplicates a binary N times and creates a new</fsummary> + <type> + <v>Subject = binary()</v> + <v>N = integer() >= 0</v> + </type> + <desc> + <p>Creates a binary with the content of <c>Subject</c> duplicated <c>N</c> times.</p> + + <p>This function will always create a new binary, even if <c>N = + 1</c>. By using <c>copy/1</c> on a binary referencing a larger binary, one + might free up the larger binary for garbage collection.</p> + + <note> + <p>By deliberately copying a single binary to avoid referencing + a larger binary, one might, instead of freeing up the larger + binary for later garbage collection, create much more binary + data than needed. Sharing binary data is usually good. Only in + special cases, when small parts reference large binaries and the + large binaries are no longer used in any process, deliberate + copying might be a good idea.</p> </note> + + <p>If <c>N</c> < <c>0</c>, a <c>badarg</c> exception is raised.</p> + </desc> + </func> + <func> + <name>decode_unsigned(Subject) -> Unsigned</name> + <fsummary>Decode a whole binary into an integer of arbitrary size</fsummary> + <type> + <v>Subject = binary()</v> + <v>Unsigned = integer() >= 0</v> + </type> + <desc> + <p>The same as <c>decode_unsigned(Subject,big)</c>.</p> + </desc> + </func> + <func> + <name>decode_unsigned(Subject, Endianess) -> Unsigned</name> + <fsummary>Decode a whole binary into an integer of arbitrary size</fsummary> + <type> + <v>Subject = binary()</v> + <v>Endianess = big | little</v> + <v>Unsigned = integer() >= 0</v> + </type> + <desc> + + <p>Converts the binary digit representation, in big or little + endian, of a positive integer in <c>Subject</c> to an Erlang <c>integer()</c>.</p> + + <p>Example:</p> + + <code> +1> binary:decode_unsigned(<<169,138,199>>,big). +11111111 + </code> + </desc> + </func> + <func> + <name>encode_unsigned(Unsigned) -> binary()</name> + <fsummary>Encodes an unsigned integer into the minimal binary</fsummary> + <type> + <v>Unsigned = integer() >= 0</v> + </type> + <desc> + <p>The same as <c>encode_unsigned(Unsigned,big)</c>.</p> + </desc> + </func> + <func> + <name>encode_unsigned(Unsigned,Endianess) -> binary()</name> + <fsummary>Encodes an unsigned integer into the minimal binary</fsummary> + <type> + <v>Unsigned = integer() >= 0</v> + <v>Endianess = big | little</v> + </type> + <desc> + + <p>Converts a positive integer to the smallest possible + representation in a binary digit representation, either big + or little endian.</p> + + <p>Example:</p> + + <code> +1> binary:encode_unsigned(11111111,big). +<<169,138,199>> + </code> + </desc> + </func> + <func> + <name>first(Subject) -> byte()</name> + <fsummary>Returns the first byte of a binary</fsummary> + <type> + <v>Subject = binary()</v> + </type> + <desc> + + <p>Returns the first byte of the binary <c>Subject</c> as an integer. If the + size of <c>Subject</c> is zero, a <c>badarg</c> exception is raised.</p> + + </desc> + </func> + <func> + <name>last(Subject) -> byte()</name> + <fsummary>Returns the last byte of a binary</fsummary> + <type> + <v>Subject = binary()</v> + </type> + <desc> + + <p>Returns the last byte of the binary <c>Subject</c> as an integer. If the + size of <c>Subject</c> is zero, a <c>badarg</c> exception is raised.</p> + + </desc> + </func> + <func> + <name>list_to_bin(ByteList) -> binary()</name> + <fsummary>Convert a list of integers and binaries to a binary</fsummary> + <type> + <v>ByteList = iodata() (see module erlang)</v> + </type> + <desc> + <p>Works exactly as <c>erlang:list_to_binary/1</c>, added for completeness.</p> + </desc> + </func> + <func> + <name>longest_common_prefix(Binaries) -> integer() >= 0</name> + <fsummary>Returns length of longest common prefix for a set of binaries</fsummary> + <type> + <v>Binaries = [ binary() ]</v> + </type> + <desc> + + <p>Returns the length of the longest common prefix of the + binaries in the list <c>Binaries</c>. Example:</p> + +<code> +1> binary:longest_common_prefix([<<"erlang">>,<<"ergonomy">>]). +2 +2> binary:longest_common_prefix([<<"erlang">>,<<"perl">>]). +0 +</code> + + <p>If <c>Binaries</c> is not a flat list of binaries, a <c>badarg</c> exception is raised.</p> + </desc> + </func> + <func> + <name>longest_common_suffix(Binaries) -> integer() >= 0</name> + <fsummary>Returns length of longest common suffix for a set of binaries</fsummary> + <type> + <v>Binaries = [ binary() ]</v> + </type> + <desc> + + <p>Returns the length of the longest common suffix of the + binaries in the list <c>Binaries</c>. Example:</p> + +<code> +1> binary:longest_common_suffix([<<"erlang">>,<<"fang">>]). +3 +2> binary:longest_common_suffix([<<"erlang">>,<<"perl">>]). +0 +</code> + + <p>If <c>Binaries</c> is not a flat list of binaries, a <c>badarg</c> exception is raised.</p> + + </desc> + </func> + <func> + <name>match(Subject, Pattern) -> Found | <c>nomatch</c></name> + <fsummary>Searches for the first match of a pattern in a binary</fsummary> + <type> + <v>Subject = binary()</v> + <v>Pattern = binary() | [ binary() ] | cp()</v> + <v>Found = part()</v> + </type> + <desc> + <p>The same as <c>match(Subject, Pattern, [])</c>.</p> + </desc> + </func> + <func> + <name>match(Subject,Pattern,Options) -> Found | <c>nomatch</c></name> + <fsummary>Searches for the first match of a pattern in a binary</fsummary> + <type> + <v>Subject = binary()</v> + <v>Pattern = binary() | [ binary() ] | cp()</v> + <v>Found = part()</v> + <v>Options = [ Option ]</v> + <v>Option = {scope, part()}</v> + </type> + <desc> + + <p>Searches for the first occurrence of <c>Pattern</c> in <c>Subject</c> and + returns the position and length.</p> + + <p>The function will return <c>{Pos,Length}</c> for the binary + in <c>Pattern</c> starting at the lowest position in + <c>Subject</c>, Example:</p> + +<code> +1> binary:match(<<"abcde">>, [<<"bcde">>,<<"cd">>],[]). +{1,4} +</code> + + <p>Even though <c><<"cd">></c> ends before + <c><<"bcde">></c>, <c><<"bcde">></c> + begins first and is therefore the first match. If two + overlapping matches begin at the same position, the longest is + returned.</p> + + <p>Summary of the options:</p> + + <taglist> + <tag>{scope, {Start, Length}}</tag> + <item><p>Only the given part is searched. Return values still have + offsets from the beginning of <c>Subject</c>. A negative <c>Length</c> is + allowed as described in the <c>TYPES</c> section of this manual.</p></item> + </taglist> + + <p>If none of the strings in + <c>Pattern</c> is found, the atom <c>nomatch</c> is returned.</p> + + <p>For a description of <c>Pattern</c>, see + <seealso marker="#compile_pattern-1">compile_pattern/1</seealso>.</p> + + <p>If <c>{scope, {Start,Length}}</c> is given in the options + such that <c>Start</c> is larger than the size of + <c>Subject</c>, <c>Start + Length</c> is less than zero or + <c>Start + Length</c> is larger than the size of + <c>Subject</c>, a <c>badarg</c> exception is raised.</p> + + </desc> + </func> + <func> + <name>matches(Subject, Pattern) -> Found</name> + <fsummary>Searches for all matches of a pattern in a binary</fsummary> + <type> + <v>Subject = binary()</v> + <v>Pattern = binary() | [ binary() ] | cp()</v> + <v>Found = [ part() ] | []</v> + </type> + <desc> + <p>The same as <c>matches(Subject, Pattern, [])</c>.</p> + </desc> + </func> + <func> + <name>matches(Subject,Pattern,Options) -> Found</name> + <fsummary>Searches for all matches of a pattern in a binary</fsummary> + <type> + <v>Subject = binary()</v> + <v>Pattern = binary() | [ binary() ] | cp()</v> + <v>Found = [ part() ] | []</v> + <v>Options = [ Option ]</v> + <v>Option = {scope, part()}</v> + </type> + <desc> + + <p>Works like match, but the <c>Subject</c> is searched until + exhausted and a list of all non-overlapping parts matching + <c>Pattern</c> is returned (in order). </p> + + <p>The first and longest match is preferred to a shorter, + which is illustrated by the following example:</p> + +<code> +1> binary:matches(<<"abcde">>, + [<<"bcde">>,<<"bc">>>,<<"de">>],[]). +[{1,4}] +</code> + + <p>The result shows that <<"bcde">> is selected instead of the + shorter match <<"bc">> (which would have given raise to one + more match,<<"de">>). This corresponds to the behavior of posix + regular expressions (and programs like awk), but is not + consistent with alternative matches in re (and Perl), where + instead lexical ordering in the search pattern selects which + string matches.</p> + + <p>If none of the strings in pattern is found, an empty list is returned.</p> + + <p>For a description of <c>Pattern</c>, see <seealso marker="#compile_pattern-1">compile_pattern/1</seealso> and for a + description of available options, see <seealso marker="#match-3">match/3</seealso>.</p> + + <p>If <c>{scope, {Start,Length}}</c> is given in the options such that + <c>Start</c> is larger than the size of <c>Subject</c>, <c>Start + Length</c> is + less than zero or <c>Start + Length</c> is larger than the size of + <c>Subject</c>, a <c>badarg</c> exception is raised.</p> + + </desc> + </func> + <func> + <name>part(Subject, PosLen) -> binary()</name> + <fsummary>Extracts a part of a binary</fsummary> + <type> + <v>Subject = binary()</v> + <v>PosLen = part()</v> + </type> + <desc> + + <p>Extracts the part of the binary <c>Subject</c> described by <c>PosLen</c>.</p> + + <p>Negative length can be used to extract bytes at the end of a binary:</p> + +<code> +1> Bin = <<1,2,3,4,5,6,7,8,9,10>>. +2> binary:part(Bin,{byte_size(Bin), -5}). +<<6,7,8,9,10>> +</code> + + <note> + <p><seealso marker="#part-2">part/2</seealso>and <seealso + marker="#part-3">part/3</seealso> are also available in the + <c>erlang</c> module under the names <c>binary_part/2</c> and + <c>binary_part/3</c>. Those BIFs are allowed in guard tests.</p> + </note> + + <p>If <c>PosLen</c> in any way references outside the binary, a <c>badarg</c> exception + is raised.</p> + + </desc> + </func> + <func> + <name>part(Subject, Pos, Len) -> binary()</name> + <fsummary>Extracts a part of a binary</fsummary> + <type> + <v>Subject = binary()</v> + <v>Pos = integer() >= 0</v> + <v>Len = integer() >= 0</v> + </type> + <desc> + <p>The same as <c>part(Subject, {Pos, Len})</c>.</p> + </desc> + </func> + <func> + <name>referenced_byte_size(binary()) -> integer() >= 0</name> + <fsummary>Determines the size of the actual binary pointed out by a sub-binary</fsummary> + <desc> + + <p>If a binary references a larger binary (often described as + being a sub-binary), it can be useful to get the size of the + actual referenced binary. This function can be used in a program + to trigger the use of <c>copy/1</c>. By copying a binary, one might + dereference the original, possibly large, binary which a smaller + binary is a reference to.</p> + + <p>Example:</p> + + <code> +store(Binary, GBSet) -> + NewBin = + case binary:referenced_byte_size(Binary) of + Large when Large > 2 * byte_size(Binary) -> + binary:copy(Binary); + _ -> + Binary + end, + gb_sets:insert(NewBin,GBSet). + </code> + + <p>In this example, we chose to copy the binary content before + inserting it in the <c>gb_set()</c> if it references a binary more than + twice the size of the data we're going to keep. Of course + different rules for when copying will apply to different + programs.</p> + + <p>Binary sharing will occur whenever binaries are taken apart, + this is the fundamental reason why binaries are fast, + decomposition can always be done with O(1) complexity. In rare + circumstances this data sharing is however undesirable, why this + function together with <c>copy/1</c> might be useful when optimizing + for memory use.</p> + + <p>Example of binary sharing:</p> + + <code> +1> A = binary:copy(<<1>>,100). +<<1,1,1,1,1 ... +2> byte_size(A). +100 +3> binary:referenced_byte_size(A) +100 +4> <<_:10/binary,B:10/binary,_/binary>> = A. +<<1,1,1,1,1 ... +5> byte_size(B). +10 +6> binary:referenced_byte_size(B) +100 + </code> + + <note> + <p>Binary data is shared among processes. If another process + still references the larger binary, copying the part this + process uses only consumes more memory and will not free up the + larger binary for garbage collection. Use this kind of intrusive + functions with extreme care, and only if a real problem is + detected.</p> + </note> + + </desc> + </func> + <func> + <name name="replace" arity="3"/> + <fsummary>Replaces bytes in a binary according to a pattern</fsummary> + <desc> + <p>The same as <c>replace(<anno>Subject</anno>,<anno>Pattern</anno>,<anno>Replacement</anno>,[])</c>.</p> + </desc> + </func> + <func> + <name name="replace" arity="4"/> + <fsummary>Replaces bytes in a binary according to a pattern</fsummary> + <type_desc variable="OnePos">An integer() =< byte_size(<anno>Replacement</anno>) + </type_desc> + <desc> + + <p>Constructs a new binary by replacing the parts in + <c><anno>Subject</anno></c> matching <c><anno>Pattern</anno></c> with the content of + <c><anno>Replacement</anno></c>.</p> + + <p>If the matching sub-part of <c><anno>Subject</anno></c> giving raise to the + replacement is to be inserted in the result, the option + <c>{insert_replaced, <anno>InsPos</anno>}</c> will insert the matching part into + <c><anno>Replacement</anno></c> at the given position (or positions) before actually + inserting <c><anno>Replacement</anno></c> into the <c><anno>Subject</anno></c>. Example:</p> + +<code> +1> binary:replace(<<"abcde">>,<<"b">>,<<"[]">>,[{insert_replaced,1}]). +<<"a[b]cde">> +2> binary:replace(<<"abcde">>,[<<"b">>,<<"d">>],<<"[]">>, + [global,{insert_replaced,1}]). +<<"a[b]c[d]e">> +3> binary:replace(<<"abcde">>,[<<"b">>,<<"d">>],<<"[]">>, + [global,{insert_replaced,[1,1]}]). +<<"a[bb]c[dd]e">> +4> binary:replace(<<"abcde">>,[<<"b">>,<<"d">>],<<"[-]">>, + [global,{insert_replaced,[1,2]}]). +<<"a[b-b]c[d-d]e">> +</code> + + <p>If any position given in <c><anno>InsPos</anno></c> is greater than the size of the replacement binary, a <c>badarg</c> exception is raised.</p> + + <p>The options <c>global</c> and <c>{scope, part()}</c> work as for <seealso marker="#split-3">split/3</seealso>. The return type is always a <c>binary()</c>.</p> + + <p>For a description of <c><anno>Pattern</anno></c>, see <seealso marker="#compile_pattern-1">compile_pattern/1</seealso>.</p> + </desc> + </func> + <func> + <name name="split" arity="2"/> + <fsummary>Splits a binary according to a pattern</fsummary> + <desc> + <p>The same as <c>split(<anno>Subject</anno>, <anno>Pattern</anno>, [])</c>.</p> + </desc> + </func> + <func> + <name name="split" arity="3"/> + <fsummary>Splits a binary according to a pattern</fsummary> + <desc> + + <p>Splits <c><anno>Subject</anno></c> into a list of binaries based on <c><anno>Pattern</anno></c>. If + the option global is not given, only the first occurrence of + <c><anno>Pattern</anno></c> in <c><anno>Subject</anno></c> will give rise to a split.</p> + + <p>The parts of <c><anno>Pattern</anno></c> actually found in <c><anno>Subject</anno></c> are not included in the result.</p> + + <p>Example:</p> + +<code> +1> binary:split(<<1,255,4,0,0,0,2,3>>, [<<0,0,0>>,<<2>>],[]). +[<<1,255,4>>, <<2,3>>] +2> binary:split(<<0,1,0,0,4,255,255,9>>, [<<0,0>>, <<255,255>>],[global]). +[<<0,1>>,<<4>>,<<9>>] +</code> + + <p>Summary of options:</p> + <taglist> + + <tag>{scope, part()}</tag> + + <item><p>Works as in <seealso marker="#match-3">match/3</seealso> and + <seealso marker="#matches-3">matches/3</seealso>. Note that + this only defines the scope of the search for matching strings, + it does not cut the binary before splitting. The bytes before + and after the scope will be kept in the result. See example + below.</p></item> + + <tag>trim</tag> + + <item><p>Removes trailing empty parts of the result (as does trim in <c>re:split/3</c>)</p></item> + + <tag>global</tag> + + <item><p>Repeats the split until the <c><anno>Subject</anno></c> is + exhausted. Conceptually the global option makes split work on + the positions returned by <seealso marker="#matches-3">matches/3</seealso>, + while it normally + works on the position returned by + <seealso marker="#match-3">match/3</seealso>.</p></item> + + </taglist> + + <p>Example of the difference between a scope and taking the + binary apart before splitting:</p> + +<code> +1> binary:split(<<"banana">>,[<<"a">>],[{scope,{2,3}}]). +[<<"ban">>,<<"na">>] +2> binary:split(binary:part(<<"banana">>,{2,3}),[<<"a">>],[]). +[<<"n">>,<<"n">>] +</code> + + <p>The return type is always a list of binaries that are all + referencing <c><anno>Subject</anno></c>. This means that the data in <c><anno>Subject</anno></c> is not + actually copied to new binaries and that <c><anno>Subject</anno></c> cannot be + garbage collected until the results of the split are no longer + referenced.</p> + + <p>For a description of <c><anno>Pattern</anno></c>, see <seealso marker="#compile_pattern-1">compile_pattern/1</seealso>.</p> + + </desc> + </func> + </funcs> +</erlref> diff --git a/lib/stdlib/doc/src/c.xml b/lib/stdlib/doc/src/c.xml index 19e3ac1f08..ddae388a1b 100644 --- a/lib/stdlib/doc/src/c.xml +++ b/lib/stdlib/doc/src/c.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2009</year> + <year>1996</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -39,43 +39,33 @@ </description> <funcs> <func> - <name>bt(Pid) -> void()</name> + <name name="bt" arity="1"/> <fsummary>Stack backtrace for a process</fsummary> - <type> - <v>Pid = pid()</v> - </type> <desc> <p>Stack backtrace for a process. Equivalent to - <c>erlang:process_display(Pid, backtrace)</c>.</p> + <c>erlang:process_display(<anno>Pid</anno>, backtrace)</c>.</p> </desc> </func> <func> - <name>c(File) -> {ok, Module} | error</name> - <name>c(File, Options) -> {ok, Module} | error</name> + <name name="c" arity="1"/> + <name name="c" arity="2"/> <fsummary>Compile and load code in a file</fsummary> - <type> - <v>File = name() -- see filename(3)</v> - <v>Options = [Opt] -- see compile:file/2</v> - </type> <desc> <p><c>c/1,2</c> compiles and then purges and loads the code for - a file. <c>Options</c> defaults to []. Compilation is + a file. <c><anno>Options</anno></c> defaults to []. Compilation is equivalent to:</p> <code type="none"> -compile:file(File, Options ++ [report_errors, report_warnings])</code> +compile:file(<anno>File</anno>, <anno>Options</anno> ++ [report_errors, report_warnings])</code> <p>Note that purging the code means that any processes lingering in old code for the module are killed without warning. See <c>code/3</c> for more information.</p> </desc> </func> <func> - <name>cd(Dir) -> void()</name> + <name name="cd" arity="1"/> <fsummary>Change working directory</fsummary> - <type> - <v>Dir = name() -- see filename(3)</v> - </type> <desc> - <p>Changes working directory to <c>Dir</c>, which may be a + <p>Changes working directory to <c><anno>Dir</anno></c>, which may be a relative name, and then prints the name of the new working directory.</p> <pre> @@ -84,14 +74,14 @@ compile:file(File, Options ++ [report_errors, report_warnings])</code> </desc> </func> <func> - <name>flush() -> void()</name> + <name name="flush" arity="0"/> <fsummary>Flush any messages sent to the shell</fsummary> <desc> <p>Flushes any messages sent to the shell.</p> </desc> </func> <func> - <name>help() -> void()</name> + <name name="help" arity="0"/> <fsummary>Help information</fsummary> <desc> <p>Displays help information: all valid shell internal commands, @@ -99,8 +89,8 @@ compile:file(File, Options ++ [report_errors, report_warnings])</code> </desc> </func> <func> - <name>i() -> void()</name> - <name>ni() -> void()</name> + <name name="i" arity="0"/> + <name name="ni" arity="0"/> <fsummary>Information about the system</fsummary> <desc> <p><c>i/0</c> displays information about the system, listing @@ -109,26 +99,20 @@ compile:file(File, Options ++ [report_errors, report_warnings])</code> </desc> </func> <func> - <name>i(X, Y, Z) -> void()</name> + <name name="i" arity="3"/> <fsummary>Information about pid <X.Y.Z></fsummary> - <type> - <v>X = Y = Z = int()</v> - </type> <desc> <p>Displays information about a process, Equivalent to - <c>process_info(pid(X, Y, Z))</c>, but location transparent.</p> + <c>process_info(pid(<anno>X</anno>, <anno>Y</anno>, <anno>Z</anno>))</c>, but location transparent.</p> </desc> </func> <func> - <name>l(Module) -> void()</name> + <name name="l" arity="1"/> <fsummary>Load or reload module</fsummary> - <type> - <v>Module = atom()</v> - </type> <desc> <p>Purges and loads, or reloads, a module by calling - <c>code:purge(Module)</c> followed by - <c>code:load_file(Module)</c>.</p> + <c>code:purge(<anno>Module</anno>)</c> followed by + <c>code:load_file(<anno>Module</anno>)</c>.</p> <p>Note that purging the code means that any processes lingering in old code for the module are killed without warning. See <c>code/3</c> for more information.</p> @@ -136,35 +120,33 @@ compile:file(File, Options ++ [report_errors, report_warnings])</code> </func> <func> <name>lc(Files) -> ok</name> - <fsummary>Compile a list of files</fsummary> <type> <v>Files = [File]</v> - <v> File = name() -- see filename(3)</v> + <v>File = <seealso marker="file#type-filename">file:filename() + </seealso></v> </type> + <fsummary>Compile a list of files</fsummary> <desc> <p>Compiles a list of files by calling <c>compile:file(File, [report_errors, report_warnings])</c> for each <c>File</c> in <c>Files</c>.</p> </desc> </func> <func> - <name>ls() -> void()</name> + <name name="ls" arity="0"/> <fsummary>List files in the current directory</fsummary> <desc> <p>Lists files in the current directory.</p> </desc> </func> <func> - <name>ls(Dir) -> void()</name> + <name name="ls" arity="1"/> <fsummary>List files in a directory</fsummary> - <type> - <v>Dir = name() -- see filename(3)</v> - </type> <desc> - <p>Lists files in directory <c>Dir</c>.</p> + <p>Lists files in directory <c><anno>Dir</anno></c>.</p> </desc> </func> <func> - <name>m() -> void()</name> + <name name="m" arity="0"/> <fsummary>Which modules are loaded</fsummary> <desc> <p>Displays information about the loaded modules, including @@ -172,84 +154,67 @@ compile:file(File, Options ++ [report_errors, report_warnings])</code> </desc> </func> <func> - <name>m(Module) -> void()</name> + <name name="m" arity="1"/> <fsummary>Information about a module</fsummary> - <type> - <v>Module = atom()</v> - </type> <desc> - <p>Displays information about <c>Module</c>.</p> + <p>Displays information about <c><anno>Module</anno></c>.</p> </desc> </func> <func> - <name>memory() -> [{Type, Size}]</name> + <name name="memory" arity="0"/> <fsummary>Memory allocation information</fsummary> - <type> - <v>Type, Size -- see erlang:memory/0</v> - </type> <desc> <p>Memory allocation information. Equivalent to - <c>erlang:memory/0</c>.</p> + <seealso marker="erts:erlang#memory/0"><c>erlang:memory/0</c> + </seealso>.</p> </desc> </func> <func> - <name>memory(Type) -> Size</name> - <name>memory([Type]) -> [{Type, Size}]</name> + <name name="memory" arity="1" clause_i="1"/> + <name name="memory" arity="1" clause_i="2"/> <fsummary>Memory allocation information</fsummary> - <type> - <v>Type, Size -- see erlang:memory/0</v> - </type> <desc> <p>Memory allocation information. Equivalent to - <c>erlang:memory/1</c>.</p> + <seealso marker="erts:erlang#memory/1"><c>erlang:memory/1</c> + </seealso>.</p> </desc> </func> <func> - <name>nc(File) -> {ok, Module} | error</name> - <name>nc(File, Options) -> {ok, Module} | error</name> + <name name="nc" arity="1"/> + <name name="nc" arity="2"/> <fsummary>Compile and load code in a file on all nodes</fsummary> - <type> - <v>File = name() -- see filename(3)</v> - <v>Options = [Opt] -- see compile:file/2</v> - </type> <desc> <p>Compiles and then loads the code for a file on all nodes. - <c>Options</c> defaults to []. Compilation is equivalent to:</p> + <c><anno>Options</anno></c> defaults to []. Compilation is equivalent to:</p> <code type="none"> -compile:file(File, Opts ++ [report_errors, report_warnings])</code> +compile:file(<anno>File</anno>, <anno>Options</anno> ++ [report_errors, report_warnings])</code> </desc> </func> <func> - <name>nl(Module) -> void()</name> + <name name="nl" arity="1"/> <fsummary>Load module on all nodes</fsummary> - <type> - <v>Module = atom()</v> - </type> <desc> - <p>Loads <c>Module</c> on all nodes.</p> + <p>Loads <c><anno>Module</anno></c> on all nodes.</p> </desc> </func> <func> - <name>pid(X, Y, Z) -> pid()</name> + <name name="pid" arity="3"/> <fsummary>Convert X,Y,Z to a pid</fsummary> - <type> - <v>X = Y = Z = int()</v> - </type> <desc> - <p>Converts <c>X</c>, <c>Y</c>, <c>Z</c> to the pid + <p>Converts <c><anno>X</anno></c>, <c><anno>Y</anno></c>, <c><anno>Z</anno></c> to the pid <c><![CDATA[<X.Y.Z>]]></c>. This function should only be used when debugging.</p> </desc> </func> <func> - <name>pwd() -> void()</name> + <name name="pwd" arity="0"/> <fsummary>Print working directory</fsummary> <desc> <p>Prints the name of the working directory.</p> </desc> </func> <func> - <name>q() -> void()</name> + <name name="q" arity="0"/> <fsummary>Quit - shorthand for <c>init:stop()</c></fsummary> <desc> <p>This function is shorthand for <c>init:stop()</c>, that is, @@ -257,8 +222,8 @@ compile:file(File, Opts ++ [report_errors, report_warnings])</code> </desc> </func> <func> - <name>regs() -> void()</name> - <name>nregs() -> void()</name> + <name name="regs" arity="0"/> + <name name="nregs" arity="0"/> <fsummary>Information about registered processes</fsummary> <desc> <p><c>regs/0</c> displays information about all registered diff --git a/lib/stdlib/doc/src/calendar.xml b/lib/stdlib/doc/src/calendar.xml index 36f0c03162..f8db48e00c 100644 --- a/lib/stdlib/doc/src/calendar.xml +++ b/lib/stdlib/doc/src/calendar.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2009</year> + <year>1996</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -63,121 +63,165 @@ given as local time, they must be converted to universal time, in order to get the correct value of the elapsed time between epochs. Use of the function <c>time_difference/2</c> is discouraged.</p> + <p>There exists different definitions for the week of the year. + The calendar module contains a week of the year implementation + which conforms to the ISO 8601 standard. Since the week number for + a given date can fall on the previous, the current or on the next + year it is important to provide the information which year is it + together with the week number. The function <c>iso_week_number/0</c> + and <c>iso_week_number/1</c> returns a tuple of the year and the + week number.</p> </description> - <section> - <title>DATA TYPES</title> - <code type="none"> -date() = {Year, Month, Day} - Year = int() - Month = 1..12 - Day = 1..31 -Year cannot be abbreviated. Example: 93 denotes year 93, not 1993. -Valid range depends on the underlying OS. -The date tuple must denote a valid date. + <datatypes> + <datatype> + <name name="datetime"/> + </datatype> + <datatype> + <name name="datetime1970"/> + </datatype> + <datatype> + <name name="date"/> + </datatype> + <datatype> + <name name="year"/> + <desc><p>Year cannot be abbreviated. Example: 93 denotes year + 93, not 1993. Valid range depends on the underlying OS. The + date tuple must denote a valid date.</p> + </desc> + </datatype> + <datatype> + <name name="year1970"/> + </datatype> + <datatype> + <name name="month"/> + </datatype> + <datatype> + <name name="day"/> + </datatype> + <datatype> + <name name="time"/> + </datatype> + <datatype> + <name name="hour"/> + </datatype> + <datatype> + <name name="minute"/> + </datatype> + <datatype> + <name name="second"/> + </datatype> + <datatype> + <name name="daynum"/> + </datatype> + <datatype> + <name name="ldom"/> + </datatype> + <datatype> + <name name="yearweeknum"/> + </datatype> + <datatype> + <name name="weeknum"/> + </datatype> + </datatypes> -time() = {Hour, Minute, Second} - Hour = 0..23 - Minute = Second = 0..59</code> - </section> <funcs> <func> - <name>date_to_gregorian_days(Date) -> Days</name> - <name>date_to_gregorian_days(Year, Month, Day) -> Days</name> + <name name="date_to_gregorian_days" arity="1"/> + <name name="date_to_gregorian_days" arity="3"/> + <type variable="Date" name_i="1"/> + <type variable="Year"/> + <type variable="Month"/> + <type variable="Day"/> <fsummary>Compute the number of days from year 0 up to the given date</fsummary> - <type> - <v>Date = date()</v> - <v>Days = int()</v> - </type> <desc> <p>This function computes the number of gregorian days starting with year 0 and ending at the given date.</p> </desc> </func> <func> - <name>datetime_to_gregorian_seconds({Date, Time}) -> Seconds</name> + <name name="datetime_to_gregorian_seconds" arity="1"/> <fsummary>Compute the number of seconds from year 0 up to the given date and time</fsummary> - <type> - <v>Date = date()</v> - <v>Time = time()</v> - <v>Seconds = int()</v> - </type> <desc> <p>This function computes the number of gregorian seconds starting with year 0 and ending at the given date and time.</p> </desc> </func> <func> - <name>day_of_the_week(Date) -> DayNumber</name> - <name>day_of_the_week(Year, Month, Day) -> DayNumber</name> + <name name="day_of_the_week" arity="1"/> + <name name="day_of_the_week" arity="3"/> <fsummary>Compute the day of the week</fsummary> - <type> - <v>Date = date()</v> - <v>DayNumber = 1..7</v> - </type> + <type variable="Date" name_i="1"/> + <type variable="Year"/> + <type variable="Month"/> + <type variable="Day"/> <desc> - <p>This function computes the day of the week given <c>Year</c>, - <c>Month</c> and <c>Day</c>. The return value denotes the day + <p>This function computes the day of the week given <c><anno>Year</anno></c>, + <c><anno>Month</anno></c> and <c><anno>Day</anno></c>. The return value denotes the day of the week as <c>1</c>: Monday, <c>2</c>: Tuesday, and so on.</p> </desc> </func> <func> - <name>gregorian_days_to_date(Days) -> Date</name> + <name name="gregorian_days_to_date" arity="1"/> <fsummary>Compute the date given the number of gregorian days</fsummary> - <type> - <v>Days = int()</v> - <v>Date = date()</v> - </type> <desc> <p>This function computes the date given the number of gregorian days.</p> </desc> </func> <func> - <name>gregorian_seconds_to_datetime(Seconds) -> {Date, Time}</name> + <name name="gregorian_seconds_to_datetime" arity="1"/> <fsummary>Compute the date given the number of gregorian days</fsummary> - <type> - <v>Seconds = int()</v> - <v>Date = date()</v> - <v>Time = time()</v> - </type> <desc> <p>This function computes the date and time from the given number of gregorian seconds.</p> </desc> </func> <func> - <name>is_leap_year(Year) -> bool()</name> + <name name="is_leap_year" arity="1"/> <fsummary>Check if a year is a leap year</fsummary> <desc> <p>This function checks if a year is a leap year.</p> </desc> </func> <func> - <name>last_day_of_the_month(Year, Month) -> int()</name> + <name name="iso_week_number" arity="0"/> + <fsummary>Compute the iso week number for the actual date</fsummary> + <desc> + <p>This function returns the tuple {Year, WeekNum} representing + the iso week number for the actual date. For determining the + actual date, the function <c>local_time/0</c> is used.</p> + </desc> + </func> + <func> + <name name="iso_week_number" arity="1"/> + <fsummary>Compute the iso week number for the given date</fsummary> + <desc> + <p>This function returns the tuple {Year, WeekNum} representing + the iso week number for the given date.</p> + </desc> + </func> + <func> + <name name="last_day_of_the_month" arity="2"/> <fsummary>Compute the number of days in a month</fsummary> <desc> <p>This function computes the number of days in a month.</p> </desc> </func> <func> - <name>local_time() -> {Date, Time}</name> + <name name="local_time" arity="0"/> <fsummary>Compute local time</fsummary> - <type> - <v>Date = date()</v> - <v>Time = time()</v> - </type> <desc> <p>This function returns the local time reported by the underlying operating system.</p> </desc> </func> <func> - <name>local_time_to_universal_time({Date1, Time1}) -> {Date2, Time2}</name> + <name name="local_time_to_universal_time" arity="1"/> <fsummary>Convert from local time to universal time (deprecated)</fsummary> <desc> <p>This function converts from local time to Universal - Coordinated Time (UTC). <c>Date1</c> must refer to a local + Coordinated Time (UTC). <c><anno>DateTime1</anno></c> must refer to a local date after Jan 1, 1970.</p> <warning> <p>This function is deprecated. Use @@ -190,15 +234,11 @@ time() = {Hour, Minute, Second} </desc> </func> <func> - <name>local_time_to_universal_time_dst({Date1, Time1}) -> [{Date, Time}]</name> + <name name="local_time_to_universal_time_dst" arity="1"/> <fsummary>Convert from local time to universal time(s)</fsummary> - <type> - <v>Date1 = Date = date()</v> - <v>Time1 = Time = time()</v> - </type> <desc> <p>This function converts from local time to Universal - Coordinated Time (UTC). <c>Date1</c> must refer to a local + Coordinated Time (UTC). <c><anno>DateTime1</anno></c> must refer to a local date after Jan 1, 1970.</p> <p>The return value is a list of 0, 1 or 2 possible UTC times:</p> <taglist> @@ -226,65 +266,48 @@ time() = {Hour, Minute, Second} </desc> </func> <func> - <name>now_to_local_time(Now) -> {Date, Time}</name> + <name name="now_to_local_time" arity="1"/> <fsummary>Convert now to local date and time</fsummary> - <type> - <v>Now -- see erlang:now/0</v> - <v>Date = date()</v> - <v>Time = time()</v> - </type> <desc> <p>This function returns local date and time converted from the return value from <c>erlang:now()</c>.</p> </desc> </func> <func> - <name>now_to_universal_time(Now) -> {Date, Time}</name> - <name>now_to_datetime(Now) -> {Date, Time}</name> + <name name="now_to_universal_time" arity="1"/> + <name name="now_to_datetime" arity="1"/> <fsummary>Convert now to date and time</fsummary> - <type> - <v>Now -- see erlang:now/0</v> - <v>Date = date()</v> - <v>Time = time()</v> - </type> <desc> <p>This function returns Universal Coordinated Time (UTC) converted from the return value from <c>erlang:now()</c>.</p> </desc> </func> <func> - <name>seconds_to_daystime(Seconds) -> {Days, Time}</name> + <name name="seconds_to_daystime" arity="1"/> <fsummary>Compute days and time from seconds</fsummary> - <type> - <v>Seconds = Days = int()</v> - <v>Time = time()</v> - </type> <desc> <p>This function transforms a given number of seconds into days, - hours, minutes, and seconds. The <c>Time</c> part is always - non-negative, but <c>Days</c> is negative if the argument - <c>Seconds</c> is.</p> + hours, minutes, and seconds. The <c><anno>Time</anno></c> part is always + non-negative, but <c><anno>Days</anno></c> is negative if the argument + <c><anno>Seconds</anno></c> is.</p> </desc> </func> <func> - <name>seconds_to_time(Seconds) -> Time</name> + <name name="seconds_to_time" arity="1"/> <fsummary>Compute time from seconds</fsummary> - <type> - <v>Seconds = int() < 86400</v> - <v>Time = time()</v> - </type> + <type name="secs_per_day"/> <desc> <p>This function computes the time from the given number of - seconds. <c>Seconds</c> must be less than the number of + seconds. <c><anno>Seconds</anno></c> must be less than the number of seconds per day (86400).</p> </desc> </func> <func> - <name>time_difference(T1, T2) -> {Days, Time}</name> + <name name="time_difference" arity="2"/> <fsummary>Compute the difference between two times (deprecated)</fsummary> <desc> - <p>This function returns the difference between two <c>{Date, Time}</c> tuples. <c>T2</c> should refer to an epoch later - than <c>T1</c>.</p> + <p>This function returns the difference between two <c>{Date, Time}</c> tuples. <c><anno>T2</anno></c> should refer to an epoch later + than <c><anno>T1</anno></c>.</p> <warning> <p>This function is obsolete. Use the conversion functions for gregorian days and seconds instead.</p> @@ -292,24 +315,17 @@ time() = {Hour, Minute, Second} </desc> </func> <func> - <name>time_to_seconds(Time) -> Seconds</name> + <name name="time_to_seconds" arity="1"/> <fsummary>Compute the number of seconds since midnight up to the given time</fsummary> - <type> - <v>Time = time()</v> - <v>Seconds = int()</v> - </type> + <type name="secs_per_day"/> <desc> <p>This function computes the number of seconds since midnight up to the specified time.</p> </desc> </func> <func> - <name>universal_time() -> {Date, Time}</name> + <name name="universal_time" arity="0"/> <fsummary>Compute universal time</fsummary> - <type> - <v>Date = date()</v> - <v>Time = time()</v> - </type> <desc> <p>This function returns the Universal Coordinated Time (UTC) reported by the underlying operating system. Local time is @@ -317,25 +333,22 @@ time() = {Hour, Minute, Second} </desc> </func> <func> - <name>universal_time_to_local_time({Date1, Time1}) -> {Date2, Time2}</name> + <name name="universal_time_to_local_time" arity="1"/> <fsummary>Convert from universal time to local time</fsummary> - <type> - <v>Date1 = Date2 = date()</v> - <v>Time1 = Time2 = time()</v> - </type> <desc> <p>This function converts from Universal Coordinated Time (UTC) - to local time. <c>Date1</c> must refer to a date after Jan 1, + to local time. <c><anno>DateTime</anno></c> must refer to a date after Jan 1, 1970.</p> </desc> </func> <func> - <name>valid_date(Date) -> bool()</name> - <name>valid_date(Year, Month, Day) -> bool()</name> + <name name="valid_date" arity="1"/> + <name name="valid_date" arity="3"/> + <type variable="Date" name_i="1"/> + <type variable="Year"/> + <type variable="Month"/> + <type variable="Day"/> <fsummary>Check if a date is valid</fsummary> - <type> - <v>Date = date()</v> - </type> <desc> <p>This function checks if a date is a valid.</p> </desc> diff --git a/lib/stdlib/doc/src/dets.xml b/lib/stdlib/doc/src/dets.xml index 8d1398d3b7..215ec154ed 100644 --- a/lib/stdlib/doc/src/dets.xml +++ b/lib/stdlib/doc/src/dets.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2009</year> + <year>1996</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -100,50 +100,99 @@ the process with the error tuple). If given badly formed arguments, all functions exit the process with a <c>badarg</c> message.</p> - <p><em>Types</em></p> - <pre> -access() = read | read_write -auto_save() = infinity | int() -bindings_cont() = tuple() -bool() = true | false -file() = string() -int() = integer() >= 0 -keypos() = integer() >= 1 -name() = atom() | ref() -no_slots() = integer() >= 0 | default -object() = tuple() -object_cont() = tuple() -select_cont() = tuple() -type() = bag | duplicate_bag | set -version() = 8 | 9 | default </pre> </description> + <datatypes> + <datatype> + <name name="access"/> + </datatype> + <datatype> + <name name="auto_save"/> + </datatype> + <datatype> + <name name="bindings_cont"/> + <desc> + <p>Opaque continuation used by <seealso marker="#match/1"> + <c>match/1</c></seealso> and <seealso marker="#match/3"> + <c>match/3</c></seealso>.</p> + </desc> + </datatype> + <datatype> + <name name="cont"/> + <desc> + <p>Opaque continuation used by <seealso marker="#bchunk/2"> + <c>bchunk/2</c></seealso>.</p> + </desc> + </datatype> + <datatype> + <name name="keypos"/> + </datatype> + <datatype> + <name name="match_spec"/> + <desc> + <p>Match specifications, see the <seealso + marker="erts:match_spec">match specification</seealso> + documentation in the ERTS User's Guide and <seealso + marker="ms_transform">ms_transform(3).</seealso></p> + </desc> + </datatype> + <datatype> + <name name="no_slots"/> + </datatype> + <datatype> + <name name="object"/> + </datatype> + <datatype> + <name name="object_cont"/> + <desc> + <p>Opaque continuation used by <seealso marker="#match_object/1"> + <c>match_object/1</c></seealso> and <seealso marker="#match_object/3"> + <c>match_object/3</c></seealso>.</p> + </desc> + </datatype> + <datatype> + <name name="pattern"/> + <desc> + <p>See <seealso marker="ets#match/2">ets:match/2</seealso> for a + description of patterns.</p> + </desc> + </datatype> + <datatype> + <name name="select_cont"/> + <desc> + <p>Opaque continuation used by <seealso marker="#select/1"> + <c>select/1</c></seealso> and <seealso marker="#select/3"> + <c>select/3</c></seealso>.</p> + </desc> + </datatype> + <datatype> + <name name="tab_name"/> + </datatype> + <datatype> + <name name="type"/> + </datatype> + <datatype> + <name name="version"/> + </datatype> + </datatypes> <funcs> <func> - <name>all() -> [Name]</name> + <name name="all" arity="0"/> <fsummary>Return a list of the names of all open Dets tables on this node.</fsummary> - <type> - <v>Name = name()</v> - </type> <desc> <p>Returns a list of the names of all open tables on this node.</p> </desc> </func> <func> - <name>bchunk(Name, Continuation) -> {Continuation2, Data} | '$end_of_table' | {error, Reason}</name> + <name name="bchunk" arity="2"/> <fsummary>Return a chunk of objects stored in a Dets table.</fsummary> - <type> - <v>Name = name()</v> - <v>Continuation = start | cont()</v> - <v>Continuation2 = cont()</v> - <v>Data = binary() | tuple()</v> - </type> <desc> <p>Returns a list of objects stored in a table. The exact representation of the returned objects is not public. The lists of data can be used for initializing a table by giving the value <c>bchunk</c> to the <c>format</c> option of the - <c>init_table/3</c> function. The Mnesia application uses this + <seealso marker="#init_table/3"><c>init_table/3</c></seealso> + function. The Mnesia application uses this function for copying open tables.</p> <p>Unless the table is protected using <c>safe_fixtable/2</c>, calls to <c>bchunk/2</c> may not work as expected if @@ -151,24 +200,23 @@ version() = 8 | 9 | default </pre> <p>The first time <c>bchunk/2</c> is called, an initial continuation, the atom <c>start</c>, must be provided.</p> <p>The <c>bchunk/2</c> function returns a tuple - <c>{Continuation2, Data}</c>, where <c>Data</c> is a list of - objects. <c>Continuation2</c> is another continuation which is + <c>{<anno>Continuation2</anno>, <anno>Data</anno>}</c>, + where <c><anno>Data</anno></c> is a list of + objects. <c><anno>Continuation2</anno></c> is another continuation + which is to be passed on to a subsequent call to <c>bchunk/2</c>. With a series of calls to <c>bchunk/2</c> it is possible to extract all objects of the table. </p> <p><c>bchunk/2</c> returns <c>'$end_of_table'</c> when all - objects have been returned, or <c>{error, Reason}</c> if an - error occurs. + objects have been returned, or <c>{error, <anno>Reason</anno>}</c> + if an error occurs. </p> </desc> </func> <func> - <name>close(Name) -> ok | {error, Reason} </name> + <name name="close" arity="1"/> <fsummary>Close a Dets table.</fsummary> - <type> - <v>Name = name()</v> - </type> <desc> <p>Closes a table. Only processes that have opened a table are allowed to close it. @@ -180,22 +228,16 @@ version() = 8 | 9 | default </pre> </desc> </func> <func> - <name>delete(Name, Key) -> ok | {error, Reason}</name> + <name name="delete" arity="2"/> <fsummary>Delete all objects with a given key from a Dets table.</fsummary> - <type> - <v>Name = name()</v> - </type> <desc> - <p>Deletes all objects with the key <c>Key</c> from the table - <c>Name</c>.</p> + <p>Deletes all objects with the key <c><anno>Key</anno></c> from + the table <c><anno>Name</anno></c>.</p> </desc> </func> <func> - <name>delete_all_objects(Name) -> ok | {error, Reason}</name> + <name name="delete_all_objects" arity="1"/> <fsummary>Delete all objects from a Dets table.</fsummary> - <type> - <v>Name = name()</v> - </type> <desc> <p>Deletes all objects from a table in almost constant time. However, if the table if fixed, <c>delete_all_objects(T)</c> @@ -203,12 +245,8 @@ version() = 8 | 9 | default </pre> </desc> </func> <func> - <name>delete_object(Name, Object) -> ok | {error, Reason}</name> + <name name="delete_object" arity="2"/> <fsummary>Delete a given object from a Dets table.</fsummary> - <type> - <v>Name = name()</v> - <v>Object = object()</v> - </type> <desc> <p>Deletes all instances of a given object from a table. If a table is of type <c>bag</c> or <c>duplicate_bag</c>, the @@ -218,18 +256,15 @@ version() = 8 | 9 | default </pre> </desc> </func> <func> - <name>first(Name) -> Key | '$end_of_table'</name> + <name name="first" arity="1"/> <fsummary>Return the first key stored in a Dets table.</fsummary> - <type> - <v>Key = term()</v> - <v>Name = name()</v> - </type> <desc> - <p>Returns the first key stored in the table <c>Name</c> + <p>Returns the first key stored in the table <c><anno>Name</anno></c> according to the table's internal order, or <c>'$end_of_table'</c> if the table is empty.</p> <p>Unless the table is protected using <c>safe_fixtable/2</c>, - subsequent calls to <c>next/2</c> may not work as expected if + subsequent calls to <seealso marker="#next/2"><c>next/2</c></seealso> + may not work as expected if concurrent updates are made to the table.</p> <p>Should an error occur, the process is exited with an error tuple <c>{error, Reason}</c>. The reason for not returning the @@ -243,107 +278,78 @@ version() = 8 | 9 | default </pre> </desc> </func> <func> - <name>foldl(Function, Acc0, Name) -> Acc1 | {error, Reason}</name> - <fsummary>Fold a function over a Dets table.</fsummary> - <type> - <v>Function = fun(Object, AccIn) -> AccOut</v> - <v>Acc0 = Acc1 = AccIn = AccOut = term()</v> - <v>Name = name()</v> - <v>Object = object()</v> - </type> - <desc> - <p>Calls <c>Function</c> on successive elements of the table - <c>Name</c> together with an extra argument <c>AccIn</c>. The - order in which the elements of the table are traversed is - unspecified. <c>Function</c> must return a new accumulator - which is passed to the next call. <c>Acc0</c> is returned if - the table is empty.</p> - </desc> - </func> - <func> - <name>foldr(Function, Acc0, Name) -> Acc1 | {error, Reason}</name> + <name name="foldl" arity="3"/> + <name name="foldr" arity="3"/> <fsummary>Fold a function over a Dets table.</fsummary> - <type> - <v>Function = fun(Object, AccIn) -> AccOut</v> - <v>Acc0 = Acc1 = AccIn = AccOut = term()</v> - <v>Name = name()</v> - <v>Object = object()</v> - </type> <desc> - <p>Calls <c>Function</c> on successive elements of the table - <c>Name</c> together with an extra argument <c>AccIn</c>. The + <p>Calls <c><anno>Function</anno></c> on successive elements of + the table <c><anno>Name</anno></c> together with an extra argument + <c>AccIn</c>. The order in which the elements of the table are traversed is - unspecified. <c>Function</c> must return a new accumulator - which is passed to the next call. <c>Acc0</c> is returned if + unspecified. <c><anno>Function</anno></c> must return a new + accumulator which is passed to the next call. + <c><anno>Acc0</anno></c> is returned if the table is empty.</p> </desc> </func> <func> - <name>from_ets(Name, EtsTab) -> ok | {error, Reason}</name> + <name name="from_ets" arity="2"/> <fsummary>Replace the objects of a Dets table with the objects of an Ets table.</fsummary> - <type> - <v>Name = name()</v> - <v>EtsTab = - see ets(3) -</v> - </type> <desc> - <p>Deletes all objects of the table <c>Name</c> and then - inserts all the objects of the Ets table <c>EtsTab</c>. The - order in which the objects are inserted is not specified. + <p>Deletes all objects of the table <c><anno>Name</anno></c> and then + inserts all the objects of the Ets table <c><anno>EtsTab</anno></c>. + The order in which the objects are inserted is not specified. Since <c>ets:safe_fixtable/2</c> is called the Ets table must be public or owned by the calling process.</p> </desc> </func> <func> - <name>info(Name) -> InfoList | undefined</name> + <name name="info" arity="1"/> <fsummary>Return information about a Dets table.</fsummary> - <type> - <v>Name = name()</v> - <v>InfoList = [{Item, Value}]</v> - </type> <desc> - <p>Returns information about the table <c>Name</c> as a list of - <c>{Item, Value}</c> tuples:</p> + <p>Returns information about the table <c><anno>Name</anno></c> + as a list of tuples:</p> <list type="bulleted"> <item> - <p><c>{file_size, int()}</c>, the size of the file in + <p><c>{file_size, integer() >= 0}</c>, the size of the file in bytes.</p> </item> <item> - <p><c>{filename, file()}</c>, the name of the file - where objects are stored.</p> + <p><c>{filename, <seealso marker="file#type-name">file:name()</seealso>}</c>, + the name of the file where objects are stored.</p> </item> <item> - <p><c>{keypos, keypos()}</c>, the position of the - key.</p> + <p><c>{keypos, <seealso marker="#type-keypos">keypos()</seealso>} + </c>, the position of the key.</p> </item> <item> - <p><c>{size, int()}</c>, the number of objects stored + <p><c>{size, integer() >= 0}</c>, the number of objects stored in the table.</p> </item> <item> - <p><c>{type, type()}</c>, the type of the table.</p> + <p><c>{type, <seealso marker="#type-type">type()</seealso>}</c>, + the type of the table.</p> </item> </list> </desc> </func> <func> - <name>info(Name, Item) -> Value | undefined</name> + <name name="info" arity="2"/> <fsummary>Return the information associated with a given item for a Dets table.</fsummary> - <type> - <v>Name = name()</v> - </type> <desc> - <p>Returns the information associated with <c>Item</c> for the - table <c>Name</c>. In addition to the <c>{Item, Value}</c> + <p>Returns the information associated with <c><anno>Item</anno></c> + for the table <c><anno>Name</anno></c>. + In addition to the <c>{<anno>Item</anno>, <anno>Value</anno>}</c> pairs defined for <c>info/1</c>, the following items are allowed:</p> <list type="bulleted"> <item> - <p><c>{access, access()}</c>, the access mode.</p> + <p><c>{access, <seealso marker="#type-access">access()</seealso>} + </c>, the access mode.</p> </item> <item> - <p><c>{auto_save, auto_save()}</c>, the auto save - interval.</p> + <p><c>{auto_save, <seealso marker="#type-auto_save"> + auto_save()</seealso>}</c>, the auto save interval.</p> </item> <item> <p><c>{bchunk_format, binary()}</c>, an opaque binary @@ -362,21 +368,22 @@ version() = 8 | 9 | default </pre> <c>erlang:phash2/1</c> BIF is used.</p> </item> <item> - <p><c>{memory, int()}</c>, the size of the file in + <p><c>{memory, integer() >= 0}</c>, the size of the file in bytes. The same value is associated with the item <c>file_size</c>.</p> </item> <item> - <p><c>{no_keys, int()}</c>, the number of different + <p><c>{no_keys, integer >= 0()}</c>, the number of different keys stored in the table. Only available for version 9 tables.</p> </item> <item> - <p><c>{no_objects, int()}</c>, the number of objects + <p><c>{no_objects, integer >= 0()}</c>, the number of objects stored in the table.</p> </item> <item> - <p><c>{no_slots, {Min, Used, Max}}</c>, the number of + <p><c>{no_slots, {</c>Min<c>, </c>Used<c>, </c>Max<c>}}</c>, + the number of slots of the table. <c>Min</c> is the minimum number of slots, <c>Used</c> is the number of currently used slots, and <c>Max</c> is the maximum number of slots. Only @@ -387,7 +394,7 @@ version() = 8 | 9 | default </pre> handles requests to the Dets table.</p> </item> <item> - <p><c>{ram_file, bool()}</c>, whether the table is + <p><c>{ram_file, boolean()}</c>, whether the table is kept in RAM.</p> </item> <item> @@ -399,32 +406,28 @@ version() = 8 | 9 | default </pre> table is not fixed, SafeFixed is the atom <c>false</c>.</p> </item> <item> - <p><c>{version, int()}</c>, the version of the format - of the table.</p> + <p><c>{version, integer()</c>, the version of the format of + the table.</p> </item> </list> </desc> </func> <func> - <name>init_table(Name, InitFun [, Options]) -> ok | {error, Reason}</name> + <name name="init_table" arity="2"/> + <name name="init_table" arity="3"/> <fsummary>Replace all objects of a Dets table.</fsummary> - <type> - <v>Name = atom()</v> - <v>InitFun = fun(Arg) -> Res</v> - <v>Arg = read | close</v> - <v>Res = end_of_input | {[object()], InitFun} | {Data, InitFun} | term()</v> - <v>Data = binary() | tuple()</v> - </type> <desc> - <p>Replaces the existing objects of the table <c>Name</c> with - objects created by calling the input function <c>InitFun</c>, + <p>Replaces the existing objects of the table <c><anno>Name</anno></c> + with objects created by calling the input function + <c><anno>InitFun</anno></c>, see below. The reason for using this function rather than calling <c>insert/2</c> is that of efficiency. It should be noted that the input functions are called by the process that handles requests to the Dets table, not by the calling process.</p> <p>When called with the argument <c>read</c> the function - <c>InitFun</c> is assumed to return <c>end_of_input</c> when + <c><anno>InitFun</anno></c> is assumed to return + <c>end_of_input</c> when there is no more input, or <c>{Objects, Fun}</c>, where <c>Objects</c> is a list of objects and <c>Fun</c> is a new input function. Any other value Value is returned as an error @@ -448,7 +451,8 @@ version() = 8 | 9 | default </pre> item <c>no_slots</c>. See also the <c>min_no_slots</c> option below. </p> - <p>The <c>Options</c> argument is a list of <c>{Key, Val}</c> + <p>The <c><anno>Options</anno></c> argument is a list of + <c>{Key, Val}</c> tuples where the following values are allowed:</p> <list type="bulleted"> <item> @@ -461,87 +465,68 @@ version() = 8 | 9 | default </pre> </item> <item> <p><c>{format, Format}</c>. Specifies the format of the - objects returned by the function <c>InitFun</c>. If + objects returned by the function <c><anno>InitFun</anno></c>. If <c>Format</c> is <c>term</c> (the default), - <c>InitFun</c> is assumed to return a list of tuples. If - <c>Format</c> is <c>bchunk</c>, <c>InitFun</c> is - assumed to return <c>Data</c> as returned by - <c>bchunk/2</c>. This option overrides the + <c><anno>InitFun</anno></c> is assumed to return a list of tuples. If + <c>Format</c> is <c>bchunk</c>, <c><anno>InitFun</anno></c> is + assumed to return <c><anno>Data</anno></c> as returned by + <seealso marker="#bchunk/2"><c>bchunk/2</c></seealso>. + This option overrides the <c>min_no_slots</c> option.</p> </item> </list> </desc> </func> <func> - <name>insert(Name, Objects) -> ok | {error, Reason}</name> + <name name="insert" arity="2"/> <fsummary>Insert one or more objects into a Dets table.</fsummary> - <type> - <v>Name = name()</v> - <v>Objects = object() | [object()]</v> - </type> <desc> - <p>Inserts one or more objects into the table <c>Name</c>. If - there already exists an object with a key matching the key of + <p>Inserts one or more objects into the table <c><anno>Name</anno></c>. + If there already exists an object with a key matching the key of some of the given objects and the table type is <c>set</c>, the old object will be replaced.</p> </desc> </func> <func> - <name>insert_new(Name, Objects) -> Bool</name> + <name name="insert_new" arity="2"/> <fsummary>Insert one or more objects into a Dets table.</fsummary> - <type> - <v>Name = name()</v> - <v>Objects = object() | [object()]</v> - <v>Bool = bool()</v> - </type> <desc> - <p>Inserts one or more objects into the table <c>Name</c>. If - there already exists some object with a key matching the key + <p>Inserts one or more objects into the table <c><anno>Name</anno></c>. + If there already exists some object with a key matching the key of any of the given objects the table is not updated and <c>false</c> is returned, otherwise the objects are inserted and <c>true</c> returned.</p> </desc> </func> <func> - <name>is_compatible_bchunk_format(Name, BchunkFormat) -> Bool</name> + <name name="is_compatible_bchunk_format" arity="2"/> <fsummary>Test compatibility of a table's chunk data.</fsummary> - <type> - <v>Name = name()</v> - <v>BchunkFormat = binary()</v> - <v>Bool = bool()</v> - </type> <desc> <p>Returns <c>true</c> if it would be possible to initialize - the table <c>Name</c>, using <c>init_table/3</c> with the + the table <c><anno>Name</anno></c>, using + <seealso marker="#init_table/3"><c>init_table/3</c></seealso> + with the option <c>{format, bchunk}</c>, with objects read with - <c>bchunk/2</c> from some table <c>T</c> such that calling + <seealso marker="#bchunk/2"><c>bchunk/2</c></seealso> from some + table <c>T</c> such that calling <c>info(T, bchunk_format)</c> returns <c>BchunkFormat</c>.</p> </desc> </func> <func> - <name>is_dets_file(FileName) -> Bool | {error, Reason}</name> + <name name="is_dets_file" arity="1"/> <fsummary>Test for a Dets table.</fsummary> - <type> - <v>FileName = file()</v> - <v>Bool = bool()</v> - </type> <desc> - <p>Returns <c>true</c> if the file <c>FileName</c> is a Dets - table, <c>false</c> otherwise.</p> + <p>Returns <c>true</c> if the file <c><anno>Filename</anno></c> + is a Dets table, <c>false</c> otherwise.</p> </desc> </func> <func> - <name>lookup(Name, Key) -> [Object] | {error, Reason}</name> + <name name="lookup" arity="2"/> <fsummary>Return all objects with a given key stored in a Dets table.</fsummary> - <type> - <v>Key = term()</v> - <v>Name = name()</v> - <v>Object = object()</v> - </type> <desc> - <p>Returns a list of all objects with the key <c>Key</c> - stored in the table <c>Name</c>. For example:</p> + <p>Returns a list of all objects with the key <c><anno>Key</anno></c> + stored in the table <c><anno>Name</anno></c>. For example:</p> <pre> 2> <input>dets:open_file(abc, [{type, bag}]).</input> {ok,abc} @@ -562,71 +547,57 @@ ok </desc> </func> <func> - <name>match(Continuation) -> {[Match], Continuation2} | '$end_of_table' | {error, Reason}</name> + <name name="match" arity="1"/> <fsummary>Match a chunk of objects stored in a Dets table and return a list of variable bindings.</fsummary> - <type> - <v>Continuation = Continuation2 = bindings_cont()</v> - <v>Match = [term()]</v> - </type> <desc> <p>Matches some objects stored in a table and returns a non-empty list of the bindings that match a given pattern in some unspecified order. The table, the pattern, and the number of objects that are matched are all defined by - <c>Continuation</c>, which has been returned by a prior call - to <c>match/1</c> or <c>match/3</c>.</p> + <c><anno>Continuation</anno></c>, which has been returned by a prior + call to <c>match/1</c> or <c>match/3</c>.</p> <p>When all objects of the table have been matched, <c>'$end_of_table'</c> is returned.</p> </desc> </func> <func> - <name>match(Name, Pattern) -> [Match] | {error, Reason}</name> + <name name="match" arity="2"/> <fsummary>Match the objects stored in a Dets table and return a list of variable bindings.</fsummary> - <type> - <v>Name = name()</v> - <v>Pattern = tuple()</v> - <v>Match = [term()]</v> - </type> <desc> - <p>Returns for each object of the table <c>Name</c> that - matches <c>Pattern</c> a list of bindings in some unspecified - order. See <seealso marker="ets">ets(3)</seealso> for a + <p>Returns for each object of the table <c><anno>Name</anno></c> that + matches <c><anno>Pattern</anno></c> a list of bindings in some unspecified + order. See <seealso marker="ets#match/2">ets:match/2</seealso> for a description of patterns. If the keypos'th element of - <c>Pattern</c> is unbound, all objects of the table are + <c><anno>Pattern</anno></c> is unbound, all objects of the table are matched. If the keypos'th element is bound, only the objects with the right key are matched.</p> </desc> </func> <func> - <name>match(Name, Pattern, N) -> {[Match], Continuation} | '$end_of_table' | {error, Reason}</name> + <name name="match" arity="3"/> <fsummary>Match the first chunk of objects stored in a Dets table and return a list of variable bindings.</fsummary> - <type> - <v>Name = name()</v> - <v>Pattern = tuple()</v> - <v>N = default | int()</v> - <v>Match = [term()]</v> - <v>Continuation = bindings_cont()</v> - </type> <desc> - <p>Matches some or all objects of the table <c>Name</c> and + <p>Matches some or all objects of the table <c><anno>Name</anno></c> and returns a non-empty list of the bindings that match - <c>Pattern</c> in some unspecified order. See <seealso marker="ets">ets(3)</seealso> for a description of - patterns.</p> + <c><anno>Pattern</anno></c> in some unspecified order. + See <seealso marker="ets#match/2">ets:match/2</seealso> for a + description of patterns.</p> <p>A tuple of the bindings and a continuation is returned, unless the table is empty, in which case <c>'$end_of_table'</c> is returned. The continuation is to be used when matching further objects by calling - <c>match/1</c>.</p> - <p>If the keypos'th element of <c>Pattern</c> is bound, all - objects of the table are matched. If the keypos'th element is - unbound, all objects of the table are matched, <c>N</c> + <seealso marker="#match/1"><c>match/1</c></seealso>.</p> + <p>If the keypos'th element of <c><anno>Pattern</anno></c> is bound, + all objects of the table are matched. If the keypos'th element is + unbound, all objects of the table are matched, <c><anno>N</anno></c> objects at a time, until at least one object matches or the end of the table has been reached. The default, indicated by - giving <c>N</c> the value <c>default</c>, is to let the number + giving <c><anno>N</anno></c> the value <c>default</c>, + is to let the number of objects vary depending on the sizes of the objects. If - <c>Name</c> is a version 9 table, all objects with the same + <c><anno>Name</anno></c> is a version 9 table, all objects with the same key are always matched at the same time which implies that - more than N objects may sometimes be matched. + more than <anno>N</anno> objects may sometimes be matched. </p> <p>The table should always be protected using <c>safe_fixtable/2</c> before calling <c>match/3</c>, or @@ -634,15 +605,11 @@ ok </desc> </func> <func> - <name>match_delete(Name, Pattern) -> ok | {error, Reason}</name> + <name name="match_delete" arity="2"/> <fsummary>Delete all objects that match a given pattern from a Dets table.</fsummary> - <type> - <v>Name = name()</v> - <v>Pattern = tuple()</v> - </type> <desc> - <p>Deletes all objects that match <c>Pattern</c> from the - table <c>Name</c>. + <p>Deletes all objects that match <c><anno>Pattern</anno></c> from the + table <c><anno>Name</anno></c>. See <seealso marker="ets#match/2">ets:match/2</seealso> for a description of patterns.</p> <p>If the keypos'th element of <c>Pattern</c> is bound, @@ -650,17 +617,13 @@ ok </desc> </func> <func> - <name>match_object(Continuation) -> {[Object], Continuation2} | '$end_of_table' | {error, Reason}</name> + <name name="match_object" arity="1"/> <fsummary>Match a chunk of objects stored in a Dets table and return a list of objects.</fsummary> - <type> - <v>Continuation = Continuation2 = object_cont()</v> - <v>Object = object()</v> - </type> <desc> <p>Returns a non-empty list of some objects stored in a table that match a given pattern in some unspecified order. The table, the pattern, and the number of objects that are matched - are all defined by <c>Continuation</c>, which has been + are all defined by <c><anno>Continuation</anno></c>, which has been returned by a prior call to <c>match_object/1</c> or <c>match_object/3</c>.</p> <p>When all objects of the table have been matched, @@ -668,20 +631,17 @@ ok </desc> </func> <func> - <name>match_object(Name, Pattern) -> [Object] | {error, Reason}</name> + <name name="match_object" arity="2"/> <fsummary>Match the objects stored in a Dets table and return a list of objects.</fsummary> - <type> - <v>Name = name()</v> - <v>Pattern = tuple()</v> - <v>Object = object()</v> - </type> <desc> - <p>Returns a list of all objects of the table <c>Name</c> that - match <c>Pattern</c> in some unspecified order. See <seealso marker="ets">ets(3)</seealso> for a description of patterns. + <p>Returns a list of all objects of the table <c><anno>Name</anno></c> that + match <c><anno>Pattern</anno></c> in some unspecified order. + See <seealso marker="ets#match/2">ets:match/2</seealso> for a + description of patterns. </p> - <p>If the keypos'th element of <c>Pattern</c> is + <p>If the keypos'th element of <c><anno>Pattern</anno></c> is unbound, all objects of the table are matched. If the - keypos'th element of <c>Pattern</c> is bound, only the + keypos'th element of <c><anno>Pattern</anno></c> is bound, only the objects with the right key are matched.</p> <p>Using the <c>match_object</c> functions for traversing all objects of a table is more efficient than calling @@ -689,34 +649,28 @@ ok </desc> </func> <func> - <name>match_object(Name, Pattern, N) -> {[Object], Continuation} | '$end_of_table' | {error, Reason}</name> + <name name="match_object" arity="3"/> <fsummary>Match the first chunk of objects stored in a Dets table and return a list of objects.</fsummary> - <type> - <v>Name = name()</v> - <v>Pattern = tuple()</v> - <v>N = default | int()</v> - <v>Object = object()</v> - <v>Continuation = object_cont()</v> - </type> <desc> - <p>Matches some or all objects stored in the table <c>Name</c> + <p>Matches some or all objects stored in the table <c><anno>Name</anno></c> and returns a non-empty list of the objects that match - <c>Pattern</c> in some unspecified order. See <seealso marker="ets">ets(3)</seealso> for a description of - patterns.</p> + <c><anno>Pattern</anno></c> in some unspecified order. + See <seealso marker="ets#match/2">ets:match/2</seealso> for a + description of patterns.</p> <p>A list of objects and a continuation is returned, unless the table is empty, in which case <c>'$end_of_table'</c> is returned. The continuation is to be used when matching further objects by calling <c>match_object/1</c>.</p> - <p>If the keypos'th element of <c>Pattern</c> is bound, all + <p>If the keypos'th element of <c><anno>Pattern</anno></c> is bound, all objects of the table are matched. If the keypos'th element is - unbound, all objects of the table are matched, <c>N</c> + unbound, all objects of the table are matched, <c><anno>N</anno></c> objects at a time, until at least one object matches or the end of the table has been reached. The default, indicated by - giving <c>N</c> the value <c>default</c>, is to let the number + giving <c><anno>N</anno></c> the value <c>default</c>, is to let the number of objects vary depending on the sizes of the objects. If - <c>Name</c> is a version 9 table, all matching objects with + <c><anno>Name</anno></c> is a version 9 table, all matching objects with the same key are always returned in the same reply which - implies that more than N objects may sometimes be returned. + implies that more than <anno>N</anno> objects may sometimes be returned. </p> <p>The table should always be protected using <c>safe_fixtable/2</c> before calling <c>match_object/3</c>, @@ -724,43 +678,31 @@ ok </desc> </func> <func> - <name>member(Name, Key) -> Bool | {error, Reason}</name> + <name name="member" arity="2"/> <fsummary>Test for occurrence of a key in a Dets table.</fsummary> - <type> - <v>Name = name()</v> - <v>Key = term()</v> - <v>Bool = bool()</v> - </type> <desc> <p>Works like <c>lookup/2</c>, but does not return the objects. The function returns <c>true</c> if one or more - elements of the table has the key <c>Key</c>, <c>false</c> + elements of the table has the key <c><anno>Key</anno></c>, <c>false</c> otherwise.</p> </desc> </func> <func> - <name>next(Name, Key1) -> Key2 | '$end_of_table'</name> + <name name="next" arity="2"/> <fsummary>Return the next key in a Dets table.</fsummary> - <type> - <v>Name = name()</v> - <v>Key1 = Key2 = term()</v> - </type> <desc> - <p>Returns the key following <c>Key1</c> in the table - <c>Name</c> according to the table's internal order, or + <p>Returns the key following <c><anno>Key1</anno></c> in the table + <c><anno>Name</anno></c> according to the table's internal order, or <c>'$end_of_table'</c> if there is no next key.</p> <p>Should an error occur, the process is exited with an error tuple <c>{error, Reason}</c>.</p> - <p>Use <c>first/1</c> to find the first key in the table.</p> + <p>Use <seealso marker="#first/1"><c>first/1</c></seealso> to find + the first key in the table.</p> </desc> </func> <func> - <name>open_file(Filename) -> {ok, Reference} | {error, Reason}</name> + <name name="open_file" arity="1"/> <fsummary>Open an existing Dets table.</fsummary> - <type> - <v>FileName = file()</v> - <v>Reference = ref()</v> - </type> <desc> <p>Opens an existing table. If the table has not been properly closed, it will be repaired. The returned reference is to be @@ -769,15 +711,12 @@ ok </desc> </func> <func> - <name>open_file(Name, Args) -> {ok, Name} | {error, Reason}</name> + <name name="open_file" arity="2"/> <fsummary>Open a Dets table.</fsummary> - <type> - <v>Name = atom()</v> - </type> <desc> <p>Opens a table. An empty Dets table is created if no file exists.</p> - <p>The atom <c>Name</c> is the name of the table. The table + <p>The atom <c><anno>Name</anno></c> is the name of the table. The table name must be provided in all subsequent operations on the table. The name can be used by other processes as well, and several process can share one table. @@ -786,18 +725,20 @@ ok name and arguments, then the table will have two users. If one user closes the table, it still remains open until the second user closes the table.</p> - <p>The <c>Args</c> argument is a list of <c>{Key, Val}</c> + <p>The <c><anno>Args</anno></c> argument is a list of <c>{Key, Val}</c> tuples where the following values are allowed:</p> <list type="bulleted"> <item> - <p><c>{access, access()}</c>. It is possible to open + <p><c>{access, <seealso marker="#type-access"> + access()</seealso>}</c>. It is possible to open existing tables in read-only mode. A table which is opened in read-only mode is not subjected to the automatic file reparation algorithm if it is later opened after a crash. The default value is <c>read_write</c>.</p> </item> <item> - <p><c>{auto_save, auto_save()}</c>, the auto save + <p><c>{auto_save, <seealso marker="#type-auto_save"> + auto_save()</seealso>}</c>, the auto save interval. If the interval is an integer <c>Time</c>, the table is flushed to disk whenever it is not accessed for <c>Time</c> milliseconds. A table that has been flushed @@ -807,16 +748,19 @@ ok is 180000 (3 minutes).</p> </item> <item> - <p><c>{estimated_no_objects, int()}</c>. Equivalent to the + <p><c>{estimated_no_objects, <seealso marker="#type-no_slots"> + no_slots()</seealso>}</c>. Equivalent to the <c>min_no_slots</c> option.</p> </item> <item> - <p><c>{file, file()}</c>, the name of the file to be + <p><c>{file, <seealso marker="file#type-name"> + file:name()</seealso>}</c>, the name of the file to be opened. The default value is the name of the table.</p> </item> <item> - <p><c>{max_no_slots, no_slots()}</c>, the maximum number - of slots that will be used. The default value is 2 M, and + <p><c>{max_no_slots, <seealso marker="#type-no_slots"> + no_slots()</seealso>}</c>, the maximum number + of slots that will be used. The default value as well as the maximal value is 32 M. Note that a higher value may increase the fragmentation of the table, and conversely, that a smaller value may decrease the fragmentation, at @@ -824,14 +768,16 @@ ok 9 tables.</p> </item> <item> - <p><c>{min_no_slots, no_slots()}</c>. Application + <p><c>{min_no_slots, <seealso marker="#type-no_slots"> + no_slots()</seealso>}</c>. Application performance can be enhanced with this flag by specifying, when the table is created, the estimated number of different keys that will be stored in the table. The default value as well as the minimum value is 256.</p> </item> <item> - <p><c>{keypos, keypos()}</c>, the position of the + <p><c>{keypos, <seealso marker="#type-keypos"> + keypos()</seealso>}</c>, the position of the element of each object to be used as key. The default value is 1. The ability to explicitly state the key position is most convenient when we want to store Erlang @@ -839,7 +785,7 @@ ok name of the record type.</p> </item> <item> - <p><c>{ram_file, bool()}</c>, whether the table is to + <p><c>{ram_file, boolean()}</c>, whether the table is to be kept in RAM. Keeping the table in RAM may sound like an anomaly, but can enhance the performance of applications which open a table, insert a set of objects, and then @@ -849,7 +795,7 @@ ok </item> <item> <p><c>{repair, Value}</c>. <c>Value</c> can be either - a <c>bool()</c> or the atom <c>force</c>. The flag + a <c>boolean()</c> or the atom <c>force</c>. The flag specifies whether the Dets server should invoke the automatic file reparation algorithm. The default is <c>true</c>. If <c>false</c> is specified, there is no @@ -868,11 +814,12 @@ ok already open.</p> </item> <item> - <p><c>{type, type()}</c>, the type of the table. The - default value is <c>set</c>.</p> + <p><c>{type, <seealso marker="#type-type">type()</seealso>}</c>, + the type of the table. The default value is <c>set</c>.</p> </item> <item> - <p><c>{version, version()}</c>, the version of the format + <p><c>{version, <seealso marker="#type-version"> + version()</seealso>}</c>, the version of the format used for the table. The default value is <c>9</c>. Tables on the format used before OTP R8 can be created by giving the value <c>8</c>. A version 8 table can be converted to @@ -883,12 +830,8 @@ ok </desc> </func> <func> - <name>pid2name(Pid) -> {ok, Name} | undefined</name> + <name name="pid2name" arity="1"/> <fsummary>Return the name of the Dets table handled by a pid.</fsummary> - <type> - <v>Name = name()</v> - <v>Pid = pid()</v> - </type> <desc> <p>Returns the name of the table given the pid of a process that handles requests to a table, or <c>undefined</c> if @@ -897,12 +840,8 @@ ok </desc> </func> <func> - <name>repair_continuation(Continuation, MatchSpec) -> Continuation2</name> + <name name="repair_continuation" arity="2"/> <fsummary>Repair a continuation from select/1 or select/3.</fsummary> - <type> - <v>Continuation = Continuation2 = select_cont()</v> - <v>MatchSpec = match_spec()</v> - </type> <desc> <p>This function can be used to restore an opaque continuation returned by <c>select/3</c> or <c>select/1</c> if the @@ -932,14 +871,11 @@ ok </desc> </func> <func> - <name>safe_fixtable(Name, Fix)</name> + <name name="safe_fixtable" arity="2"/> <fsummary>Fix a Dets table for safe traversal.</fsummary> - <type> - <v>Name = name()</v> - <v>Fix = bool()</v> - </type> <desc> - <p>If <c>Fix</c> is <c>true</c>, the table <c>Name</c> is + <p>If <c><anno>Fix</anno></c> is <c>true</c>, the table + <c><anno>Name</anno></c> is fixed (once more) by the calling process, otherwise the table is released. The table is also released when a fixing process terminates. @@ -961,17 +897,13 @@ ok </desc> </func> <func> - <name>select(Continuation) -> {Selection, Continuation2} | '$end_of_table' | {error, Reason}</name> + <name name="select" arity="1"/> <fsummary>Apply a match specification to some objects stored in a Dets table.</fsummary> - <type> - <v>Continuation = Continuation2 = select_cont()</v> - <v>Selection = [term()]</v> - </type> <desc> <p>Applies a match specification to some objects stored in a table and returns a non-empty list of the results. The table, the match specification, and the number of objects - that are matched are all defined by <c>Continuation</c>, + that are matched are all defined by <c><anno>Continuation</anno></c>, which has been returned by a prior call to <c>select/1</c> or <c>select/3</c>.</p> <p>When all objects of the table have been matched, @@ -979,20 +911,15 @@ ok </desc> </func> <func> - <name>select(Name, MatchSpec) -> Selection | {error, Reason}</name> + <name name="select" arity="2"/> <fsummary>Apply a match specification to all objects stored in a Dets table.</fsummary> - <type> - <v>Name = name()</v> - <v>MatchSpec = match_spec()</v> - <v>Selection = [term()]</v> - </type> <desc> <p>Returns the results of applying the match specification - <c>MatchSpec</c> to all or some objects stored in the table - <c>Name</c>. The order of the objects is not specified. See + <c><anno>MatchSpec</anno></c> to all or some objects stored in the table + <c><anno>Name</anno></c>. The order of the objects is not specified. See the ERTS User's Guide for a description of match specifications.</p> - <p>If the keypos'th element of <c>MatchSpec</c> is + <p>If the keypos'th element of <c><anno>MatchSpec</anno></c> is unbound, the match specification is applied to all objects of the table. If the keypos'th element is bound, the match specification is applied to the objects with the right key(s) @@ -1004,19 +931,12 @@ ok </desc> </func> <func> - <name>select(Name, MatchSpec, N) -> {Selection, Continuation} | '$end_of_table' | {error, Reason}</name> + <name name="select" arity="3"/> <fsummary>Apply a match specification to the first chunk of objects stored in a Dets table.</fsummary> - <type> - <v>Name = name()</v> - <v>MatchSpec = match_spec()</v> - <v>N = default | int()</v> - <v>Selection = [term()]</v> - <v>Continuation = select_cont()</v> - </type> <desc> <p>Returns the results of applying the match specification - <c>MatchSpec</c> to some or all objects stored in the table - <c>Name</c>. The order of the objects is not specified. See + <c><anno>MatchSpec</anno></c> to some or all objects stored in the table + <c><anno>Name</anno></c>. The order of the objects is not specified. See the ERTS User's Guide for a description of match specifications.</p> <p>A tuple of the results of applying the match specification @@ -1024,18 +944,18 @@ ok in which case <c>'$end_of_table'</c> is returned. The continuation is to be used when matching further objects by calling <c>select/1</c>.</p> - <p>If the keypos'th element of <c>MatchSpec</c> is bound, the + <p>If the keypos'th element of <c><anno>MatchSpec</anno></c> is bound, the match specification is applied to all objects of the table with the right key(s). If the keypos'th element of - <c>MatchSpec</c> is unbound, the match specification is - applied to all objects of the table, <c>N</c> objects at a + <c><anno>MatchSpec</anno></c> is unbound, the match specification is + applied to all objects of the table, <c><anno>N</anno></c> objects at a time, until at least one object matches or the end of the table has been reached. The default, indicated by giving - <c>N</c> the value <c>default</c>, is to let the number of + <c><anno>N</anno></c> the value <c>default</c>, is to let the number of objects vary depending on the sizes of the objects. If - <c>Name</c> is a version 9 table, all objects with the same + <c><anno>Name</anno></c> is a version 9 table, all objects with the same key are always handled at the same time which implies that the - match specification may be applied to more than N objects. + match specification may be applied to more than <anno>N</anno> objects. </p> <p>The table should always be protected using <c>safe_fixtable/2</c> before calling <c>select/3</c>, or @@ -1043,48 +963,35 @@ ok </desc> </func> <func> - <name>select_delete(Name, MatchSpec) -> N | {error, Reason}</name> + <name name="select_delete" arity="2"/> <fsummary>Delete all objects that match a given pattern from a Dets table.</fsummary> - <type> - <v>Name = name()</v> - <v>MatchSpec = match_spec()</v> - <v>N = int()</v> - </type> <desc> - <p>Deletes each object from the table <c>Name</c> such that - applying the match specification <c>MatchSpec</c> to the + <p>Deletes each object from the table <c><anno>Name</anno></c> such that + applying the match specification <c><anno>MatchSpec</anno></c> to the object returns the value <c>true</c>. See the ERTS User's Guide for a description of match specifications. Returns the number of deleted objects.</p> - <p>If the keypos'th element of <c>MatchSpec</c> is + <p>If the keypos'th element of <c><anno>MatchSpec</anno></c> is bound, the match specification is applied to the objects with the right key(s) only.</p> </desc> </func> <func> - <name>slot(Name, I) -> '$end_of_table' | [Object] | {error, Reason}</name> + <name name="slot" arity="2"/> <fsummary>Return the list of objects associated with a slot of a Dets table.</fsummary> - <type> - <v>Name = name()</v> - <v>I = int()</v> - <v>Object = object()</v> - </type> <desc> <p>The objects of a table are distributed among slots, starting with slot <c>0</c> and ending with slot n. This function returns the list of objects associated with slot - <c>I</c>. If <c>I</c> is greater than n <c>'$end_of_table'</c> - is returned.</p> + <c><anno>I</anno></c>. If <c><anno>I</anno></c> is greater than n + <c>'$end_of_table'</c> is returned.</p> </desc> </func> <func> - <name>sync(Name) -> ok | {error, Reason}</name> + <name name="sync" arity="1"/> <fsummary>Ensure that all updates made to a Dets table are written to disk.</fsummary> - <type> - <v>Name = name()</v> - </type> <desc> - <p>Ensures that all updates made to the table <c>Name</c> are + <p>Ensures that all updates made to the table <c><anno>Name</anno></c> are written to disk. This also applies to tables which have been opened with the <c>ram_file</c> flag set to <c>true</c>. In this case, the contents of the RAM file are flushed to @@ -1095,25 +1002,16 @@ ok </desc> </func> <func> - <name>table(Name [, Options]) -> QueryHandle</name> + <name name="table" arity="1"/> + <name name="table" arity="2"/> <fsummary>Return a QLC query handle.</fsummary> - <type> - <v>Name = name()</v> - <v>QueryHandle = - a query handle, see qlc(3) -</v> - <v>Options = [Option] | Option</v> - <v>Option = {n_objects, Limit} | {traverse, TraverseMethod}</v> - <v>Limit = default | integer() >= 1</v> - <v>TraverseMethod = first_next | select | {select, MatchSpec}</v> - <v>MatchSpec = match_spec()</v> - </type> <desc> - <p> <marker id="qlc_table"></marker> -Returns a QLC (Query List + <p><marker id="qlc_table"></marker>Returns a QLC (Query List Comprehension) query handle. The module <c>qlc</c> implements a query language aimed mainly at Mnesia but Ets tables, Dets tables, and lists are also recognized by <c>qlc</c> as sources of data. Calling <c>dets:table/1,2</c> is the - means to make the Dets table <c>Name</c> usable to <c>qlc</c>.</p> + means to make the Dets table <c><anno>Name</anno></c> usable to <c>qlc</c>.</p> <p>When there are only simple restrictions on the key position <c>qlc</c> uses <c>dets:lookup/2</c> to look up the keys, but when that is not possible the whole table is traversed. The @@ -1137,7 +1035,8 @@ Returns a QLC (Query List specification that matches all objects.</p> </item> <item> - <p><c>{select, MatchSpec}</c>. As for <c>select</c> + <p><c>{select, <seealso marker="#type-match_spec"> + match_spec()}</seealso></c>. As for <c>select</c> the table is traversed by calling <c>dets:select/3</c> and <c>dets:select/1</c>. The difference is that the match specification is explicitly given. This is how to @@ -1166,35 +1065,23 @@ true </pre> </desc> </func> <func> - <name>to_ets(Name, EtsTab) -> EtsTab | {error, Reason}</name> + <name name="to_ets" arity="2"/> <fsummary>Insert all objects of a Dets table into an Ets table.</fsummary> - <type> - <v>Name = name()</v> - <v>EtsTab = - see ets(3) -</v> - </type> <desc> - <p>Inserts the objects of the Dets table <c>Name</c> into the - Ets table <c>EtsTab</c>. The order in which the objects are + <p>Inserts the objects of the Dets table <c><anno>Name</anno></c> into the + Ets table <c><anno>EtsTab</anno></c>. The order in which the objects are inserted is not specified. The existing objects of the Ets table are kept unless overwritten.</p> </desc> </func> <func> - <name>traverse(Name, Fun) -> Return | {error, Reason}</name> + <name name="traverse" arity="2"/> <fsummary>Apply a function to all or some objects stored in a Dets table.</fsummary> - <type> - <v>Fun = fun(Object) -> FunReturn</v> - <v>FunReturn = continue | {continue, Val} | {done, Value}</v> - <v>Val = Value = term()</v> - <v>Name = name()</v> - <v>Object = object()</v> - <v>Return = [term()]</v> - </type> <desc> - <p>Applies <c>Fun</c> to each object stored in the table - <c>Name</c> in some unspecified order. Different actions are - taken depending on the return value of <c>Fun</c>. The - following <c>Fun</c> return values are allowed:</p> + <p>Applies <c><anno>Fun</anno></c> to each object stored in the table + <c><anno>Name</anno></c> in some unspecified order. Different actions are + taken depending on the return value of <c><anno>Fun</anno></c>. The + following <c><anno>Fun</anno></c> return values are allowed:</p> <taglist> <tag><c>continue</c></tag> <item> @@ -1206,35 +1093,31 @@ fun(X) -> io:format("~p~n", [X]), continue end. </pre> </item> <tag><c>{continue, Val}</c></tag> <item> - <p>Continue the traversal and accumulate <c>Val</c>. The + <p>Continue the traversal and accumulate <c><anno>Val</anno></c>. The following function is supplied in order to collect all objects of a table in a list: </p> <pre> fun(X) -> {continue, X} end. </pre> </item> - <tag><c>{done, Value}</c></tag> + <tag><c>{done, <anno>Value</anno>}</c></tag> <item> - <p>Terminate the traversal and return <c>[Value | Acc]</c>.</p> + <p>Terminate the traversal and return <c>[<anno>Value</anno> | Acc]</c>.</p> </item> </taglist> - <p>Any other value returned by <c>Fun</c> terminates the + <p>Any other value <c><anno>OtherValue</anno></c> returned by <c><anno>Fun</anno></c> terminates the traversal and is immediately returned. </p> </desc> </func> <func> - <name>update_counter(Name, Key, Increment) -> Result</name> + <name name="update_counter" arity="3"/> <fsummary>Update a counter object stored in a Dets table.</fsummary> - <type> - <v>Name = name()</v> - <v>Key = term()</v> - <v>Increment = {Pos, Incr} | Incr</v> - <v>Pos = Incr = Result = integer()</v> - </type> <desc> - <p>Updates the object with key <c>Key</c> stored in the table - <c>Name</c> of type <c>set</c> by adding <c>Incr</c> to the - element at the <c>Pos</c>:th position. The new counter value + <p>Updates the object with key <c><anno>Key</anno></c> stored in the + table <c><anno>Name</anno></c> of type <c>set</c> by adding + <c><anno>Incr</anno></c> to the + element at the <c><anno>Pos</anno></c>:th position. + The new counter value is returned. If no position is specified, the element directly following the key is updated.</p> <p>This functions provides a way of updating a counter, @@ -1252,4 +1135,3 @@ fun(X) -> {continue, X} end. </pre> <seealso marker="qlc">qlc(3)</seealso></p> </section> </erlref> - diff --git a/lib/stdlib/doc/src/dict.xml b/lib/stdlib/doc/src/dict.xml index ebcd2eed09..b01acd02bf 100644 --- a/lib/stdlib/doc/src/dict.xml +++ b/lib/stdlib/doc/src/dict.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2009</year> + <year>1996</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -39,176 +39,120 @@ they do not compare equal (<c>==</c>).</p> </description> - <section> - <title>DATA TYPES</title> - <code type="none"> -dictionary() - as returned by new/0</code> - </section> + <datatypes> + <datatype> + <name><marker id="type-dict">dict()</marker></name> + <desc><p>Dictionary as returned by <c>new/0</c>.</p></desc> + </datatype> + </datatypes> <funcs> <func> - <name>append(Key, Value, Dict1) -> Dict2</name> + <name name="append" arity="3"/> <fsummary>Append a value to keys in a dictionary</fsummary> - <type> - <v>Key = Value = term()</v> - <v>Dict1 = Dict2 = dictionary()</v> - </type> <desc> - <p>This function appends a new <c>Value</c> to the current list - of values associated with <c>Key</c>. An exception is - generated if the initial value associated with <c>Key</c> is - not a list of values.</p> + <p>This function appends a new <c><anno>Value</anno></c> to the current list + of values associated with <c><anno>Key</anno></c>.</p> </desc> </func> <func> - <name>append_list(Key, ValList, Dict1) -> Dict2</name> + <name name="append_list" arity="3"/> <fsummary>Append new values to keys in a dictionary</fsummary> - <type> - <v>ValList = [Value]</v> - <v>Key = Value = term()</v> - <v>Dict1 = Dict2 = dictionary()</v> - </type> <desc> - <p>This function appends a list of values <c>ValList</c> to - the current list of values associated with <c>Key</c>. An + <p>This function appends a list of values <c><anno>ValList</anno></c> to + the current list of values associated with <c><anno>Key</anno></c>. An exception is generated if the initial value associated with - <c>Key</c> is not a list of values.</p> + <c><anno>Key</anno></c> is not a list of values.</p> </desc> </func> <func> - <name>erase(Key, Dict1) -> Dict2</name> + <name name="erase" arity="2"/> <fsummary>Erase a key from a dictionary</fsummary> - <type> - <v>Key = term()</v> - <v>Dict1 = Dict2 = dictionary()</v> - </type> <desc> <p>This function erases all items with a given key from a dictionary.</p> </desc> </func> <func> - <name>fetch(Key, Dict) -> Value</name> + <name name="fetch" arity="2"/> <fsummary>Look-up values in a dictionary</fsummary> - <type> - <v>Key = Value = term()</v> - <v>Dict = dictionary()</v> - </type> <desc> - <p>This function returns the value associated with <c>Key</c> - in the dictionary <c>Dict</c>. <c>fetch</c> assumes that - the <c>Key</c> is present in the dictionary and an exception - is generated if <c>Key</c> is not in the dictionary.</p> + <p>This function returns the value associated with <c><anno>Key</anno></c> + in the dictionary <c><anno>Dict</anno></c>. <c>fetch</c> assumes that + the <c><anno>Key</anno></c> is present in the dictionary and an exception + is generated if <c><anno>Key</anno></c> is not in the dictionary.</p> </desc> </func> <func> - <name>fetch_keys(Dict) -> Keys</name> + <name name="fetch_keys" arity="1"/> <fsummary>Return all keys in a dictionary</fsummary> - <type> - <v>Dict = dictionary()</v> - <v>Keys = [term()]</v> - </type> <desc> <p>This function returns a list of all keys in the dictionary.</p> </desc> </func> <func> - <name>filter(Pred, Dict1) -> Dict2</name> + <name name="filter" arity="2"/> <fsummary>Choose elements which satisfy a predicate</fsummary> - <type> - <v>Pred = fun(Key, Value) -> bool()</v> - <v> Key = Value = term()</v> - <v>Dict1 = Dict2 = dictionary()</v> - </type> <desc> - <p><c>Dict2</c> is a dictionary of all keys and values in - <c>Dict1</c> for which <c>Pred(Key, Value)</c> is <c>true</c>.</p> + <p><c><anno>Dict2</anno></c> is a dictionary of all keys and values in + <c><anno>Dict1</anno></c> for which <c><anno>Pred</anno>(<anno>Key</anno>, <anno>Value</anno>)</c> is <c>true</c>.</p> </desc> </func> <func> - <name>find(Key, Dict) -> {ok, Value} | error</name> + <name name="find" arity="2"/> <fsummary>Search for a key in a dictionary</fsummary> - <type> - <v>Key = Value = term()</v> - <v>Dict = dictionary()</v> - </type> <desc> <p>This function searches for a key in a dictionary. Returns - <c>{ok, Value}</c> where <c>Value</c> is the value associated - with <c>Key</c>, or <c>error</c> if the key is not present in + <c>{ok, <anno>Value</anno>}</c> where <c><anno>Value</anno></c> is the value associated + with <c><anno>Key</anno></c>, or <c>error</c> if the key is not present in the dictionary.</p> </desc> </func> <func> - <name>fold(Fun, Acc0, Dict) -> Acc1</name> + <name name="fold" arity="3"/> <fsummary>Fold a function over a dictionary</fsummary> - <type> - <v>Fun = fun(Key, Value, AccIn) -> AccOut</v> - <v>Key = Value = term()</v> - <v>Acc0 = Acc1 = AccIn = AccOut = term()</v> - <v>Dict = dictionary()</v> - </type> <desc> - <p>Calls <c>Fun</c> on successive keys and values of - <c>Dict</c> together with an extra argument <c>Acc</c> - (short for accumulator). <c>Fun</c> must return a new - accumulator which is passed to the next call. <c>Acc0</c> is + <p>Calls <c><anno>Fun</anno></c> on successive keys and values of + <c><anno>Dict</anno></c> together with an extra argument <c>Acc</c> + (short for accumulator). <c><anno>Fun</anno></c> must return a new + accumulator which is passed to the next call. <c><anno>Acc0</anno></c> is returned if the list is empty. The evaluation order is undefined.</p> </desc> </func> <func> - <name>from_list(List) -> Dict</name> + <name name="from_list" arity="1"/> <fsummary>Convert a list of pairs to a dictionary</fsummary> - <type> - <v>List = [{Key, Value}]</v> - <v>Dict = dictionary()</v> - </type> <desc> - <p>This function converts the key/value list <c>List</c> to a - dictionary.</p> + <p>This function converts the <c><anno>Key</anno></c> - <c><anno>Value</anno></c> list + <c><anno>List</anno></c> to a dictionary.</p> </desc> </func> <func> - <name>is_key(Key, Dict) -> bool()</name> + <name name="is_key" arity="2"/> <fsummary>Test if a key is in a dictionary</fsummary> - <type> - <v>Key = term()</v> - <v>Dict = dictionary()</v> - </type> <desc> - <p>This function tests if <c>Key</c> is contained in - the dictionary <c>Dict</c>.</p> + <p>This function tests if <c><anno>Key</anno></c> is contained in + the dictionary <c><anno>Dict</anno></c>.</p> </desc> </func> <func> - <name>map(Fun, Dict1) -> Dict2</name> + <name name="map" arity="2"/> <fsummary>Map a function over a dictionary</fsummary> - <type> - <v>Fun = fun(Key, Value1) -> Value2</v> - <v> Key = Value1 = Value2 = term()</v> - <v>Dict1 = Dict2 = dictionary()</v> - </type> <desc> - <p><c>map</c> calls <c>Func</c> on successive keys and values - of <c>Dict</c> to return a new value for each key. + <p><c>map</c> calls <c><anno>Fun</anno></c> on successive keys and values + of <c><anno>Dict1</anno></c> to return a new value for each key. The evaluation order is undefined.</p> </desc> </func> <func> - <name>merge(Fun, Dict1, Dict2) -> Dict3</name> + <name name="merge" arity="3"/> <fsummary>Merge two dictionaries</fsummary> - <type> - <v>Fun = fun(Key, Value1, Value2) -> Value</v> - <v> Key = Value1 = Value2 = Value3 = term()</v> - <v>Dict1 = Dict2 = Dict3 = dictionary()</v> - </type> <desc> - <p><c>merge</c> merges two dictionaries, <c>Dict1</c> and - <c>Dict2</c>, to create a new dictionary. All the <c>Key</c> - - <c>Value</c> pairs from both dictionaries are included in + <p><c>merge</c> merges two dictionaries, <c><anno>Dict1</anno></c> and + <c><anno>Dict2</anno></c>, to create a new dictionary. All the <c><anno>Key</anno></c> + - <c><anno>Value</anno></c> pairs from both dictionaries are included in the new dictionary. If a key occurs in both dictionaries then - <c>Fun</c> is called with the key and both values to return a + <c><anno>Fun</anno></c> is called with the key and both values to return a new value. <c>merge</c> could be defined as:</p> <code type="none"> merge(Fun, D1, D2) -> @@ -219,75 +163,52 @@ merge(Fun, D1, D2) -> </desc> </func> <func> - <name>new() -> dictionary()</name> + <name name="new" arity="0"/> <fsummary>Create a dictionary</fsummary> <desc> <p>This function creates a new dictionary.</p> </desc> </func> <func> - <name>size(Dict) -> int()</name> + <name name="size" arity="1"/> <fsummary>Return the number of elements in a dictionary</fsummary> - <type> - <v>Dict = dictionary()</v> - </type> <desc> - <p>Returns the number of elements in a <c>Dict</c>.</p> + <p>Returns the number of elements in a <c><anno>Dict</anno></c>.</p> </desc> </func> <func> - <name>store(Key, Value, Dict1) -> Dict2</name> + <name name="store" arity="3"/> <fsummary>Store a value in a dictionary</fsummary> - <type> - <v>Key = Value = term()</v> - <v>Dict1 = Dict2 = dictionary()</v> - </type> <desc> - <p>This function stores a <c>Key</c> - <c>Value</c> pair in a - dictionary. If the <c>Key</c> already exists in <c>Dict1</c>, - the associated value is replaced by <c>Value</c>.</p> + <p>This function stores a <c><anno>Key</anno></c> - <c><anno>Value</anno></c> pair in a + dictionary. If the <c><anno>Key</anno></c> already exists in <c><anno>Dict1</anno></c>, + the associated value is replaced by <c><anno>Value</anno></c>.</p> </desc> </func> <func> - <name>to_list(Dict) -> List</name> + <name name="to_list" arity="1"/> <fsummary>Convert a dictionary to a list of pairs</fsummary> - <type> - <v>Dict = dictionary()</v> - <v>List = [{Key, Value}]</v> - </type> <desc> <p>This function converts the dictionary to a list representation.</p> </desc> </func> <func> - <name>update(Key, Fun, Dict1) -> Dict2</name> + <name name="update" arity="3"/> <fsummary>Update a value in a dictionary</fsummary> - <type> - <v>Key = term()</v> - <v>Fun = fun(Value1) -> Value2</v> - <v> Value1 = Value2 = term()</v> - <v>Dict1 = Dict2 = dictionary()</v> - </type> <desc> - <p>Update the a value in a dictionary by calling <c>Fun</c> on + <p>Update a value in a dictionary by calling <c><anno>Fun</anno></c> on the value to get a new value. An exception is generated if - <c>Key</c> is not present in the dictionary.</p> + <c><anno>Key</anno></c> is not present in the dictionary.</p> </desc> </func> <func> - <name>update(Key, Fun, Initial, Dict1) -> Dict2</name> + <name name="update" arity="4"/> <fsummary>Update a value in a dictionary</fsummary> - <type> - <v>Key = Initial = term()</v> - <v>Fun = fun(Value1) -> Value2</v> - <v> Value1 = Value2 = term()</v> - <v>Dict1 = Dict2 = dictionary()</v> - </type> <desc> - <p>Update the a value in a dictionary by calling <c>Fun</c> on - the value to get a new value. If <c>Key</c> is not present - in the dictionary then <c>Initial</c> will be stored as + <p>Update a value in a dictionary by calling <c><anno>Fun</anno></c> on + the value to get a new value. If <c><anno>Key</anno></c> is not present + in the dictionary then <c><anno>Initial</anno></c> will be stored as the first value. For example <c>append/3</c> could be defined as:</p> <code type="none"> @@ -296,17 +217,12 @@ append(Key, Val, D) -> </desc> </func> <func> - <name>update_counter(Key, Increment, Dict1) -> Dict2</name> + <name name="update_counter" arity="3"/> <fsummary>Increment a value in a dictionary</fsummary> - <type> - <v>Key = term()</v> - <v>Increment = number()</v> - <v>Dict1 = Dict2 = dictionary()</v> - </type> <desc> - <p>Add <c>Increment</c> to the value associated with <c>Key</c> - and store this value. If <c>Key</c> is not present in - the dictionary then <c>Increment</c> will be stored as + <p>Add <c><anno>Increment</anno></c> to the value associated with <c><anno>Key</anno></c> + and store this value. If <c><anno>Key</anno></c> is not present in + the dictionary then <c><anno>Increment</anno></c> will be stored as the first value.</p> <p>This could be defined as:</p> <code type="none"> diff --git a/lib/stdlib/doc/src/digraph.xml b/lib/stdlib/doc/src/digraph.xml index ad256e671f..0afc70ebe0 100644 --- a/lib/stdlib/doc/src/digraph.xml +++ b/lib/stdlib/doc/src/digraph.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2009</year> + <year>1996</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -87,67 +87,79 @@ is a digraph that has no cycles. </p> </description> + <datatypes> + <datatype> + <name name="d_type"/> + </datatype> + <datatype> + <name name="d_cyclicity"/> + </datatype> + <datatype> + <name name="d_protection"/> + </datatype> + <datatype> + <name><marker id="type-digraph">digraph()</marker></name> + <desc><p>A digraph as returned by <c>new/0,1</c>.</p></desc> + </datatype> + <datatype> + <name><marker id="type-edge">edge()</marker></name> + </datatype> + <datatype> + <name name="label"/> + </datatype> + <datatype> + <name><marker id="type-vertex">vertex()</marker></name> + </datatype> + </datatypes> <funcs> <func> - <name>add_edge(G, E, V1, V2, Label) -> edge() | {error, Reason}</name> - <name>add_edge(G, V1, V2, Label) -> edge() | {error, Reason}</name> - <name>add_edge(G, V1, V2) -> edge() | {error, Reason}</name> + <name name="add_edge" arity="3"/> + <name name="add_edge" arity="4"/> + <name name="add_edge" arity="5"/> <fsummary>Add an edge to a digraph.</fsummary> - <type> - <v>G = digraph()</v> - <v>E = edge()</v> - <v>V1 = V2 = vertex()</v> - <v>Label = label()</v> - <v>Reason = {bad_edge, Path} | {bad_vertex, V}</v> - <v>Path = [vertex()]</v> - </type> + <type name="add_edge_err_rsn"/> <desc> - <p><c>add_edge/5</c> creates (or modifies) the edge <c>E</c> - of the digraph <c>G</c>, using <c>Label</c> as the (new) + <p><c>add_edge/5</c> creates (or modifies) the edge <c><anno>E</anno></c> + of the digraph <c><anno>G</anno></c>, using <c><anno>Label</anno></c> as the (new) <seealso marker="#label">label</seealso> of the edge. The edge is <seealso marker="#emanate">emanating</seealso> from - <c>V1</c> and <seealso marker="#incident">incident</seealso> - on <c>V2</c>. Returns <c>E</c>. + <c><anno>V1</anno></c> and <seealso marker="#incident">incident</seealso> + on <c><anno>V2</anno></c>. Returns <c><anno>E</anno></c>. </p> - <p><c>add_edge(G, V1, V2, Label)</c> is + <p><c>add_edge(<anno>G</anno>, <anno>V1</anno>, <anno>V2</anno>, <anno>Label</anno>)</c> is equivalent to - <c>add_edge(G, E, V1, V2, Label)</c>, - where <c>E</c> is a created edge. The created edge is + <c>add_edge(<anno>G</anno>, <anno>E</anno>, <anno>V1</anno>, <anno>V2</anno>, <anno>Label</anno>)</c>, + where <c><anno>E</anno></c> is a created edge. The created edge is represented by the term <c>['$e' | N]</c>, where N is an integer >= 0. </p> - <p><c>add_edge(G, V1, V2)</c> is equivalent to - <c>add_edge(G, V1, V2, [])</c>. + <p><c>add_edge(<anno>G</anno>, <anno>V1</anno>, <anno>V2</anno>)</c> is equivalent to + <c>add_edge(<anno>G</anno>, <anno>V1</anno>, <anno>V2</anno>, [])</c>. </p> <p>If the edge would create a cycle in an <seealso marker="#acyclic_digraph">acyclic digraph</seealso>, - then <c>{error, {bad_edge, Path}}</c> is returned. If - either of <c>V1</c> or <c>V2</c> is not a vertex of the - digraph <c>G</c>, then - <c>{error, {bad_vertex, </c>V<c>}}</c> is - returned, V = <c>V1</c> or - V = <c>V2</c>. + then <c>{error, {bad_edge, <anno>Path</anno>}}</c> is returned. If + either of <c><anno>V1</anno></c> or <c><anno>V2</anno></c> is not a vertex of the + digraph <c><anno>G</anno></c>, then + <c>{error, {bad_vertex, </c><anno>V</anno><c>}}</c> is + returned, <anno>V</anno> = <c><anno>V1</anno></c> or + <anno>V</anno> = <c><anno>V2</anno></c>. </p> </desc> </func> <func> - <name>add_vertex(G, V, Label) -> vertex()</name> - <name>add_vertex(G, V) -> vertex()</name> - <name>add_vertex(G) -> vertex()</name> + <name name="add_vertex" arity="1"/> + <name name="add_vertex" arity="2"/> + <name name="add_vertex" arity="3"/> <fsummary>Add or modify a vertex of a digraph.</fsummary> - <type> - <v>G = digraph()</v> - <v>V = vertex()</v> - <v>Label = label()</v> - </type> <desc> - <p><c>add_vertex/3</c> creates (or modifies) the vertex <c>V</c> - of the digraph <c>G</c>, using <c>Label</c> as the (new) + <p><c>add_vertex/3</c> creates (or modifies) the vertex <c><anno>V</anno></c> + of the digraph <c><anno>G</anno></c>, using <c><anno>Label</anno></c> as the (new) <seealso marker="#label">label</seealso> of the - vertex. Returns <c>V</c>. + vertex. Returns <c><anno>V</anno></c>. </p> - <p><c>add_vertex(G, V)</c> is equivalent to - <c>add_vertex(G, V, [])</c>. + <p><c>add_vertex(<anno>G</anno>, <anno>V</anno>)</c> is equivalent to + <c>add_vertex(<anno>G</anno>, <anno>V</anno>, [])</c>. </p> <p><c>add_vertex/1</c> creates a vertex using the empty list as label, and returns the created vertex. The created vertex @@ -157,304 +169,227 @@ </desc> </func> <func> - <name>del_edge(G, E) -> true</name> + <name name="del_edge" arity="2"/> <fsummary>Delete an edge from a digraph.</fsummary> - <type> - <v>G = digraph()</v> - <v>E = edge()</v> - </type> <desc> - <p>Deletes the edge <c>E</c> from the digraph <c>G</c>. + <p>Deletes the edge <c><anno>E</anno></c> from the digraph <c><anno>G</anno></c>. </p> </desc> </func> <func> - <name>del_edges(G, Edges) -> true</name> + <name name="del_edges" arity="2"/> <fsummary>Delete edges from a digraph.</fsummary> - <type> - <v>G = digraph()</v> - <v>Edges = [edge()]</v> - </type> <desc> - <p>Deletes the edges in the list <c>Edges</c> from the digraph - <c>G</c>. + <p>Deletes the edges in the list <c><anno>Edges</anno></c> from the digraph + <c><anno>G</anno></c>. </p> </desc> </func> <func> - <name>del_path(G, V1, V2) -> true</name> + <name name="del_path" arity="3"/> <fsummary>Delete paths from a digraph.</fsummary> - <type> - <v>G = digraph()</v> - <v>V1 = V2 = vertex()</v> - </type> <desc> - <p>Deletes edges from the digraph <c>G</c> until there are no + <p>Deletes edges from the digraph <c><anno>G</anno></c> until there are no <seealso marker="#path">paths</seealso> from the vertex - <c>V1</c> to the vertex <c>V2</c>. + <c><anno>V1</anno></c> to the vertex <c><anno>V2</anno></c>. </p> <p>A sketch of the procedure employed: Find an arbitrary <seealso marker="#simple_path">simple path</seealso> - v[1], v[2], ..., v[k] from <c>V1</c> to - <c>V2</c> in <c>G</c>. Remove all edges of - <c>G</c> <seealso marker="#emanate">emanating</seealso> from v[i] + v[1], v[2], ..., v[k] from <c><anno>V1</anno></c> to + <c><anno>V2</anno></c> in <c><anno>G</anno></c>. Remove all edges of + <c><anno>G</anno></c> <seealso marker="#emanate">emanating</seealso> from v[i] and <seealso marker="#incident">incident</seealso> to v[i+1] for 1 <= i < k (including multiple - edges). Repeat until there is no path between <c>V1</c> and - <c>V2</c>. + edges). Repeat until there is no path between <c><anno>V1</anno></c> and + <c><anno>V2</anno></c>. </p> </desc> </func> <func> - <name>del_vertex(G, V) -> true</name> + <name name="del_vertex" arity="2"/> <fsummary>Delete a vertex from a digraph.</fsummary> - <type> - <v>G = digraph()</v> - <v>V = vertex()</v> - </type> <desc> - <p>Deletes the vertex <c>V</c> from the digraph <c>G</c>. Any + <p>Deletes the vertex <c><anno>V</anno></c> from the digraph <c><anno>G</anno></c>. Any edges <seealso marker="#emanate">emanating</seealso> from - <c>V</c> or <seealso marker="#incident">incident</seealso> - on <c>V</c> are also deleted. + <c><anno>V</anno></c> or <seealso marker="#incident">incident</seealso> + on <c><anno>V</anno></c> are also deleted. </p> </desc> </func> <func> - <name>del_vertices(G, Vertices) -> true</name> + <name name="del_vertices" arity="2"/> <fsummary>Delete vertices from a digraph.</fsummary> - <type> - <v>G = digraph()</v> - <v>Vertices = [vertex()]</v> - </type> <desc> - <p>Deletes the vertices in the list <c>Vertices</c> from the - digraph <c>G</c>. + <p>Deletes the vertices in the list <c><anno>Vertices</anno></c> from the + digraph <c><anno>G</anno></c>. </p> </desc> </func> <func> - <name>delete(G) -> true</name> + <name name="delete" arity="1"/> <fsummary>Delete a digraph.</fsummary> - <type> - <v>G = digraph()</v> - </type> <desc> - <p>Deletes the digraph <c>G</c>. This call is important - because digraphs are implemented with <c>Ets</c>. There is - no garbage collection of <c>Ets</c> tables. The digraph + <p>Deletes the digraph <c><anno>G</anno></c>. This call is important + because digraphs are implemented with <c>ETS</c>. There is + no garbage collection of <c>ETS</c> tables. The digraph will, however, be deleted if the process that created the digraph terminates. </p> </desc> </func> <func> - <name>edge(G, E) -> {E, V1, V2, Label} | false</name> + <name name="edge" arity="2"/> <fsummary>Return the vertices and the label of an edge of a digraph.</fsummary> - <type> - <v>G = digraph()</v> - <v>E = edge()</v> - <v>V1 = V2 = vertex()</v> - <v>Label = label()</v> - </type> <desc> - <p>Returns <c>{E, V1, V2, Label}</c> where - <c>Label</c> is the <seealso marker="#label">label</seealso> + <p>Returns <c>{<anno>E</anno>, <anno>V1</anno>, <anno>V2</anno>, <anno>Label</anno>}</c> where + <c><anno>Label</anno></c> is the <seealso marker="#label">label</seealso> of the edge - <c>E</c> <seealso marker="#emanate">emanating</seealso> from - <c>V1</c> and <seealso marker="#incident">incident</seealso> on - <c>V2</c> of the digraph <c>G</c>. - If there is no edge <c>E</c> of the - digraph <c>G</c>, then <c>false</c> is returned. + <c><anno>E</anno></c> <seealso marker="#emanate">emanating</seealso> from + <c><anno>V1</anno></c> and <seealso marker="#incident">incident</seealso> on + <c><anno>V2</anno></c> of the digraph <c><anno>G</anno></c>. + If there is no edge <c><anno>E</anno></c> of the + digraph <c><anno>G</anno></c>, then <c>false</c> is returned. </p> </desc> </func> <func> - <name>edges(G) -> Edges</name> + <name name="edges" arity="1"/> <fsummary>Return all edges of a digraph.</fsummary> - <type> - <v>G = digraph()</v> - <v>Edges = [edge()]</v> - </type> <desc> - <p>Returns a list of all edges of the digraph <c>G</c>, in + <p>Returns a list of all edges of the digraph <c><anno>G</anno></c>, in some unspecified order. </p> </desc> </func> <func> - <name>edges(G, V) -> Edges</name> + <name name="edges" arity="2"/> <fsummary>Return the edges emanating from or incident on a vertex of a digraph.</fsummary> - <type> - <v>G = digraph()</v> - <v>V = vertex()</v> - <v>Edges = [edge()]</v> - </type> <desc> <p>Returns a list of all edges <seealso marker="#emanate">emanating</seealso> from - or <seealso marker="#incident">incident</seealso> on <c>V</c> - of the digraph <c>G</c>, in some unspecified order.</p> + or <seealso marker="#incident">incident</seealso> on <c><anno>V</anno></c> + of the digraph <c><anno>G</anno></c>, in some unspecified order.</p> </desc> </func> <func> - <name>get_cycle(G, V) -> Vertices | false</name> + <name name="get_cycle" arity="2"/> <fsummary>Find one cycle in a digraph.</fsummary> - <type> - <v>G = digraph()</v> - <v>V1 = V2 = vertex()</v> - <v>Vertices = [vertex()]</v> - </type> <desc> <p>If there is a <seealso marker="#simple_cycle">simple cycle</seealso> of length two or more through the vertex - <c>V</c>, then the cycle is returned as a list - <c>[V, ..., V]</c> of vertices, otherwise if there + <c><anno>V</anno></c>, then the cycle is returned as a list + <c>[<anno>V</anno>, ..., <anno>V</anno>]</c> of vertices, otherwise if there is a <seealso marker="#loop">loop</seealso> through - <c>V</c>, then the loop is returned as a list <c>[V]</c>. If - there are no cycles through <c>V</c>, then <c>false</c> is + <c><anno>V</anno></c>, then the loop is returned as a list <c>[<anno>V</anno>]</c>. If + there are no cycles through <c><anno>V</anno></c>, then <c>false</c> is returned. </p> <p><c>get_path/3</c> is used for finding a simple cycle - through <c>V</c>. + through <c><anno>V</anno></c>. </p> </desc> </func> <func> - <name>get_path(G, V1, V2) -> Vertices | false</name> + <name name="get_path" arity="3"/> <fsummary>Find one path in a digraph.</fsummary> - <type> - <v>G = digraph()</v> - <v>V1 = V2 = vertex()</v> - <v>Vertices = [vertex()]</v> - </type> <desc> <p>Tries to find a <seealso marker="#simple_path">simple path</seealso> from - the vertex <c>V1</c> to the vertex - <c>V2</c> of the digraph <c>G</c>. Returns the path as a - list <c>[V1, ..., V2]</c> of vertices, or - <c>false</c> if no simple path from <c>V1</c> to <c>V2</c> + the vertex <c><anno>V1</anno></c> to the vertex + <c><anno>V2</anno></c> of the digraph <c><anno>G</anno></c>. Returns the path as a + list <c>[<anno>V1</anno>, ..., <anno>V2</anno>]</c> of vertices, or + <c>false</c> if no simple path from <c><anno>V1</anno></c> to <c><anno>V2</anno></c> of length one or more exists. </p> - <p>The digraph <c>G</c> is traversed in a depth-first manner, + <p>The digraph <c><anno>G</anno></c> is traversed in a depth-first manner, and the first path found is returned. </p> </desc> </func> <func> - <name>get_short_cycle(G, V) -> Vertices | false</name> + <name name="get_short_cycle" arity="2"/> <fsummary>Find one short cycle in a digraph.</fsummary> - <type> - <v>G = digraph()</v> - <v>V1 = V2 = vertex()</v> - <v>Vertices = [vertex()]</v> - </type> <desc> <p>Tries to find an as short as possible <seealso marker="#simple_cycle">simple cycle</seealso> through - the vertex <c>V</c> of the digraph <c>G</c>. Returns the cycle - as a list <c>[V, ..., V]</c> of vertices, or - <c>false</c> if no simple cycle through <c>V</c> exists. + the vertex <c><anno>V</anno></c> of the digraph <c>G</c>. Returns the cycle + as a list <c>[<anno>V</anno>, ..., <anno>V</anno>]</c> of vertices, or + <c>false</c> if no simple cycle through <c><anno>V</anno></c> exists. Note that a <seealso marker="#loop">loop</seealso> through - <c>V</c> is returned as the list <c>[V, V]</c>. + <c><anno>V</anno></c> is returned as the list <c>[<anno>V</anno>, <anno>V</anno>]</c>. </p> <p><c>get_short_path/3</c> is used for finding a simple cycle - through <c>V</c>. + through <c><anno>V</anno></c>. </p> </desc> </func> <func> - <name>get_short_path(G, V1, V2) -> Vertices | false</name> + <name name="get_short_path" arity="3"/> <fsummary>Find one short path in a digraph.</fsummary> - <type> - <v>G = digraph()</v> - <v>V1 = V2 = vertex()</v> - <v>Vertices = [vertex()]</v> - </type> <desc> <p>Tries to find an as short as possible <seealso marker="#simple_path">simple path</seealso> from - the vertex <c>V1</c> to the vertex <c>V2</c> of the digraph <c>G</c>. - Returns the path as a list <c>[V1, ..., V2]</c> of - vertices, or <c>false</c> if no simple path from <c>V1</c> - to <c>V2</c> of length one or more exists. + the vertex <c><anno>V1</anno></c> to the vertex <c><anno>V2</anno></c> of the digraph <c><anno>G</anno></c>. + Returns the path as a list <c>[<anno>V1</anno>, ..., <anno>V2</anno>]</c> of + vertices, or <c>false</c> if no simple path from <c><anno>V1</anno></c> + to <c><anno>V2</anno></c> of length one or more exists. </p> - <p>The digraph <c>G</c> is traversed in a breadth-first + <p>The digraph <c><anno>G</anno></c> is traversed in a breadth-first manner, and the first path found is returned. </p> </desc> </func> <func> - <name>in_degree(G, V) -> integer()</name> + <name name="in_degree" arity="2"/> <fsummary>Return the in-degree of a vertex of a digraph.</fsummary> - <type> - <v>G= digraph()</v> - <v>V = vertex()</v> - </type> <desc> <p>Returns the <seealso marker="#in_degree">in-degree</seealso> of the vertex - <c>V</c> of the digraph <c>G</c>. + <c><anno>V</anno></c> of the digraph <c><anno>G</anno></c>. </p> </desc> </func> <func> - <name>in_edges(G, V) -> Edges</name> + <name name="in_edges" arity="2"/> <fsummary>Return all edges incident on a vertex of a digraph.</fsummary> - <type> - <v>G = digraph()</v> - <v>V = vertex()</v> - <v>Edges = [edge()]</v> - </type> <desc> <p>Returns a list of all edges <seealso marker="#incident">incident</seealso> on - <c>V</c> of the digraph <c>G</c>, in some unspecified order. + <c><anno>V</anno></c> of the digraph <c><anno>G</anno></c>, in some unspecified order. </p> </desc> </func> <func> - <name>in_neighbours(G, V) -> Vertices</name> + <name name="in_neighbours" arity="2"/> <fsummary>Return all in-neighbours of a vertex of a digraph.</fsummary> - <type> - <v>G = digraph()</v> - <v>V = vertex()</v> - <v>Vertices = [vertex()]</v> - </type> <desc> <p>Returns a list of all <seealso marker="#in_neighbour">in-neighbours</seealso> of - <c>V</c> of the digraph <c>G</c>, in some unspecified order. + <c><anno>V</anno></c> of the digraph <c><anno>G</anno></c>, in some unspecified order. </p> </desc> </func> <func> - <name>info(G) -> InfoList</name> + <name name="info" arity="1"/> <fsummary>Return information about a digraph.</fsummary> - <type> - <v>G = digraph()</v> - <v>InfoList = [{cyclicity, Cyclicity}, {memory, NoWords}, {protection, Protection}]</v> - <v>Cyclicity = cyclic | acyclic</v> - <v>Protection = protected | private</v> - <v>NoWords = integer() >= 0</v> - </type> + <type name="d_cyclicity"/> + <type name="d_protection"/> <desc> <p>Returns a list of <c>{Tag, Value}</c> pairs describing the - digraph <c>G</c>. The following pairs are returned: + digraph <c><anno>G</anno></c>. The following pairs are returned: </p> <list type="bulleted"> <item> - <p><c>{cyclicity, Cyclicity}</c>, where <c>Cyclicity</c> + <p><c>{cyclicity, <anno>Cyclicity</anno>}</c>, where <c><anno>Cyclicity</anno></c> is <c>cyclic</c> or <c>acyclic</c>, according to the options given to <c>new</c>.</p> </item> <item> - <p><c>{memory, NoWords}</c>, where <c>NoWords</c> is - the number of words allocated to the <c>ets</c> tables.</p> + <p><c>{memory, <anno>NoWords</anno>}</c>, where <c><anno>NoWords</anno></c> is + the number of words allocated to the <c>ETS</c> tables.</p> </item> <item> - <p><c>{protection, Protection}</c>, where <c>Protection</c> + <p><c>{protection, <anno>Protection</anno>}</c>, where <c><anno>Protection</anno></c> is <c>protected</c> or <c>private</c>, according to the options given to <c>new</c>.</p> </item> @@ -462,7 +397,7 @@ </desc> </func> <func> - <name>new() -> digraph()</name> + <name name="new" arity="0"/> <fsummary>Return a protected empty digraph, where cycles are allowed.</fsummary> <desc> <p>Equivalent to <c>new([])</c>. @@ -470,15 +405,16 @@ </desc> </func> <func> - <name>new(Type) -> digraph()</name> + <name name="new" arity="1"/> <fsummary>Create a new empty digraph.</fsummary> - <type> - <v>Type = [cyclic | acyclic | private | protected]</v> - </type> + <type variable="Type"/> + <type name="d_type"/> + <type name="d_cyclicity"/> + <type name="d_protection"/> <desc> <p>Returns an <seealso marker="#empty_digraph">empty digraph</seealso> with - properties according to the options in <c>Type</c>:</p> + properties according to the options in <c><anno>Type</anno></c>:</p> <taglist> <tag><c>cyclic</c></tag> <item>Allow <seealso marker="#cycle">cycles</seealso> in the @@ -491,101 +427,72 @@ <item>The digraph can be read and modified by the creating process only.</item> </taglist> - <p>If an unrecognized type option <c>T</c> is given or <c>Type</c> + <p>If an unrecognized type option <c>T</c> is given or <c><anno>Type</anno></c> is not a proper list, there will be a <c>badarg</c> exception. </p> </desc> </func> <func> - <name>no_edges(G) -> integer() >= 0</name> + <name name="no_edges" arity="1"/> <fsummary>Return the number of edges of the a digraph.</fsummary> - <type> - <v>G = digraph()</v> - </type> <desc> - <p>Returns the number of edges of the digraph <c>G</c>. + <p>Returns the number of edges of the digraph <c><anno>G</anno></c>. </p> </desc> </func> <func> - <name>no_vertices(G) -> integer() >= 0</name> + <name name="no_vertices" arity="1"/> <fsummary>Return the number of vertices of a digraph.</fsummary> - <type> - <v>G = digraph()</v> - </type> <desc> - <p>Returns the number of vertices of the digraph <c>G</c>. + <p>Returns the number of vertices of the digraph <c><anno>G</anno></c>. </p> </desc> </func> <func> - <name>out_degree(G, V) -> integer()</name> + <name name="out_degree" arity="2"/> <fsummary>Return the out-degree of a vertex of a digraph.</fsummary> - <type> - <v>G = digraph()</v> - <v>V = vertex()</v> - </type> <desc> <p>Returns the <seealso marker="#out_degree">out-degree</seealso> of the vertex - <c>V</c> of the digraph <c>G</c>. + <c><anno>V</anno></c> of the digraph <c><anno>G</anno></c>. </p> </desc> </func> <func> - <name>out_edges(G, V) -> Edges</name> + <name name="out_edges" arity="2"/> <fsummary>Return all edges emanating from a vertex of a digraph.</fsummary> - <type> - <v>G = digraph()</v> - <v>V = vertex()</v> - <v>Edges = [edge()]</v> - </type> <desc> <p>Returns a list of all edges <seealso marker="#emanate">emanating</seealso> from - <c>V</c> of the digraph <c>G</c>, in some unspecified order. + <c><anno>V</anno></c> of the digraph <c><anno>G</anno></c>, in some unspecified order. </p> </desc> </func> <func> - <name>out_neighbours(G, V) -> Vertices</name> + <name name="out_neighbours" arity="2"/> <fsummary>Return all out-neighbours of a vertex of a digraph.</fsummary> - <type> - <v>G = digraph()</v> - <v>V = vertex()</v> - <v>Vertices = [vertex()]</v> - </type> <desc> <p>Returns a list of all <seealso marker="#out_neighbour">out-neighbours</seealso> of - <c>V</c> of the digraph <c>G</c>, in some unspecified order. + <c><anno>V</anno></c> of the digraph <c><anno>G</anno></c>, in some unspecified order. </p> </desc> </func> <func> - <name>vertex(G, V) -> {V, Label} | false</name> + <name name="vertex" arity="2"/> <fsummary>Return the label of a vertex of a digraph.</fsummary> - <type> - <v>G = digraph()</v> - <v>V = vertex()</v> - <v>Label = label()</v> - </type> <desc> - <p>Returns <c>{V, Label}</c> where <c>Label</c> is the + <p>Returns <c>{<anno>V</anno>, <anno>Label</anno>}</c> where <c><anno>Label</anno></c> is the <seealso marker="#label">label</seealso> of the vertex - <c>V</c> of the digraph <c>G</c>, or <c>false</c> if there - is no vertex <c>V</c> of the digraph <c>G</c>. + <c><anno>V</anno></c> of the digraph <c><anno>G</anno></c>, or <c>false</c> if there + is no vertex <c><anno>V</anno></c> of the digraph <c><anno>G</anno></c>. </p> </desc> </func> <func> - <name>vertices(G) -> Vertices</name> + <name name="vertices" arity="1"/> <fsummary>Return all vertices of a digraph.</fsummary> - <type> - <v>G = digraph()</v> - <v>Vertices = [vertex()]</v> - </type> <desc> - <p>Returns a list of all vertices of the digraph <c>G</c>, in + <p>Returns a list of all vertices of the digraph <c><anno>G</anno></c>, in some unspecified order. </p> </desc> diff --git a/lib/stdlib/doc/src/digraph_utils.xml b/lib/stdlib/doc/src/digraph_utils.xml index 4b137456b3..e44632bfd2 100644 --- a/lib/stdlib/doc/src/digraph_utils.xml +++ b/lib/stdlib/doc/src/digraph_utils.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>2000</year><year>2009</year> + <year>2000</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -119,49 +119,43 @@ considering all edges undirected.</p> </description> + <datatypes> + <datatype> + <name><marker id="type-digraph">digraph()</marker></name> + <desc><p>A digraph as returned by <c>digraph:new/0,1</c>.</p></desc> + </datatype> + </datatypes> <funcs> <func> - <name>arborescence_root(Digraph) -> no | {yes, Root}</name> + <name name="arborescence_root" arity="1"/> <fsummary>Check if a digraph is an arborescence.</fsummary> - <type> - <v>Digraph = digraph()</v> - <v>Root = vertex()</v> - </type> <desc> - - <p>Returns <c>{yes, Root}</c> if <c>Root</c> is + <p>Returns <c>{yes, <anno>Root</anno>}</c> if <c><anno>Root</anno></c> is the <seealso marker="#root">root</seealso> of the arborescence - <c>Digraph</c>, <c>no</c> otherwise. + <c><anno>Digraph</anno></c>, <c>no</c> otherwise. </p> </desc> </func> <func> - <name>components(Digraph) -> [Component]</name> + <name name="components" arity="1"/> <fsummary>Return the components of a digraph.</fsummary> - <type> - <v>Digraph = digraph()</v> - <v>Component = [vertex()]</v> - </type> <desc> <p>Returns a list of <seealso marker="#components">connected components</seealso>. Each component is represented by its vertices. The order of the vertices and the order of the components are arbitrary. Each vertex of the digraph - <c>Digraph</c> occurs in exactly one component. + <c><anno>Digraph</anno></c> occurs in exactly one component. </p> </desc> </func> <func> - <name>condensation(Digraph) -> CondensedDigraph</name> + <name name="condensation" arity="1"/> <fsummary>Return a condensed graph of a digraph.</fsummary> - <type> - <v>Digraph = CondensedDigraph = digraph()</v> - </type> <desc> <p>Creates a digraph where the vertices are the <seealso marker="#strong_components">strongly connected - components</seealso> of <c>Digraph</c> as returned by + components</seealso> of <c><anno>Digraph</anno></c> as returned by <c>strong_components/1</c>. If X and Y are strongly connected components, and there exist vertices x and y in X and Y respectively such that there is an @@ -169,7 +163,7 @@ and <seealso marker="#incident">incident</seealso> on y, then an edge emanating from X and incident on Y is created. </p> - <p>The created digraph has the same type as <c>Digraph</c>. + <p>The created digraph has the same type as <c><anno>Digraph</anno></c>. All vertices and edges have the default <seealso marker="#label">label</seealso> <c>[]</c>. </p> @@ -181,12 +175,8 @@ </desc> </func> <func> - <name>cyclic_strong_components(Digraph) -> [StrongComponent]</name> + <name name="cyclic_strong_components" arity="1"/> <fsummary>Return the cyclic strong components of a digraph.</fsummary> - <type> - <v>Digraph = digraph()</v> - <v>StrongComponent = [vertex()]</v> - </type> <desc> <p>Returns a list of <seealso marker="#strong_components">strongly connected components</seealso>. @@ -194,67 +184,50 @@ by its vertices. The order of the vertices and the order of the components are arbitrary. Only vertices that are included in some <seealso marker="#cycle">cycle</seealso> in - <c>Digraph</c> are returned, otherwise the returned list is + <c><anno>Digraph</anno></c> are returned, otherwise the returned list is equal to that returned by <c>strong_components/1</c>. </p> </desc> </func> <func> - <name>is_acyclic(Digraph) -> bool()</name> + <name name="is_acyclic" arity="1"/> <fsummary>Check if a digraph is acyclic.</fsummary> - <type> - <v>Digraph = digraph()</v> - </type> <desc> <p>Returns <c>true</c> if and only if the digraph - <c>Digraph</c> is <seealso marker="#acyclic_digraph">acyclic</seealso>.</p> + <c><anno>Digraph</anno></c> is <seealso marker="#acyclic_digraph">acyclic</seealso>.</p> </desc> </func> <func> - <name>is_arborescence(Digraph) -> bool()</name> + <name name="is_arborescence" arity="1"/> <fsummary>Check if a digraph is an arborescence.</fsummary> - <type> - <v>Digraph = digraph()</v> - </type> <desc> <p>Returns <c>true</c> if and only if the digraph - <c>Digraph</c> is + <c><anno>Digraph</anno></c> is an <seealso marker="#arborescence">arborescence</seealso>.</p> </desc> </func> <func> - <name>is_tree(Digraph) -> bool()</name> + <name name="is_tree" arity="1"/> <fsummary>Check if a digraph is a tree.</fsummary> - <type> - <v>Digraph = digraph()</v> - </type> <desc> <p>Returns <c>true</c> if and only if the digraph - <c>Digraph</c> is + <c><anno>Digraph</anno></c> is a <seealso marker="#tree">tree</seealso>.</p> </desc> </func> <func> - <name>loop_vertices(Digraph) -> Vertices</name> + <name name="loop_vertices" arity="1"/> <fsummary>Return the vertices of a digraph included in some loop.</fsummary> - <type> - <v>Digraph = digraph()</v> - <v>Vertices = [vertex()]</v> - </type> <desc> - <p>Returns a list of all vertices of <c>Digraph</c> that are + <p>Returns a list of all vertices of <c><anno>Digraph</anno></c> that are included in some <seealso marker="#loop">loop</seealso>.</p> </desc> </func> <func> - <name>postorder(Digraph) -> Vertices</name> + <name name="postorder" arity="1"/> <fsummary>Return the vertices of a digraph in post-order.</fsummary> - <type> - <v>Digraph = digraph()</v> - <v>Vertices = [vertex()]</v> - </type> <desc> - <p>Returns all vertices of the digraph <c>Digraph</c>. The + <p>Returns all vertices of the digraph <c><anno>Digraph</anno></c>. The order is given by a <seealso marker="#depth_first_traversal">depth-first traversal</seealso> of the digraph, collecting visited @@ -266,14 +239,10 @@ </desc> </func> <func> - <name>preorder(Digraph) -> Vertices</name> + <name name="preorder" arity="1"/> <fsummary>Return the vertices of a digraph in pre-order.</fsummary> - <type> - <v>Digraph = digraph()</v> - <v>Vertices = [vertex()]</v> - </type> <desc> - <p>Returns all vertices of the digraph <c>Digraph</c>. The + <p>Returns all vertices of the digraph <c><anno>Digraph</anno></c>. The order is given by a <seealso marker="#depth_first_traversal">depth-first traversal</seealso> of the digraph, collecting visited @@ -281,119 +250,94 @@ </desc> </func> <func> - <name>reachable(Vertices, Digraph) -> Vertices</name> + <name name="reachable" arity="2"/> <fsummary>Return the vertices reachable from some vertices of a digraph.</fsummary> - <type> - <v>Digraph = digraph()</v> - <v>Vertices = [vertex()]</v> - </type> <desc> <p>Returns an unsorted list of digraph vertices such that for each vertex in the list, there is - a <seealso marker="#path">path</seealso> in <c>Digraph</c> from some - vertex of <c>Vertices</c> to the vertex. In particular, + a <seealso marker="#path">path</seealso> in <c><anno>Digraph</anno></c> from some + vertex of <c><anno>Vertices</anno></c> to the vertex. In particular, since paths may have length zero, the vertices of - <c>Vertices</c> are included in the returned list. + <c><anno>Vertices</anno></c> are included in the returned list. </p> </desc> </func> <func> - <name>reachable_neighbours(Vertices, Digraph) -> Vertices</name> + <name name="reachable_neighbours" arity="2"/> <fsummary>Return the neighbours reachable from some vertices of a digraph.</fsummary> - <type> - <v>Digraph = digraph()</v> - <v>Vertices = [vertex()]</v> - </type> <desc> <p>Returns an unsorted list of digraph vertices such that for each vertex in the list, there is - a <seealso marker="#path">path</seealso> in <c>Digraph</c> of length - one or more from some vertex of <c>Vertices</c> to the + a <seealso marker="#path">path</seealso> in <c><anno>Digraph</anno></c> of length + one or more from some vertex of <c><anno>Vertices</anno></c> to the vertex. As a consequence, only those vertices - of <c>Vertices</c> that are included in + of <c><anno>Vertices</anno></c> that are included in some <seealso marker="#cycle">cycle</seealso> are returned. </p> </desc> </func> <func> - <name>reaching(Vertices, Digraph) -> Vertices</name> + <name name="reaching" arity="2"/> <fsummary>Return the vertices that reach some vertices of a digraph.</fsummary> - <type> - <v>Digraph = digraph()</v> - <v>Vertices = [vertex()]</v> - </type> <desc> <p>Returns an unsorted list of digraph vertices such that for each vertex in the list, there is a <seealso marker="#path">path</seealso> from the vertex to some - vertex of <c>Vertices</c>. In particular, since paths may have - length zero, the vertices of <c>Vertices</c> are included in + vertex of <c><anno>Vertices</anno></c>. In particular, since paths may have + length zero, the vertices of <c><anno>Vertices</anno></c> are included in the returned list. </p> </desc> </func> <func> - <name>reaching_neighbours(Vertices, Digraph) -> Vertices</name> + <name name="reaching_neighbours" arity="2"/> <fsummary>Return the neighbours that reach some vertices of a digraph.</fsummary> - <type> - <v>Digraph = digraph()</v> - <v>Vertices = [vertex()]</v> - </type> <desc> <p>Returns an unsorted list of digraph vertices such that for each vertex in the list, there is a <seealso marker="#path">path</seealso> of length one or more - from the vertex to some vertex of <c>Vertices</c>. As a consequence, - only those vertices of <c>Vertices</c> that are included in + from the vertex to some vertex of <c><anno>Vertices</anno></c>. As a consequence, + only those vertices of <c><anno>Vertices</anno></c> that are included in some <seealso marker="#cycle">cycle</seealso> are returned. </p> </desc> </func> <func> - <name>strong_components(Digraph) -> [StrongComponent]</name> + <name name="strong_components" arity="1"/> <fsummary>Return the strong components of a digraph.</fsummary> - <type> - <v>Digraph = digraph()</v> - <v>StrongComponent = [vertex()]</v> - </type> <desc> <p>Returns a list of <seealso marker="#strong_components">strongly connected components</seealso>. Each strongly component is represented by its vertices. The order of the vertices and the order of the components are arbitrary. Each vertex of the digraph - <c>Digraph</c> occurs in exactly one strong component. + <c><anno>Digraph</anno></c> occurs in exactly one strong component. </p> </desc> </func> <func> - <name>subgraph(Digraph, Vertices [, Options]) -> Subgraph</name> + <name name="subgraph" arity="2"/> + <name name="subgraph" arity="3"/> <fsummary>Return a subgraph of a digraph.</fsummary> - <type> - <v>Digraph = Subgraph = digraph()</v> - <v>Options = [{type, SubgraphType}, {keep_labels, bool()}]</v> - <v>SubgraphType = inherit | type()</v> - <v>Vertices = [vertex()]</v> - </type> <desc> <p>Creates a maximal <seealso marker="#subgraph">subgraph</seealso> of <c>Digraph</c> having - as vertices those vertices of <c>Digraph</c> that are - mentioned in <c>Vertices</c>. + as vertices those vertices of <c><anno>Digraph</anno></c> that are + mentioned in <c><anno>Vertices</anno></c>. </p> <p>If the value of the option <c>type</c> is <c>inherit</c>, - which is the default, then the type of <c>Digraph</c> is used + which is the default, then the type of <c><anno>Digraph</anno></c> is used for the subgraph as well. Otherwise the option value of <c>type</c> is used as argument to <c>digraph:new/1</c>. </p> <p>If the value of the option <c>keep_labels</c> is <c>true</c>, which is the default, then the <seealso marker="#label">labels</seealso> of vertices and edges - of <c>Digraph</c> are used for the subgraph as well. If the value + of <c><anno>Digraph</anno></c> are used for the subgraph as well. If the value is <c>false</c>, then the default label, <c>[]</c>, is used for the subgraph's vertices and edges. </p> - <p><c>subgraph(Digraph, Vertices)</c> is equivalent to - <c>subgraph(Digraph, Vertices, [])</c>. + <p><c>subgraph(<anno>Digraph</anno>, <anno>Vertices</anno>)</c> is equivalent to + <c>subgraph(<anno>Digraph</anno>, <anno>Vertices</anno>, [])</c>. </p> <p>There will be a <c>badarg</c> exception if any of the arguments are invalid. @@ -401,16 +345,12 @@ </desc> </func> <func> - <name>topsort(Digraph) -> Vertices | false</name> + <name name="topsort" arity="1"/> <fsummary>Return a topological sorting of the vertices of a digraph.</fsummary> - <type> - <v>Digraph = digraph()</v> - <v>Vertices = [vertex()]</v> - </type> <desc> <p>Returns a <seealso marker="#topsort">topological ordering</seealso> of the vertices of the digraph - <c>Digraph</c> if such an ordering exists, <c>false</c> + <c><anno>Digraph</anno></c> if such an ordering exists, <c>false</c> otherwise. For each vertex in the returned list, there are no <seealso marker="#out_neighbour">out-neighbours</seealso> that occur earlier in the list.</p> diff --git a/lib/stdlib/doc/src/epp.xml b/lib/stdlib/doc/src/epp.xml index e6b48b270a..488499581f 100644 --- a/lib/stdlib/doc/src/epp.xml +++ b/lib/stdlib/doc/src/epp.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2010</year> + <year>1996</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -38,65 +38,61 @@ by <c>compile</c> to preprocess macros and include files before the actual parsing takes place.</p> </description> + <datatypes> + <datatype> + <name name="macros"></name> + </datatype> + <datatype> + <name name="epp_handle"></name> + <desc><p>Handle to the epp server.</p></desc> + </datatype> + </datatypes> <funcs> <func> - <name>open(FileName, IncludePath) -> {ok,Epp} | {error, ErrorDescriptor}</name> - <name>open(FileName, IncludePath, PredefMacros) -> {ok,Epp} | {error, ErrorDescriptor}</name> + <name name="open" arity="2"/> + <name name="open" arity="3"/> <fsummary>Open a file for preprocessing</fsummary> - <type> - <v>FileName = atom() | string()</v> - <v>IncludePath = [DirectoryName]</v> - <v>DirectoryName = atom() | string()</v> - <v>PredefMacros = [{atom(),term()}]</v> - <v>Epp = pid() -- handle to the epp server</v> - <v>ErrorDescriptor = term()</v> - </type> <desc> <p>Opens a file for preprocessing.</p> </desc> </func> <func> - <name>close(Epp) -> ok</name> + <name name="close" arity="1"/> <fsummary>Close the preprocessing of the file associated with <c>Epp</c></fsummary> - <type> - <v>Epp = pid() -- handle to the epp server</v> - </type> <desc> <p>Closes the preprocessing of a file.</p> </desc> </func> <func> - <name>parse_erl_form(Epp) -> {ok, AbsForm} | {eof, Line} | {error, ErrorInfo}</name> + <name name="parse_erl_form" arity="1"/> <fsummary>Return the next Erlang form from the opened Erlang source file</fsummary> - <type> - <v>Epp = pid()</v> - <v>AbsForm = term()</v> - <v>Line = integer()</v> - <v>ErrorInfo = see separate description below.</v> - </type> <desc> <p>Returns the next Erlang form from the opened Erlang source file. - The tuple <c>{eof, Line}</c> is returned at end-of-file. The first + The tuple <c>{eof, <anno>Line</anno>}</c> is returned at end-of-file. The first form corresponds to an implicit attribute <c>-file(File,1).</c>, where <c>File</c> is the name of the file.</p> </desc> </func> <func> - <name>parse_file(FileName,IncludePath,PredefMacro) -> {ok,[Form]} | {error,OpenError}</name> - <fsummary>Preprocesse and parse an Erlang source file</fsummary> - <type> - <v>FileName = atom() | string()</v> - <v>IncludePath = [DirectoryName]</v> - <v>DirectoryName = atom() | string()</v> - <v>PredefMacros = [{atom(),term()}]</v> - <v>Form = term() -- same as returned by erl_parse:parse_form</v> - </type> + <name name="parse_file" arity="3"/> + <fsummary>Preprocess and parse an Erlang source file</fsummary> <desc> <p>Preprocesses and parses an Erlang source file. - Note that the tuple <c>{eof, Line}</c> returned at end-of-file is + Note that the tuple <c>{eof, <anno>Line</anno>}</c> returned at end-of-file is included as a "form".</p> </desc> </func> + <func> + <name name="format_error" arity="1"/> + <fsummary>Format an error descriptor</fsummary> + <desc> + <p>Takes an <c><anno>ErrorDescriptor</anno></c> and returns + a string which + describes the error or warning. This function is usually + called implicitly when processing an <c>ErrorInfo</c> + structure (see below).</p> + </desc> + </func> </funcs> <section> diff --git a/lib/stdlib/doc/src/erl_eval.xml b/lib/stdlib/doc/src/erl_eval.xml index 62af23c5eb..d0622594d9 100644 --- a/lib/stdlib/doc/src/erl_eval.xml +++ b/lib/stdlib/doc/src/erl_eval.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2009</year> + <year>1996</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -36,63 +36,108 @@ <description> <p>This module provides an interpreter for Erlang expressions. The expressions are in the abstract syntax as returned by - <c>erl_parse</c>, the Erlang parser, or a call to - <c>io:parse_erl_exprs/2</c>.</p> + <seealso marker="erl_parse"><c>erl_parse</c></seealso>, + the Erlang parser, or <seealso marker="io"> + <c>io</c></seealso>.</p> </description> + <datatypes> + <datatype> + <name name="bindings"/> + </datatype> + <datatype> + <name name="binding_struct"/> + <desc><p>A binding structure.</p></desc> + </datatype> + <datatype> + <name name="expression"/> + </datatype> + <datatype> + <name name="expressions"/> + <desc><p>As returned by <seealso marker="erl_parse#parse_exprs/1"> + <c>erl_parse:parse_exprs/1</c></seealso> or + <seealso marker="io#parse_erl_exprs/2"> + <c>io:parse_erl_exprs/2</c></seealso>.</p></desc> + </datatype> + <datatype> + <name name="expression_list"/> + </datatype> + <datatype> + <name name="func_spec"/> + </datatype> + <datatype> + <name name="lfun_eval_handler"/> + </datatype> + <datatype> + <name name="lfun_value_handler"/> + </datatype> + <datatype> + <name name="local_function_handler"/> + <desc><p>Further described + <seealso marker="#local_function_handler">below.</seealso></p> + </desc> + </datatype> + <datatype> + <name name="name"/> + </datatype> + <datatype> + <name name="nlfun_handler"/> + </datatype> + <datatype> + <name name="non_local_function_handler"/> + <desc><p>Further described + <seealso marker="#non_local_function_handler">below.</seealso></p> + </desc> + </datatype> + <datatype> + <name name="value"/> + </datatype> + </datatypes> <funcs> <func> - <name>exprs(Expressions, Bindings) -> {value, Value, NewBindings}</name> - <name>exprs(Expressions, Bindings, LocalFunctionHandler) -> {value, Value, NewBindings}</name> - <name>exprs(Expressions, Bindings, LocalFunctionHandler, NonlocalFunctionHandler) -> {value, Value, NewBindings}</name> + <name name="exprs" arity="2"/> + <name name="exprs" arity="3"/> + <name name="exprs" arity="4"/> <fsummary>Evaluate expressions</fsummary> - <type> - <v>Expressions = as returned by erl_parse or io:parse_erl_exprs/2</v> - <v>Bindings = as returned by bindings/1</v> - <v>LocalFunctionHandler = {value, Func} | {eval, Func} | none</v> - <v>NonlocalFunctionHandler = {value, Func} | none</v> - </type> <desc> - <p>Evaluates <c>Expressions</c> with the set of bindings - <c>Bindings</c>, where <c>Expressions</c> is a sequence of + <p>Evaluates <c><anno>Expressions</anno></c> with the set of bindings + <c><anno>Bindings</anno></c>, where <c><anno>Expressions</anno></c> + is a sequence of expressions (in abstract syntax) of a type which may be - returned by <c>io:parse_erl_exprs/2</c>. See below for an + returned by <seealso marker="io#parse_erl_exprs/2"> + <c>io:parse_erl_exprs/2</c></seealso>. See below for an explanation of how and when to use the arguments - <c>LocalFunctionHandler</c> and <c>NonlocalFunctionHandler</c>. + <c><anno>LocalFunctionHandler</anno></c> and + <c><anno>NonLocalFunctionHandler</anno></c>. </p> - <p>Returns <c>{value, Value, NewBindings}</c></p> + <p>Returns <c>{value, <anno>Value</anno>, <anno>NewBindings</anno>}</c> + </p> </desc> </func> <func> - <name>expr(Expression, Bindings) -> { value, Value, NewBindings }</name> - <name>expr(Expression, Bindings, LocalFunctionHandler) -> { value, Value, NewBindings }</name> - <name>expr(Expression, Bindings, LocalFunctionHandler, NonlocalFunctionHandler) -> { value, Value, NewBindings }</name> - <name>expr(Expression, Bindings, LocalFunctionHandler, NonlocalFunctionHandler, ReturnFormat) -> { value, Value, NewBindings } | Value</name> + <name name="expr" arity="2"/> + <name name="expr" arity="3"/> + <name name="expr" arity="4"/> + <name name="expr" arity="5"/> <fsummary>Evaluate expression</fsummary> - <type> - <v>Expression = as returned by io:parse_erl_form/2, for example</v> - <v>Bindings = as returned by bindings/1</v> - <v>LocalFunctionHandler = {value, Func} | {eval, Func} | none</v> - <v>NonlocalFunctionHandler = {value, Func} | none</v> - <v>ReturnFormat = value | none</v> - </type> <desc> - <p>Evaluates <c>Expression</c> with the set of bindings - <c>Bindings</c>. <c>Expression</c> is an expression (in - abstract syntax) of a type which may be returned by - <c>io:parse_erl_form/2</c>. See below for an explanation of + <p>Evaluates <c><anno>Expression</anno></c> with the set of bindings + <c><anno>Bindings</anno></c>. <c><anno>Expression</anno></c> + is an expression in + abstract syntax. See below for an explanation of how and when to use the arguments - <c>LocalFunctionHandler</c> and - <c>NonlocalFunctionHandler</c>. + <c><anno>LocalFunctionHandler</anno></c> and + <c><anno>NonLocalFunctionHandler</anno></c>. </p> - <p>Returns <c>{value, Value, NewBindings}</c> by default. But - if the <c>ReturnFormat</c> is <c>value</c> only the <c>Value</c> - is returned.</p> + <p>Returns <c>{value, <anno>Value</anno>, + <anno>NewBindings</anno>}</c> by default. But if the + <c><anno>ReturnFormat</anno></c> is <c>value</c> only + the <c><anno>Value</anno></c> is returned.</p> </desc> </func> <func> - <name>expr_list(ExpressionList, Bindings) -> {ValueList, NewBindings}</name> - <name>expr_list(ExpressionList, Bindings, LocalFunctionHandler) -> {ValueList, NewBindings}</name> - <name>expr_list(ExpressionList, Bindings, LocalFunctionHandler, NonlocalFunctionHandler) -> {ValueList, NewBindings}</name> + <name name="expr_list" arity="2"/> + <name name="expr_list" arity="3"/> + <name name="expr_list" arity="4"/> <fsummary>Evaluate a list of expressions</fsummary> <desc> <p>Evaluates a list of expressions in parallel, using the same @@ -100,18 +145,19 @@ merge the bindings returned from each evaluation. This function is useful in the <c>LocalFunctionHandler</c>. See below. </p> - <p>Returns <c>{ValueList, NewBindings}</c>.</p> + <p>Returns <c>{<anno>ValueList</anno>, <anno>NewBindings</anno>}</c>. + </p> </desc> </func> <func> - <name>new_bindings() -> BindingStruct</name> + <name name="new_bindings" arity="0"/> <fsummary>Return a bindings structure</fsummary> <desc> <p>Returns an empty binding structure.</p> </desc> </func> <func> - <name>bindings(BindingStruct) -> Bindings</name> + <name name="bindings" arity="1"/> <fsummary>Return bindings</fsummary> <desc> <p>Returns the list of bindings contained in the binding @@ -119,25 +165,28 @@ </desc> </func> <func> - <name>binding(Name, BindingStruct) -> Binding</name> + <name name="binding" arity="2"/> <fsummary>Return bindings</fsummary> <desc> - <p>Returns the binding of <c>Name</c> in <c>BindingStruct</c>.</p> + <p>Returns the binding of <c><anno>Name</anno></c> + in <c><anno>BindingStruct</anno></c>.</p> </desc> </func> <func> - <name>add_binding(Name, Value, Bindings) -> BindingStruct</name> + <name name="add_binding" arity="3"/> <fsummary>Add a binding</fsummary> <desc> - <p>Adds the binding <c>Name = Value</c> to <c>Bindings</c>. + <p>Adds the binding <c><anno>Name</anno> = <anno>Value</anno></c> + to <c><anno>BindingStruct</anno></c>. Returns an updated binding structure.</p> </desc> </func> <func> - <name>del_binding(Name, Bindings) -> BindingStruct</name> + <name name="del_binding" arity="2"/> <fsummary>Delete a binding</fsummary> <desc> - <p>Removes the binding of <c>Name</c> in <c>Bindings</c>. + <p>Removes the binding of <c><anno>Name</anno></c> + in <c><anno>BindingStruct</anno></c>. Returns an updated binding structure.</p> </desc> </func> @@ -145,7 +194,8 @@ <section> <title>Local Function Handler</title> - <p>During evaluation of a function, no calls can be made to local + <p><marker id="local_function_handler"></marker> + During evaluation of a function, no calls can be made to local functions. An undefined function error would be generated. However, the optional argument <c>LocalFunctionHandler</c> may be used to define a function @@ -191,7 +241,8 @@ Func(Name, Arguments, Bindings) </code> <section> <title>Non-local Function Handler</title> - <p>The optional argument <c>NonlocalFunctionHandler</c> may be + <p><marker id="non_local_function_handler"></marker> + The optional argument <c>NonlocalFunctionHandler</c> may be used to define a function which is called in the following cases: a functional object (fun) is called; a built-in function is called; a function is called using the M:F syntax, where M diff --git a/lib/stdlib/doc/src/erl_expand_records.xml b/lib/stdlib/doc/src/erl_expand_records.xml index 7fb03e7c50..8ead438b31 100644 --- a/lib/stdlib/doc/src/erl_expand_records.xml +++ b/lib/stdlib/doc/src/erl_expand_records.xml @@ -5,7 +5,7 @@ <header> <copyright> <year>2005</year> - <year>2007</year> + <year>2011</year> <holder>Ericsson AB, All Rights Reserved</holder> </copyright> <legalnotice> @@ -39,12 +39,8 @@ </description> <funcs> <func> - <name>module(AbsForms, CompileOptions) -> AbsForms</name> + <name name="module" arity="2"/> <fsummary>Expand all records in a module</fsummary> - <type> - <v>AbsForms = [term()]</v> - <v>CompileOptions = [term()]</v> - </type> <desc> <p>Expands all records in a module. The returned module has no references to records, neither attributes nor code.</p> diff --git a/lib/stdlib/doc/src/erl_id_trans.xml b/lib/stdlib/doc/src/erl_id_trans.xml index 7c821d2efc..18cc2460f9 100644 --- a/lib/stdlib/doc/src/erl_id_trans.xml +++ b/lib/stdlib/doc/src/erl_id_trans.xml @@ -5,7 +5,7 @@ <header> <copyright> <year>1996</year> - <year>2007</year> + <year>2011</year> <holder>Ericsson AB, All Rights Reserved</holder> </copyright> <legalnotice> @@ -48,8 +48,8 @@ <name>parse_transform(Forms, Options) -> Forms</name> <fsummary>Transform Erlang forms</fsummary> <type> - <v>Forms = [erlang_form()]</v> - <v>Options = [compiler_options()]</v> + <v>Forms = [<seealso marker="erl_parse#type-abstract_form">erl_parse:abstract_form()</seealso>]</v> + <v>Options = [<seealso marker="compile#type-option">compile:option()</seealso>]</v> </type> <desc> <p>Performs an identity transformation on Erlang forms, as an example.</p> @@ -70,7 +70,8 @@ <section> <title>See Also</title> - <p><seealso marker="erl_parse">erl_parse(3)</seealso>, compile(3).</p> + <p><seealso marker="erl_parse">erl_parse(3)</seealso>, + <seealso marker="compiler:compile">compile(3)</seealso>.</p> </section> </erlref> diff --git a/lib/stdlib/doc/src/erl_internal.xml b/lib/stdlib/doc/src/erl_internal.xml index 906b95deb7..b8d5ad73b3 100644 --- a/lib/stdlib/doc/src/erl_internal.xml +++ b/lib/stdlib/doc/src/erl_internal.xml @@ -5,7 +5,7 @@ <header> <copyright> <year>1996</year> - <year>2007</year> + <year>2011</year> <holder>Ericsson AB, All Rights Reserved</holder> </copyright> <legalnotice> @@ -42,112 +42,75 @@ </description> <funcs> <func> - <name>bif(Name, Arity) -> bool()</name> + <name name="bif" arity="2"/> <fsummary>Test for an Erlang BIF</fsummary> - <type> - <v>Name = atom()</v> - <v>Arity = integer()</v> - </type> <desc> - <p>Returns <c>true</c> if <c>Name/Arity</c> is an Erlang BIF + <p>Returns <c>true</c> if <c><anno>Name</anno>/<anno>Arity</anno></c> is an Erlang BIF which is automatically recognized by the compiler, otherwise <c>false</c>.</p> </desc> </func> <func> - <name>guard_bif(Name, Arity) -> bool()</name> + <name name="guard_bif" arity="2"/> <fsummary>Test for an Erlang BIF allowed in guards</fsummary> - <type> - <v>Name = atom()</v> - <v>Arity = integer()</v> - </type> <desc> - <p>Returns <c>true</c> if <c>Name/Arity</c> is an Erlang BIF + <p>Returns <c>true</c> if <c><anno>Name</anno>/<anno>Arity</anno></c> is an Erlang BIF which is allowed in guards, otherwise <c>false</c>.</p> </desc> </func> <func> - <name>type_test(Name, Arity) -> bool()</name> + <name name="type_test" arity="2"/> <fsummary>Test for a valid type test</fsummary> - <type> - <v>Name = atom()</v> - <v>Arity = integer()</v> - </type> <desc> - <p>Returns <c>true</c> if <c>Name/Arity</c> is a valid Erlang + <p>Returns <c>true</c> if <c><anno>Name</anno>/<anno>Arity</anno></c> is a valid Erlang type test, otherwise <c>false</c>.</p> </desc> </func> <func> - <name>arith_op(OpName, Arity) -> bool()</name> + <name name="arith_op" arity="2"/> <fsummary>Test for an arithmetic operator</fsummary> - <type> - <v>OpName = atom()</v> - <v>Arity = integer()</v> - </type> <desc> - <p>Returns <c>true</c> if <c>OpName/Arity</c> is an arithmetic + <p>Returns <c>true</c> if <c><anno>OpName</anno>/<anno>Arity</anno></c> is an arithmetic operator, otherwise <c>false</c>.</p> </desc> </func> <func> - <name>bool_op(OpName, Arity) -> bool()</name> + <name name="bool_op" arity="2"/> <fsummary>Test for a Boolean operator</fsummary> - <type> - <v>OpName = atom()</v> - <v>Arity = integer()</v> - </type> <desc> - <p>Returns <c>true</c> if <c>OpName/Arity</c> is a Boolean + <p>Returns <c>true</c> if <c><anno>OpName</anno>/<anno>Arity</anno></c> is a Boolean operator, otherwise <c>false</c>.</p> </desc> </func> <func> - <name>comp_op(OpName, Arity) -> bool()</name> + <name name="comp_op" arity="2"/> <fsummary>Test for a comparison operator</fsummary> - <type> - <v>OpName = atom()</v> - <v>Arity = integer()</v> - </type> <desc> - <p>Returns <c>true</c> if <c>OpName/Arity</c> is a comparison + <p>Returns <c>true</c> if <c><anno>OpName</anno>/<anno>Arity</anno></c> is a comparison operator, otherwise <c>false</c>.</p> </desc> </func> <func> - <name>list_op(OpName, Arity) -> bool()</name> + <name name="list_op" arity="2"/> <fsummary>Test for a list operator</fsummary> - <type> - <v>OpName = atom()</v> - <v>Arity = integer()</v> - </type> <desc> - <p>Returns <c>true</c> if <c>OpName/Arity</c> is a list + <p>Returns <c>true</c> if <c><anno>OpName</anno>/<anno>Arity</anno></c> is a list operator, otherwise <c>false</c>.</p> </desc> </func> <func> - <name>send_op(OpName, Arity) -> bool()</name> + <name name="send_op" arity="2"/> <fsummary>Test for a send operator</fsummary> - <type> - <v>OpName = atom()</v> - <v>Arity = integer()</v> - </type> <desc> - <p>Returns <c>true</c> if <c>OpName/Arity</c> is a send + <p>Returns <c>true</c> if <c><anno>OpName</anno>/<anno>Arity</anno></c> is a send operator, otherwise <c>false</c>.</p> </desc> </func> <func> - <name>op_type(OpName, Arity) -> Type</name> + <name name="op_type" arity="2"/> <fsummary>Return operator type</fsummary> - <type> - <v>OpName = atom()</v> - <v>Arity = integer()</v> - <v>Type = arith | bool | comp | list | send</v> - </type> <desc> - <p>Returns the <c>Type</c> of operator that <c>OpName/Arity</c> + <p>Returns the <c><anno>Type</anno></c> of operator that <c><anno>OpName</anno>/<anno>Arity</anno></c> belongs to, or generates a <c>function_clause</c> error if it is not an operator at all.</p> diff --git a/lib/stdlib/doc/src/erl_lint.xml b/lib/stdlib/doc/src/erl_lint.xml index 6a7d37765c..b7fbdd8799 100644 --- a/lib/stdlib/doc/src/erl_lint.xml +++ b/lib/stdlib/doc/src/erl_lint.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2010</year> + <year>1996</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -60,29 +60,30 @@ functions separately unless you have written your own Erlang compiler.</p> </description> + <datatypes> + <datatype> + <name name="error_info"/> + </datatype> + <datatype> + <name name="error_description"/> + </datatype> + </datatypes> <funcs> <func> - <name>module(AbsForms) -> {ok,Warnings} | {error,Errors,Warnings}</name> - <name>module(AbsForms, FileName) -> {ok,Warnings} | {error,Errors,Warnings}</name> - <name>module(AbsForms, FileName, CompileOptions) -> {ok,Warnings} | {error,Errors,Warnings}</name> + <name name="module" arity="1"/> + <name name="module" arity="2"/> + <name name="module" arity="3"/> <fsummary>Check a module for errors</fsummary> - <type> - <v>AbsForms = [term()]</v> - <v>FileName = FileName2 = atom() | string()</v> - <v>Warnings = Errors = [{Filename2,[ErrorInfo]}]</v> - <v>ErrorInfo = see separate description below.</v> - <v>CompileOptions = [term()]</v> - </type> <desc> <p>This function checks all the forms in a module for errors. It returns: </p> <taglist> - <tag><c>{ok,Warnings}</c></tag> + <tag><c>{ok,<anno>Warnings</anno>}</c></tag> <item> <p>There were no errors in the module.</p> </item> - <tag><c>{error,Errors,Warnings}</c></tag> + <tag><c>{error,<anno>Errors</anno>,<anno>Warnings</anno>}</c></tag> <item> <p>There were errors in the module.</p> </item> @@ -93,14 +94,14 @@ elements of <c>Options</c> that control the warnings are only described in <seealso marker="compiler:compile#erl_lint_options">compile(3)</seealso>. </p> - <p>The <c>AbsForms</c> of a module which comes from a file + <p>The <c><anno>AbsForms</anno></c> of a module which comes from a file that is read through <c>epp</c>, the Erlang pre-processor, can come from many files. This means that any references to - errors must include the file name (see <seealso marker="epp">epp(3)</seealso>, or parser <seealso marker="erl_parse">erl_parse(3)</seealso> The warnings and - errors returned have the following format: + errors must include the file name (see <seealso marker="epp">epp(3)</seealso>, or parser <seealso marker="erl_parse">erl_parse(3)</seealso>). + The warnings and errors returned have the following format: </p> <code type="none"> - [{FileName2,[ErrorInfo]}] </code> + [{<anno>FileName2</anno>,[<anno>ErrorInfo</anno>]}] </code> <p>The errors and warnings are listed in the order in which they are encountered in the forms. This means that the errors from one file may be split into different entries in @@ -108,27 +109,20 @@ </desc> </func> <func> - <name>is_guard_test(Expr) -> bool()</name> + <name name="is_guard_test" arity="1"/> <fsummary>Test for a guard test</fsummary> - <type> - <v>Expr = term()</v> - </type> <desc> - <p>This function tests if <c>Expr</c> is a legal guard test. - <c>Expr</c> is an Erlang term representing the abstract form + <p>This function tests if <c><anno>Expr</anno></c> is a legal guard test. + <c><anno>Expr</anno></c> is an Erlang term representing the abstract form for the expression. <c>erl_parse:parse_exprs(Tokens)</c> can - be used to generate a list of <c>Expr</c>.</p> + be used to generate a list of <c><anno>Expr</anno></c>.</p> </desc> </func> <func> - <name>format_error(ErrorDescriptor) -> Chars</name> + <name name="format_error" arity="1"/> <fsummary>Format an error descriptor</fsummary> - <type> - <v>ErrorDescriptor = errordesc()</v> - <v>Chars = [char() | Chars]</v> - </type> <desc> - <p>Takes an <c>ErrorDescriptor</c> and returns a string which + <p>Takes an <c><anno>ErrorDescriptor</anno></c> and returns a string which describes the error or warning. This function is usually called implicitly when processing an <c>ErrorInfo</c> structure (see below).</p> diff --git a/lib/stdlib/doc/src/erl_parse.xml b/lib/stdlib/doc/src/erl_parse.xml index ae8a8afd5c..bafc2e0746 100644 --- a/lib/stdlib/doc/src/erl_parse.xml +++ b/lib/stdlib/doc/src/erl_parse.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2010</year> + <year>1996</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -36,31 +36,51 @@ <description> <p>This module is the basic Erlang parser which converts tokens into the abstract form of either forms (i.e., top-level constructs), - expressions, or terms. The Abstract Format is described in the ERTS - User's Guide. + expressions, or terms. The Abstract Format is described in the + <seealso marker="erts:absform">ERTS User's Guide</seealso>. Note that a token list must end with the <em>dot</em> token in order - to be acceptable to the parse functions (see erl_scan).</p> + to be acceptable to the parse functions (see <seealso marker="erl_scan">erl_scan(3)</seealso>).</p> </description> + <datatypes> + <datatype> + <name name="abstract_clause"></name> + <desc><p>Parse tree for Erlang clause.</p> + </desc> + </datatype> + <datatype> + <name name="abstract_expr"></name> + <desc><p>Parse tree for Erlang expression.</p> + </desc> + </datatype> + <datatype> + <name name="abstract_form"></name> + <desc><p>Parse tree for Erlang form.</p> + </desc> + </datatype> + <datatype> + <name name="error_description"></name> + </datatype> + <datatype> + <name name="error_info"></name> + </datatype> + <datatype> + <name name="token"></name> + </datatype> + </datatypes> <funcs> <func> - <name>parse_form(Tokens) -> {ok, AbsForm} | {error, ErrorInfo}</name> + <name name="parse_form" arity="1"/> <fsummary>Parse an Erlang form</fsummary> - <type> - <v>Tokens = [Token]</v> - <v>Token = {Tag,Line} | {Tag,Line,term()}</v> - <v>Tag = atom()</v> - <v>AbsForm = term()</v> - <v>ErrorInfo = see section Error Information below.</v> - </type> <desc> - <p>This function parses <c>Tokens</c> as if it were a form. It returns:</p> + <p>This function parses <c><anno>Tokens</anno></c> as if it were + a form. It returns:</p> <taglist> - <tag><c>{ok, AbsForm}</c></tag> + <tag><c>{ok, <anno>AbsForm</anno>}</c></tag> <item> - <p>The parsing was successful. <c>AbsForm</c> is the + <p>The parsing was successful. <c><anno>AbsForm</anno></c> is the abstract form of the parsed form.</p> </item> - <tag><c>{error, ErrorInfo}</c></tag> + <tag><c>{error, <anno>ErrorInfo</anno>}</c></tag> <item> <p>An error occurred.</p> </item> @@ -68,25 +88,18 @@ </desc> </func> <func> - <name>parse_exprs(Tokens) -> {ok, Expr_list} | {error, ErrorInfo}</name> + <name name="parse_exprs" arity="1"/> <fsummary>Parse Erlang expressions</fsummary> - <type> - <v>Tokens = [Token]</v> - <v>Token = {Tag,Line} | {Tag,Line,term()}</v> - <v>Tag = atom()</v> - <v>Expr_list = [AbsExpr]</v> - <v>AbsExpr = term()</v> - <v>ErrorInfo = see section Error Information below.</v> - </type> <desc> - <p>This function parses <c>Tokens</c> as if it were a list of expressions. It returns:</p> + <p>This function parses <c><anno>Tokens</anno></c> as if it were + a list of expressions. It returns:</p> <taglist> - <tag><c>{ok, Expr_list}</c></tag> + <tag><c>{ok, <anno>ExprList</anno>}</c></tag> <item> - <p>The parsing was successful. <c>Expr_list</c> is a + <p>The parsing was successful. <c><anno>ExprList</anno></c> is a list of the abstract forms of the parsed expressions.</p> </item> - <tag><c>{error, ErrorInfo}</c></tag> + <tag><c>{error, <anno>ErrorInfo</anno>}</c></tag> <item> <p>An error occurred.</p> </item> @@ -94,21 +107,15 @@ </desc> </func> <func> - <name>parse_term(Tokens) -> {ok, Term} | {error, ErrorInfo}</name> + <name name="parse_term" arity="1"/> <fsummary>Parse an Erlang term</fsummary> - <type> - <v>Tokens = [Token]</v> - <v>Token = {Tag,Line} | {Tag,Line,term()}</v> - <v>Tag = atom()</v> - <v>Term = term()</v> - <v>ErrorInfo = see section Error Information below.</v> - </type> <desc> - <p>This function parses <c>Tokens</c> as if it were a term. It returns:</p> + <p>This function parses <c><anno>Tokens</anno></c> as if it were + a term. It returns:</p> <taglist> - <tag><c>{ok, Term}</c></tag> + <tag><c>{ok, <anno>Term</anno>}</c></tag> <item> - <p>The parsing was successful. <c>Term</c> is + <p>The parsing was successful. <c><anno>Term</anno></c> is the Erlang term corresponding to the token list.</p> </item> <tag><c>{error, ErrorInfo}</c></tag> @@ -122,7 +129,8 @@ <name>format_error(ErrorDescriptor) -> Chars</name> <fsummary>Format an error descriptor</fsummary> <type> - <v>ErrorDescriptor = errordesc()</v> + <v>ErrorDescriptor = <seealso + marker="#type-error_info">error_description()</seealso></v> <v>Chars = [char() | Chars]</v> </type> <desc> @@ -133,44 +141,32 @@ </desc> </func> <func> - <name>tokens(AbsTerm) -> Tokens</name> - <name>tokens(AbsTerm, MoreTokens) -> Tokens</name> + <name name="tokens" arity="1"/> + <name name="tokens" arity="2"/> <fsummary>Generate a list of tokens for an expression</fsummary> - <type> - <v>Tokens = MoreTokens = [Token]</v> - <v>Token = {Tag,Line} | {Tag,Line,term()}</v> - <v>Tag = atom()</v> - <v>AbsTerm = term()</v> - <v>ErrorInfo = see section Error Information below.</v> - </type> <desc> <p>This function generates a list of tokens representing the abstract - form <c>AbsTerm</c> of an expression. Optionally, it appends - <c>Moretokens</c>.</p> + form <c><anno>AbsTerm</anno></c> of an expression. Optionally, it + appends <c><anno>MoreTokens</anno></c>.</p> </desc> </func> <func> - <name>normalise(AbsTerm) -> Data</name> + <name name="normalise" arity="1"/> <fsummary>Convert abstract form to an Erlang term</fsummary> - <type> - <v>AbsTerm = Data = term()</v> - </type> <desc> - <p>Converts the abstract form <c>AbsTerm</c> of a term into a + <p>Converts the abstract form <c><anno>AbsTerm</anno></c> of a + term into a conventional Erlang data structure (i.e., the term itself). This is the inverse of <c>abstract/1</c>.</p> </desc> </func> <func> - <name>abstract(Data) -> AbsTerm</name> + <name name="abstract" arity="1"/> <fsummary>Convert an Erlang term into an abstract form</fsummary> - <type> - <v>Data = AbsTerm = term()</v> - </type> <desc> - <p>Converts the Erlang data structure <c>Data</c> into an - abstract form of type <c>AbsTerm</c>. This is the inverse of - <c>normalise/1</c>.</p> + <p>Converts the Erlang data structure <c><anno>Data</anno></c> into an + abstract form of type <c><anno>AbsTerm</anno></c>. + This is the inverse of <c>normalise/1</c>.</p> </desc> </func> </funcs> diff --git a/lib/stdlib/doc/src/erl_pp.xml b/lib/stdlib/doc/src/erl_pp.xml index 6b15c5afd3..57b5828bcd 100644 --- a/lib/stdlib/doc/src/erl_pp.xml +++ b/lib/stdlib/doc/src/erl_pp.xml @@ -5,7 +5,7 @@ <header> <copyright> <year>1996</year> - <year>2007</year> + <year>2011</year> <holder>Ericsson AB, All Rights Reserved</holder> </copyright> <legalnotice> @@ -43,93 +43,82 @@ <p>All functions can have an optional argument which specifies a hook that is called if an attempt is made to print an unknown form.</p> </description> + <datatypes> + <datatype> + <name name="hook_function"/> + <desc> + <p>The optional argument <marker id="hook_function"> + <c>HookFunction</c></marker>, shown in the functions described below, + defines a function which is called when an unknown form occurs where there + should be a valid expression.</p> + + <p>If <c>HookFunction</c> is equal to <c>none</c> there is no hook + function.</p> + + <p>The called hook function should return a (possibly deep) list + of characters. <seealso marker="#expr/4"><c>expr/4</c></seealso> + is useful in a hook. + </p> + <p>If <c><anno>CurrentIndentation</anno></c> is negative, there will be no line + breaks and only a space is used as a separator.</p> + </desc> + </datatype> + </datatypes> <funcs> <func> - <name>form(Form) -> DeepCharList</name> - <name>form(Form, HookFunction) -> DeepCharList</name> + <name name="form" arity="1"/> + <name name="form" arity="2"/> <fsummary>Pretty print a form</fsummary> - <type> - <v>Form = term()</v> - <v>HookFunction = see separate description below.</v> - <v>DeepCharList = [char()|DeepCharList]</v> - </type> <desc> <p>Pretty prints a - <c>Form</c> which is an abstract form of a type which is - returned by <c>erl_parse:parse_form</c>.</p> + <c><anno>Form</anno></c> which is an abstract form of a type which is + returned by <seealso marker="erl_parse#parse_form/1"> + <c>erl_parse:parse_form/1</c></seealso>.</p> </desc> </func> <func> - <name>attribute(Attribute) -> DeepCharList</name> - <name>attribute(Attribute, HookFunction) -> DeepCharList</name> + <name name="attribute" arity="1"/> + <name name="attribute" arity="2"/> <fsummary>Pretty print an attribute</fsummary> - <type> - <v>Attribute = term()</v> - <v>HookFunction = see separate description below.</v> - <v>DeepCharList = [char()|DeepCharList]</v> - </type> <desc> <p>The same as <c>form</c>, but only for the attribute - <c>Attribute</c>.</p> + <c><anno>Attribute</anno></c>.</p> </desc> </func> <func> - <name>function(Function) -> DeepCharList</name> - <name>function(Function, HookFunction) -> DeepCharList</name> + <name name="function" arity="1"/> + <name name="function" arity="2"/> <fsummary>Pretty print a function</fsummary> - <type> - <v>Function = term()</v> - <v>HookFunction = see separate description below.</v> - <v>DeepCharList = [char()|DeepCharList]</v> - </type> <desc> <p>The same as <c>form</c>, but only for the function - <c>Function</c>.</p> + <c><anno>Function</anno></c>.</p> </desc> </func> <func> - <name>guard(Guard) -> DeepCharList</name> - <name>guard(Guard, HookFunction) -> DeepCharList</name> + <name name="guard" arity="1"/> + <name name="guard" arity="2"/> <fsummary>Pretty print a guard</fsummary> - <type> - <v>Form = term()</v> - <v>HookFunction = see separate description below.</v> - <v>DeepCharList = [char()|DeepCharList]</v> - </type> <desc> <p>The same as <c>form</c>, but only for the guard test - <c>Guard</c>.</p> + <c><anno>Guard</anno></c>.</p> </desc> </func> <func> - <name>exprs(Expressions) -> DeepCharList</name> - <name>exprs(Expressions, HookFunction) -> DeepCharList</name> - <name>exprs(Expressions, Indent, HookFunction) -> DeepCharList</name> + <name name="exprs" arity="1"/> + <name name="exprs" arity="2"/> + <name name="exprs" arity="3"/> <fsummary>Pretty print <c>Expressions</c></fsummary> - <type> - <v>Expressions = term()</v> - <v>HookFunction = see separate description below.</v> - <v>Indent = integer()</v> - <v>DeepCharList = [char()|DeepCharList]</v> - </type> <desc> <p>The same as <c>form</c>, but only for the sequence of - expressions in <c>Expressions</c>.</p> + expressions in <c><anno>Expressions</anno></c>.</p> </desc> </func> <func> - <name>expr(Expression) -> DeepCharList</name> - <name>expr(Expression, HookFunction) -> DeepCharList</name> - <name>expr(Expression, Indent, HookFunction) -> DeepCharList</name> - <name>expr(Expression, Indent, Precedence, HookFunction) ->-> DeepCharList</name> + <name name="expr" arity="1"/> + <name name="expr" arity="2"/> + <name name="expr" arity="3"/> + <name name="expr" arity="4"/> <fsummary>Pretty print one <c>Expression</c></fsummary> - <type> - <v>Expression = term()</v> - <v>HookFunction = see separate description below.</v> - <v>Indent = integer()</v> - <v>Precedence = </v> - <v>DeepCharList = [char()|DeepCharList]</v> - </type> <desc> <p>This function prints one expression. It is useful for implementing hooks (see below).</p> </desc> @@ -137,32 +126,6 @@ </funcs> <section> - <title>Unknown Expression Hooks</title> - <p>The optional argument <c>HookFunction</c>, shown in the functions described above, defines a function which is called when an unknown form occurs where there - should be a valid expression. It can have the following formats:</p> - <taglist> - <tag><c>Function</c></tag> - <item> - <p>The hook function is called by:</p> - <code type="none"> -Function(Expr, - CurrentIndentation, - CurrentPrecedence, - HookFunction) </code> - </item> - <tag><c>none</c></tag> - <item> - <p>There is no hook function</p> - </item> - </taglist> - <p>The called hook function should return a (possibly deep) list - of characters. <c>expr/4</c> is useful in a hook. - </p> - <p>If <c>CurrentIndentation</c> is negative, there will be no line - breaks and only a space is used as a separator.</p> - </section> - - <section> <title>Bugs</title> <p>It should be possible to have hook functions for unknown forms at places other than expressions.</p> diff --git a/lib/stdlib/doc/src/erl_scan.xml b/lib/stdlib/doc/src/erl_scan.xml index 4175146c3c..54240dea19 100644 --- a/lib/stdlib/doc/src/erl_scan.xml +++ b/lib/stdlib/doc/src/erl_scan.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2009</year> + <year>1996</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>erl_scan</title> @@ -37,56 +37,96 @@ <p>This module contains functions for tokenizing characters into Erlang tokens.</p> </description> - <section> - <title>DATA TYPES</title> - <code type="none"> -category() = atom() -column() = integer() > 0 -line() = integer() -location() = line() | {line(), column()} -reserved_word_fun() -> fun(atom()) -> bool() -set_attribute_fun() -> fun(term()) -> term() -symbol() = atom() | float() | integer() | string() -token() = {category(), attributes()} | {category(), attributes(), symbol()} -attributes() = line() | list() | tuple()</code> - </section> + <datatypes> + <datatype> + <name name="attribute_info"></name> + </datatype> + <datatype> + <name name="attributes"></name> + </datatype> + <datatype> + <name name="attributes_data"></name> + </datatype> + <datatype> + <name name="category"></name> + </datatype> + <datatype> + <name name="column"></name> + </datatype> + <datatype> + <name name="error_description"></name> + </datatype> + <datatype> + <name name="error_info"></name> + </datatype> + <datatype> + <name name="info_line"></name> + </datatype> + <datatype> + <name name="info_location"></name> + </datatype> + <datatype> + <name name="line"></name> + </datatype> + <datatype> + <name name="location"></name> + </datatype> + <datatype> + <name name="option"></name> + </datatype> + <datatype> + <name name="options"></name> + </datatype> + <datatype> + <name name="symbol"></name> + </datatype> + <datatype> + <name name="resword_fun"></name> + </datatype> + <datatype> + <name name="token"></name> + </datatype> + <datatype> + <name name="token_info"></name> + </datatype> + <datatype> + <name name="tokens"></name> + </datatype> + <datatype> + <name name="tokens_result"></name> + </datatype> + </datatypes> <funcs> <func> - <name>string(String) -> Return</name> - <name>string(String, StartLocation) -> Return</name> - <name>string(String, StartLocation, Options) -> Return</name> + <name name="string" arity="1"/> + <name name="string" arity="2"/> + <name name="string" arity="3"/> <fsummary>Scan a string and return the Erlang tokens</fsummary> - <type> - <v>String = string()</v> - <v>Return = {ok, Tokens, EndLocation} | Error</v> - <v>Tokens = [token()]</v> - <v>Error = {error, ErrorInfo, EndLocation}</v> - <v>StartLocation = EndLocation = location()</v> - <v>Options = Option | [Option]</v> - <v>Option = {reserved_word_fun,reserved_word_fun()} - | return_comments | return_white_spaces | return - | text</v> - </type> <desc> - <p>Takes the list of characters <c>String</c> and tries to - scan (tokenize) them. Returns <c>{ok, Tokens, EndLocation}</c>, - where <c>Tokens</c> are the Erlang tokens from - <c>String</c>. <c>EndLocation</c> is the first location - after the last token.</p> - <p><c>{error, ErrorInfo, EndLocation}</c> is returned if an - error occurs. <c>EndLocation</c> is the first location after + <p>Takes the list of characters <c><anno>String</anno></c> and tries to + scan (tokenize) them. Returns <c>{ok, <anno>Tokens</anno>, + <anno>EndLocation</anno>}</c>, + where <c><anno>Tokens</anno></c> are the Erlang tokens from + <c><anno>String</anno></c>. <c><anno>EndLocation</anno></c> + is the first location after the last token.</p> + <p><c>{error, <anno>ErrorInfo</anno>, <anno>ErrorLocation</anno>}</c> + is returned if an error occurs. + <c><anno>ErrorLocation</anno></c> is the first location after the erroneous token.</p> - <p><c>string(String)</c> is equivalent to - <c>string(String, 1)</c>, and <c>string(String, - StartLocation)</c> is equivalent to <c>string(String, - StartLocation, [])</c>.</p> - <p><c>StartLocation</c> indicates the initial location when - scanning starts. If <c>StartLocation</c> is a line - <c>attributes()</c> as well as <c>EndLocation</c> and - <c>ErrorLocation</c> will be lines. If - <c>StartLocation</c> is a pair of a line and a column + <p><c>string(<anno>String</anno>)</c> is equivalent to + <c>string(<anno>String</anno>, 1)</c>, and + <c>string(<anno>String</anno>, + <anno>StartLocation</anno>)</c> is equivalent to + <c>string(<anno>String</anno>, + <anno>StartLocation</anno>, [])</c>.</p> + <p><c><anno>StartLocation</anno></c> indicates the initial location + when scanning starts. If <c><anno>StartLocation</anno></c> is a line + <c>attributes()</c> as well as <c><anno>EndLocation</anno></c> and + <c><anno>ErrorLocation</anno></c> will be lines. If + <c><anno>StartLocation</anno></c> is a pair of a line and a column <c>attributes()</c> takes the form of an opaque compound - data type, and <c>EndLocation</c> and <c>ErrorLocation</c> + data type, and <c><anno>EndLocation</anno></c> and + <c><anno>ErrorLocation</anno></c> will be pairs of a line and a column. The <em>token attributes</em> contain information about the column and the line where the token begins, as well as the text of the @@ -103,7 +143,7 @@ attributes() = line() | list() | tuple()</code> Info, atom()}</c>, <c>{char, Info, integer()}</c>, <c>{comment, Info, string()}</c>, <c>{float, Info, float()}</c>, <c>{integer, - Info, integer()}</c>, <c>{var, Info, atom()}</c>, + Info, integer()}</c>, <c>{var, Info, atom()}</c>, and <c>{white_space, Info, string()}</c>.</p> <p>The valid options are:</p> <taglist> @@ -134,253 +174,218 @@ attributes() = line() | list() | tuple()</code> </desc> </func> <func> - <name>tokens(Continuation, CharSpec, StartLocation) -> Return</name> - <name>tokens(Continuation, CharSpec, StartLocation, Options) -> Return</name> + <name name="tokens" arity="3"/> + <name name="tokens" arity="4"/> + <type name="char_spec"/> + <type name="return_cont"/> + <type_desc name="return_cont">An opaque continuation</type_desc> <fsummary>Re-entrant scanner</fsummary> - <type> - <v>Continuation = [] | Continuation1</v> - <v>Return = {done, Result, LeftOverChars} | {more, Continuation1}</v> - <v>LeftOverChars = CharSpec</v> - <v>CharSpec = string() | eof</v> - <v>Continuation1 = tuple()</v> - <v>Result = {ok, Tokens, EndLocation} | {eof, EndLocation} | Error</v> - <v>Tokens = [token()]</v> - <v>Error = {error, ErrorInfo, EndLocation}</v> - <v>StartLocation = EndLocation = location()</v> - <v>Options = Option | [Option]</v> - <v>Option = {reserved_word_fun,reserved_word_fun()} - | return_comments | return_white_spaces | return</v> - </type> <desc> <p>This is the re-entrant scanner which scans characters until a <em>dot</em> ('.' followed by a white space) or <c>eof</c> has been reached. It returns:</p> <taglist> - <tag><c>{done, Result, LeftOverChars}</c></tag> + <tag><c>{done, <anno>Result</anno>, <anno>LeftOverChars</anno>}</c> + </tag> <item> <p>This return indicates that there is sufficient input - data to get a result. <c>Result</c> is:</p> + data to get a result. <c><anno>Result</anno></c> is:</p> <taglist> - <tag><c>{ok, Tokens, EndLocation}</c></tag> + <tag><c>{ok, Tokens, EndLocation}</c> + </tag> <item> - <p>The scanning was successful. <c>Tokens</c> is the - list of tokens including <em>dot</em>.</p> + <p>The scanning was successful. <c>Tokens</c> + is the list of tokens including <em>dot</em>.</p> </item> <tag><c>{eof, EndLocation}</c></tag> <item> <p>End of file was encountered before any more tokens.</p> </item> - <tag><c>{error, ErrorInfo, EndLocation}</c></tag> + <tag><c>{error, ErrorInfo, EndLocation}</c> + </tag> <item> - <p>An error occurred. <c>LeftOverChars</c> is the remaining - characters of the input data, + <p>An error occurred. <c><anno>LeftOverChars</anno></c> + is the remaining characters of the input data, starting from <c>EndLocation</c>.</p> </item> </taglist> </item> - <tag><c>{more, Continuation1}</c></tag> + <tag><c>{more, <anno>Continuation1</anno>}</c></tag> <item> <p>More data is required for building a term. - <c>Continuation1</c> must be passed in a new call to + <c><anno>Continuation1</anno></c> must be passed in a new call to <c>tokens/3,4</c> when more data is available.</p> </item> </taglist> - <p>The <c>CharSpec</c> <c>eof</c> signals end of file. - <c>LeftOverChars</c> will then take the value <c>eof</c> as - well.</p> - <p><c>tokens(Continuation, CharSpec, StartLocation)</c> is - equivalent to <c>tokens(Continuation, CharSpec, - StartLocation, [])</c>.</p> + <p>The <c><anno>CharSpec</anno></c> <c>eof</c> signals end of file. + <c><anno>LeftOverChars</anno></c> will then take the value <c>eof</c> + as well.</p> + <p><c>tokens(<anno>Continuation</anno>, <anno>CharSpec</anno>, + <anno>StartLocation</anno>)</c> is equivalent to + <c>tokens(<anno>Continuation</anno>, <anno>CharSpec</anno>, + <anno>StartLocation</anno>, [])</c>.</p> <p>See <seealso marker="#string/3">string/3</seealso> for a description of the various options.</p> </desc> </func> <func> - <name>reserved_word(Atom) -> bool()</name> + <name name="reserved_word" arity="1"/> <fsummary>Test for a reserved word</fsummary> - <type> - <v>Atom = atom()</v> - </type> <desc> - <p>Returns <c>true</c> if <c>Atom</c> is an Erlang reserved - word, otherwise <c>false</c>.</p> + <p>Returns <c>true</c> if <c><anno>Atom</anno></c> is an Erlang + reserved word, otherwise <c>false</c>.</p> </desc> </func> <func> - <name>token_info(Token) -> TokenInfo</name> + <name name="token_info" arity="1"/> <fsummary>Return information about a token</fsummary> - <type> - <v>Token = token()</v> - <v>TokenInfo = [TokenInfoTuple]</v> - <v>TokenInfoTuple = {TokenItem, Info}</v> - <v>TokenItem = atom()</v> - <v>Info = term()</v> - </type> <desc> <p>Returns a list containing information about the token - <c>Token</c>. The order of the <c>TokenInfoTuple</c>s is not - defined. The following <c>TokenItem</c>s are returned: - <c>category</c>, <c>column</c>, <c>length</c>, - <c>line</c>, <c>symbol</c>, and <c>text</c>. See <seealso + <c><anno>Token</anno></c>. The order of the + <c><anno>TokenInfoTuple</anno></c>s is not + defined. See <seealso marker="#token_info/2">token_info/2</seealso> for information about specific - <c>TokenInfoTuple</c>s.</p> + <c><anno>TokenInfoTuple</anno></c>s.</p> <p>Note that if <c>token_info(Token, TokenItem)</c> returns - <c>undefined</c> for some <c>TokenItem</c> in the list above, the - item is not included in <c>TokenInfo</c>.</p> + <c>undefined</c> for some <c>TokenItem</c>, the + item is not included in <c><anno>TokenInfo</anno></c>.</p> </desc> </func> <func> - <name>token_info(Token, TokenItemSpec) -> TokenInfo</name> + <name name="token_info" arity="2" clause_i="1"/> + <name name="token_info" arity="2" clause_i="2"/> + <type name="token_item"/> + <type name="attribute_item"/> <fsummary>Return information about a token</fsummary> - <type> - <v>Token = token()</v> - <v>TokenItemSpec = TokenItem | [TokenItem]</v> - <v>TokenInfo = TokenInfoTuple | undefined | [TokenInfoTuple]</v> - <v>TokenInfoTuple = {TokenItem, Info}</v> - <v>TokenItem = atom()</v> - <v>Info = term()</v> - </type> <desc> <p>Returns a list containing information about the token - <c>Token</c>. If <c>TokenItemSpec</c> is a single - <c>TokenItem</c>, the returned value is the corresponding + <c><anno>Token</anno></c>. If one single + <c><anno>TokenItem</anno></c> is given the returned value is + the corresponding <c>TokenInfoTuple</c>, or <c>undefined</c> if the - <c>TokenItem</c> has no value. If <c>TokenItemSpec</c> is a - list of - <c>TokenItem</c>, the result is a list of - <c>TokenInfoTuple</c>. The <c>TokenInfoTuple</c>s will - appear with the corresponding - <c>TokenItem</c>s in the same order as the <c>TokenItem</c>s - appeared in the list of <c>TokenItem</c>s. <c>TokenItem</c>s - with no value are not included in the list of - <c>TokenInfoTuple</c>.</p> - <p>The following <c>TokenInfoTuple</c>s with corresponding - <c>TokenItem</c>s are valid:</p> + <c>TokenItem</c> has no value. If a list of + <c><anno>TokenItem</anno></c>s is given the result is a list of + <c><anno>TokenInfoTuple</anno></c>. The + <c><anno>TokenInfoTuple</anno></c>s will + appear with the corresponding <c><anno>TokenItem</anno></c>s in + the same order as the <c><anno>TokenItem</anno></c>s + appear in the list of <c>TokenItem</c>s. + <c><anno>TokenItem</anno></c>s with no value are not included + in the list of <c><anno>TokenInfoTuple</anno></c>.</p> + <p>The following <c><anno>TokenInfoTuple</anno></c>s with corresponding + <c><anno>TokenItem</anno></c>s are valid:</p> <taglist> - <tag><c>{category, category()}</c></tag> + <tag><c>{category, <seealso marker="#type-category"> + category()</seealso>}</c></tag> <item><p>The category of the token.</p> </item> - <tag><c>{column, column()}</c></tag> + <tag><c>{column, <seealso marker="#type-column"> + column()</seealso>}</c></tag> <item><p>The column where the token begins.</p> </item> <tag><c>{length, integer() > 0}</c></tag> <item><p>The length of the token's text.</p> </item> - <tag><c>{line, line()}</c></tag> + <tag><c>{line, <seealso marker="#type-line"> + line()</seealso>}</c></tag> <item><p>The line where the token begins.</p> </item> - <tag><c>{location, location()}</c></tag> + <tag><c>{location, <seealso marker="#type-location"> + location()</seealso>}</c></tag> <item><p>The line and column where the token begins, or just the line if the column unknown.</p> </item> - <tag><c>{symbol, symbol()}</c></tag> + <tag><c>{symbol, <seealso marker="#type-symbol"> + symbol()</seealso>}</c></tag> <item><p>The token's symbol.</p> </item> <tag><c>{text, string()}</c></tag> - <item><p>The token's text..</p> + <item><p>The token's text.</p> </item> </taglist> </desc> </func> <func> - <name>attributes_info(Attributes) -> AttributesInfo</name> + <name name="attributes_info" arity="1"/> <fsummary>Return information about token attributes</fsummary> - <type> - <v>Attributes = attributes()</v> - <v>AttributesInfo = [AttributeInfoTuple]</v> - <v>AttributeInfoTuple = {AttributeItem, Info}</v> - <v>AttributeItem = atom()</v> - <v>Info = term()</v> - </type> <desc> <p>Returns a list containing information about the token - attributes <c>Attributes</c>. The order of the - <c>AttributeInfoTuple</c>s is not defined. The following - <c>AttributeItem</c>s are returned: - <c>column</c>, <c>length</c>, <c>line</c>, and <c>text</c>. + attributes <c><anno>Attributes</anno></c>. The order of the + <c><anno>AttributeInfoTuple</anno></c>s is not defined. See <seealso marker="#attributes_info/2">attributes_info/2</seealso> for information about specific - <c>AttributeInfoTuple</c>s.</p> + <c><anno>AttributeInfoTuple</anno></c>s.</p> <p>Note that if <c>attributes_info(Token, AttributeItem)</c> returns <c>undefined</c> for some <c>AttributeItem</c> in the list above, the item is not included in - <c>AttributesInfo</c>.</p> + <c><anno>AttributesInfo</anno></c>.</p> </desc> </func> <func> - <name>attributes_info(Attributes, AttributeItemSpec) -> AttributesInfo</name> + <name name="attributes_info" arity="2" clause_i="1"/> + <name name="attributes_info" arity="2" clause_i="2"/> <fsummary>Return information about a token attributes</fsummary> - <type> - <v>Attributes = attributes()</v> - <v>AttributeItemSpec = AttributeItem | [AttributeItem]</v> - <v>AttributesInfo = AttributeInfoTuple | undefined - | [AttributeInfoTuple]</v> - <v>AttributeInfoTuple = {AttributeItem, Info}</v> - <v>AttributeItem = atom()</v> - <v>Info = term()</v> - </type> + <type name="attribute_item"/> <desc> <p>Returns a list containing information about the token - attributes <c>Attributes</c>. If <c>AttributeItemSpec</c> is - a single <c>AttributeItem</c>, the returned value is the - corresponding <c>AttributeInfoTuple</c>, or <c>undefined</c> - if the <c>AttributeItem</c> has no value. If - <c>AttributeItemSpec</c> is a list of - <c>AttributeItem</c>, the result is a list of - <c>AttributeInfoTuple</c>. The <c>AttributeInfoTuple</c>s - will appear with the corresponding <c>AttributeItem</c>s in - the same order as the <c>AttributeItem</c>s appeared in the - list of <c>AttributeItem</c>s. <c>AttributeItem</c>s with no + attributes <c><anno>Attributes</anno></c>. If one single + <c><anno>AttributeItem</anno></c> is given the returned value is the + corresponding <c><anno>AttributeInfoTuple</anno></c>, + or <c>undefined</c> if the <c><anno>AttributeItem</anno></c> + has no value. If a list of <c><anno>AttributeItem</anno></c> + is given the result is a list of + <c><anno>AttributeInfoTuple</anno></c>. + The <c><anno>AttributeInfoTuple</anno></c>s + will appear with the corresponding <c><anno>AttributeItem</anno></c>s + in the same order as the <c><anno>AttributeItem</anno></c>s + appear in the list of <c><anno>AttributeItem</anno></c>s. + <c><anno>AttributeItem</anno></c>s with no value are not included in the list of - <c>AttributeInfoTuple</c>.</p> - <p>The following <c>AttributeInfoTuple</c>s with corresponding - <c>AttributeItem</c>s are valid:</p> + <c><anno>AttributeInfoTuple</anno></c>.</p> + <p>The following <c><anno>AttributeInfoTuple</anno></c>s with + corresponding <c><anno>AttributeItem</anno></c>s are valid:</p> <taglist> - <tag><c>{column, column()}</c></tag> + <tag><c>{column, <seealso marker="#type-column"> + column()</seealso>}</c></tag> <item><p>The column where the token begins.</p> </item> <tag><c>{length, integer() > 0}</c></tag> <item><p>The length of the token's text.</p> </item> - <tag><c>{line, line()}</c></tag> + <tag><c>{line, <seealso marker="#type-line"> + line()</seealso>}</c></tag> <item><p>The line where the token begins.</p> </item> - <tag><c>{location, location()}</c></tag> + <tag><c>{location, <seealso marker="#type-location"> + location()</seealso>}</c></tag> <item><p>The line and column where the token begins, or just the line if the column unknown.</p> </item> <tag><c>{text, string()}</c></tag> - <item><p>The token's text..</p> + <item><p>The token's text.</p> </item> </taglist> </desc> </func> <func> - <name>set_attribute(AttributeItem, Attributes, SetAttributeFun) -> AttributesInfo</name> + <name name="set_attribute" arity="3"/> <fsummary>Set a token attribute value</fsummary> - <type> - <v>AttributeItem = line</v> - <v>Attributes = attributes()</v> - <v>SetAttributeFun = set_attribute_fun()</v> - </type> <desc> <p>Sets the value of the <c>line</c> attribute of the token - attributes <c>Attributes</c>.</p> - <p>The <c>SetAttributeFun</c> is called with the value of + attributes <c><anno>Attributes</anno></c>.</p> + <p>The <c><anno>SetAttributeFun</anno></c> is called with the value of the <c>line</c> attribute, and is to return the new value of the <c>line</c> attribute.</p> </desc> </func> <func> - <name>format_error(ErrorDescriptor) -> string()</name> + <name name="format_error" arity="1"/> <fsummary>Format an error descriptor</fsummary> - <type> - <v>ErrorDescriptor = errordesc()</v> - </type> <desc> - <p>Takes an <c>ErrorDescriptor</c> and returns a string which + <p>Takes an <c><anno>ErrorDescriptor</anno></c> and returns + a string which describes the error or warning. This function is usually called implicitly when processing an <c>ErrorInfo</c> structure (see below).</p> diff --git a/lib/stdlib/doc/src/erl_tar.xml b/lib/stdlib/doc/src/erl_tar.xml index 929620bb88..fe166dbd01 100644 --- a/lib/stdlib/doc/src/erl_tar.xml +++ b/lib/stdlib/doc/src/erl_tar.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>2003</year><year>2009</year> + <year>2003</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -89,9 +89,8 @@ <v>Reason = term()</v> </type> <desc> - <p>The <marker id="add"></marker> -<c>add/3</c> function adds a file to a tar file - that has been opened for writing by + <p>The <marker id="add"></marker><c>add/3</c> function adds + a file to a tar file that has been opened for writing by <seealso marker="#open">open/1</seealso>.</p> <taglist> <tag><c>dereference</c></tag> @@ -138,8 +137,8 @@ <v>TarDescriptor = term()</v> </type> <desc> - <p>The <marker id="close"></marker> -<c>close/1</c> function closes a tar file + <p>The <marker id="close"></marker><c>close/1</c> function + closes a tar file opened by <seealso marker="#open">open/1</seealso>.</p> </desc> </func> @@ -151,11 +150,12 @@ <v>FileList = [Filename|{NameInArchive, binary()},{NameInArchive, Filename}]</v> <v>Filename = filename()</v> <v>NameInArchive = filename()</v> - <v>RetValue = ok|{error,{Name,Reason}} <V>Reason = term()</v> + <v>RetValue = ok|{error,{Name,Reason}}</v> + <v>Reason = term()</v> </type> <desc> - <p>The <marker id="create_2"></marker> -<c>create/2</c> function creates a tar file and + <p>The <marker id="create_2"></marker><c>create/2</c> function + creates a tar file and archives the files whose names are given in <c>FileList</c> into it. The files may either be read from disk or given as binaries.</p> @@ -171,11 +171,11 @@ <v>NameInArchive = filename()</v> <v>OptionList = [Option]</v> <v>Option = compressed|cooked|dereference|verbose</v> - <v>RetValue = ok|{error,{Name,Reason}} <V>Reason = term()</v> + <v>RetValue = ok|{error,{Name,Reason}}</v> + <v>Reason = term()</v> </type> <desc> - <p>The <marker id="create_3"></marker> -<c>create/3</c> function + <p>The <marker id="create_3"></marker><c>create/3</c> function creates a tar file and archives the files whose names are given in <c>FileList</c> into it. The files may either be read from disk or given as binaries.</p> @@ -220,9 +220,8 @@ <v>Reason = term()</v> </type> <desc> - <p>The <marker id="extract_1"></marker> -<c>extract/1</c> function extracts - all files from a tar archive.</p> + <p>The <marker id="extract_1"></marker><c>extract/1</c> function + extracts all files from a tar archive.</p> <p>If the <c>Name</c> argument is given as "<c>{binary,Binary}</c>", the contents of the binary is assumed to be a tar archive. </p> @@ -250,9 +249,8 @@ <v>Reason = term()</v> </type> <desc> - <p>The <marker id="extract_2"></marker> -<c>extract/2</c> function extracts - files from a tar archive.</p> + <p>The <marker id="extract_2"></marker><c>extract/2</c> function + extracts files from a tar archive.</p> <p>If the <c>Name</c> argument is given as "<c>{binary,Binary}</c>", the contents of the binary is assumed to be a tar archive. </p> @@ -322,8 +320,8 @@ <v>Reason = term()</v> </type> <desc> - <p>The <marker id="format_error_1"></marker> -<c>format_error/1</c> converts + <p>The <marker id="format_error_1"></marker><c>format_error/1</c> + function converts an error reason term to a human-readable error message string.</p> </desc> </func> @@ -339,8 +337,8 @@ <v>Reason = term()</v> </type> <desc> - <p>The <marker id="open"></marker> -<c>open/2</c> function creates a tar file for writing. + <p>The <marker id="open"></marker><c>open/2</c> function creates + a tar file for writing. (Any existing file with the same name will be truncated.)</p> <p>By convention, the name of a tar file should end in "<c>.tar</c>". To abide to the convention, you'll need to add "<c>.tar</c>" yourself @@ -373,7 +371,6 @@ You should not rely on the specific contents of the <c>TarDescriptor</c> term, as it may change in future versions as more features are added to the <c>erl_tar</c> module.</p> - <p></p> </warning> </desc> </func> @@ -386,9 +383,8 @@ <v>Reason = term()</v> </type> <desc> - <p>The <marker id="table_1"></marker> -<c>table/1</c> function retrieves - the names of all files in the tar file <c>Name</c>.</p> + <p>The <marker id="table_1"></marker><c>table/1</c> function + retrieves the names of all files in the tar file <c>Name</c>.</p> </desc> </func> <func> @@ -398,9 +394,8 @@ <v>Name = filename()</v> </type> <desc> - <p>The <marker id="table_2"></marker> -<c>table/2</c> function retrieves - the names of all files in the tar file <c>Name</c>.</p> + <p>The <marker id="table_2"></marker><c>table/2</c> function + retrieves the names of all files in the tar file <c>Name</c>.</p> </desc> </func> <func> @@ -410,8 +405,7 @@ <v>Name = filename()</v> </type> <desc> - <p>The <marker id="t_1"></marker> -<c>t/1</c> function prints the names + <p>The <marker id="t_1"></marker><c>t/1</c> function prints the names of all files in the tar file <c>Name</c> to the Erlang shell. (Similar to "<c>tar t</c>".)</p> </desc> @@ -423,8 +417,8 @@ <v>Name = filename()</v> </type> <desc> - <p>The <marker id="tt_1"></marker> -<c>tt/1</c> function prints names and + <p>The <marker id="tt_1"></marker><c>tt/1</c> function prints + names and information about all files in the tar file <c>Name</c> to the Erlang shell. (Similar to "<c>tar tv</c>".)</p> </desc> diff --git a/lib/stdlib/doc/src/ets.xml b/lib/stdlib/doc/src/ets.xml index 7b9f0e7772..efd9514db6 100644 --- a/lib/stdlib/doc/src/ets.xml +++ b/lib/stdlib/doc/src/ets.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2009</year> + <year>1996</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>ets</title> @@ -56,8 +56,8 @@ Even if there are no references to a table from any process, it will not automatically be destroyed unless the owner process terminates. It can be destroyed explicitly by using - <c>delete/1</c>.</p> - <p>Since R13B01, table ownership can be transferred at process termination + <c>delete/1</c>. The default owner is the process that created the + table. Table ownership can be transferred at process termination by using the <seealso marker="#heir">heir</seealso> option or explicitly by calling <seealso marker="#give_away/3">give_away/3</seealso>.</p> <p>Some implementation details:</p> @@ -82,11 +82,15 @@ <c>float()</c> that extends to the same value, hence the key <c>1</c> and the key <c>1.0</c> are regarded as equal in an <c>ordered_set</c> table.</p> - <p>In general, the functions below will exit with reason - <c>badarg</c> if any argument is of the wrong format, or if the - table identifier is invalid.</p> </description> - + <section> + <title>Failure</title> + <p>In general, the functions below will exit with reason + <c>badarg</c> if any argument is of the wrong format, if the + table identifier is invalid or if the operation is denied due to + table access rights (<seealso marker="#protected">protected</seealso> + or <seealso marker="#private">private</seealso>).</p> + </section> <section><marker id="concurrency"></marker> <title>Concurrency</title> <p>This module provides some limited support for concurrent access. @@ -122,15 +126,30 @@ <em>ERTS User's Guide</em>.</p> </section> - <section> - <title>DATA TYPES</title> - <code type="none"> -match_spec() - a match specification, see above - -tid() - a table identifier, as returned by new/2</code> - </section> + <datatypes> + <datatype> + <name><marker id="type-continuation">continuation()</marker></name> + <desc> + <p>Opaque continuation used by <seealso marker="#select/1"> + <c>select/1</c></seealso> and <seealso marker="#select/3"> + <c>select/3</c></seealso>.</p> + </desc> + </datatype> + <datatype> + <name name="match_spec"/> + <desc><p>A match specification, see above.</p></desc> + </datatype> + <datatype> + <name name="match_pattern"/> + </datatype> + <datatype> + <name name="tab"/> + </datatype> + <datatype> + <name name="tid"/> + <desc><p>A table identifier, as returned by new/2.</p></desc> + </datatype> + </datatypes> <funcs> <func> <name>all() -> [Tab]</name> @@ -193,37 +212,25 @@ tid() </desc> </func> <func> - <name>file2tab(Filename) -> {ok,Tab} | {error,Reason}</name> + <name name="file2tab" arity="1"/> <fsummary>Read an ETS table from a file.</fsummary> - <type> - <v>Filename = string() | atom()</v> - <v>Tab = tid() | atom()</v> - <v>Reason = term()</v> - </type> <desc> <p>Reads a file produced by <seealso marker="#tab2file/2">tab2file/2</seealso> or <seealso marker="#tab2file/3">tab2file/3</seealso> and creates the - corresponding table <c>Tab</c>.</p> - <p>Equivalent to <c>file2tab(Filename,[])</c>.</p> + corresponding table <c><anno>Tab</anno></c>.</p> + <p>Equivalent to <c>file2tab(<anno>Filename</anno>, [])</c>.</p> </desc> </func> <func> - <name>file2tab(Filename,Options) -> {ok,Tab} | {error,Reason}</name> + <name name="file2tab" arity="2"/> <fsummary>Read an ETS table from a file.</fsummary> - <type> - <v>Filename = string() | atom()</v> - <v>Tab = tid() | atom()</v> - <v>Options = [Option]</v> - <v>Option = {verify, bool()}</v> - <v>Reason = term()</v> - </type> <desc> <p>Reads a file produced by <seealso marker="#tab2file/2">tab2file/2</seealso> or <seealso marker="#tab2file/3">tab2file/3</seealso> and creates the - corresponding table <c>Tab</c>.</p> - <p>The currently only supported option is <c>{verify,bool()}</c>. If + corresponding table <c><anno>Tab</anno></c>.</p> + <p>The currently only supported option is <c>{verify,boolean()}</c>. If verification is turned on (by means of specifying <c>{verify,true}</c>), the function utilizes whatever information is present in the file to assert that the @@ -267,70 +274,52 @@ tid() </desc> </func> <func> - <name>foldl(Function, Acc0, Tab) -> Acc1</name> + <name name="foldl" arity="3"/> <fsummary>Fold a function over an ETS table</fsummary> - <type> - <v>Function = fun(A, AccIn) -> AccOut</v> - <v>Tab = tid() | atom()</v> - <v>Acc0 = Acc1 = AccIn = AccOut = term()</v> - </type> <desc> - <p><c>Acc0</c> is returned if the table is empty. + <p><c><anno>Acc0</anno></c> is returned if the table is empty. This function is similar to <c>lists:foldl/3</c>. The order in which the elements of the table are traversed is unspecified, except for tables of type <c>ordered_set</c>, for which they are traversed first to last.</p> - <p>If <c>Function</c> inserts objects into the table, or another + <p>If <c><anno>Function</anno></c> inserts objects into the table, or another process inserts objects into the table, those objects <em>may</em> (depending on key ordering) be included in the traversal.</p> </desc> </func> <func> - <name>foldr(Function, Acc0, Tab) -> Acc1</name> + <name name="foldr" arity="3"/> <fsummary>Fold a function over an ETS table</fsummary> - <type> - <v>Function = fun(A, AccIn) -> AccOut</v> - <v>Tab = tid() | atom()</v> - <v>Acc0 = Acc1 = AccIn = AccOut = term()</v> - </type> <desc> - <p><c>Acc0</c> is returned if the table is empty. + <p><c><anno>Acc0</anno></c> is returned if the table is empty. This function is similar to <c>lists:foldr/3</c>. The order in which the elements of the table are traversed is unspecified, except for tables of type <c>ordered_set</c>, for which they are traversed last to first.</p> - <p>If <c>Function</c> inserts objects into the table, or another + <p>If <c><anno>Function</anno></c> inserts objects into the table, or another process inserts objects into the table, those objects <em>may</em> (depending on key ordering) be included in the traversal.</p> </desc> </func> <func> - <name>from_dets(Tab, DetsTab) -> true</name> + <name name="from_dets" arity="2"/> <fsummary>Fill an ETS table with objects from a Dets table.</fsummary> - <type> - <v>Tab = tid() | atom()</v> - <v>DetsTab = atom()</v> - </type> <desc> <p>Fills an already created ETS table with the objects in the - already opened Dets table named <c>DetsTab</c>. The existing + already opened Dets table named <c><anno>DetsTab</anno></c>. The existing objects of the ETS table are kept unless overwritten.</p> <p>Throws a badarg error if any of the tables does not exist or the dets table is not open.</p> </desc> </func> <func> - <name>fun2ms(LiteralFun) -> MatchSpec</name> + <name name="fun2ms" arity="1"/> <fsummary>Pseudo function that transforms fun syntax to a match_spec.</fsummary> - <type> - <v>LiteralFun -- see below</v> - <v>MatchSpec = match_spec()</v> - </type> <desc> <p>Pseudo function that by means of a <c>parse_transform</c> - translates <c>LiteralFun</c> typed as parameter in the + translates <c><anno>LiteralFun</anno></c> typed as parameter in the function call to a <seealso marker="#match_spec">match_spec</seealso>. With "literal" is meant that the fun needs to textually be written @@ -338,7 +327,7 @@ tid() variable which in turn is passed to the function).</p> <p>The parse transform is implemented in the module <c>ms_transform</c> and the source <em>must</em> include the - file <c>ms_transform.hrl</c> in <c>stdlib</c> for this + file <c>ms_transform.hrl</c> in STDLIB for this pseudo function to work. Failing to include the hrl file in the source will result in a runtime error, not a compile time ditto. The include file is easiest included by adding @@ -418,20 +407,17 @@ Error: fun containing local Erlang function calls </desc> </func> <func> - <name>i() -> ok</name> + <name name="i" arity="0"/> <fsummary>Display information about all ETS tables on tty.</fsummary> <desc> <p>Displays information about all ETS tables on tty.</p> </desc> </func> <func> - <name>i(Tab) -> ok</name> + <name name="i" arity="1"/> <fsummary>Browse an ETS table on tty.</fsummary> - <type> - <v>Tab = tid() | atom()</v> - </type> <desc> - <p>Browses the table <c>Tab</c> on tty.</p> + <p>Browses the table <c><anno>Tab</anno></c> on tty.</p> </desc> </func> <func> @@ -450,7 +436,7 @@ Error: fun containing local Erlang function calls correct type, this function fails with reason <c>badarg</c>.</p> <list type="bulleted"> - <item><c>Item=memory, Value=int()</c> <br></br> + <item><c>Item=memory, Value=integer()</c> <br></br> The number of words allocated to the table.</item> <item><c>Item=owner, Value=pid()</c> <br></br> @@ -462,7 +448,7 @@ Error: fun containing local Erlang function calls <item><c>Item=name, Value=atom()</c> <br></br> The name of the table.</item> - <item><c>Item=size, Value=int()</c> <br></br> + <item><c>Item=size, Value=integer()</c> <br></br> The number of objects inserted in the table.</item> <item><c>Item=node, Value=atom()</c> <br></br> @@ -475,12 +461,15 @@ Error: fun containing local Erlang function calls <item><c>Item=type, Value=set|ordered_set|bag|duplicate_bag</c> <br></br> The table type.</item> - <item><c>Item=keypos, Value=int()</c> <br></br> + <item><c>Item=keypos, Value=integer()</c> <br></br> The key position.</item> <item><c>Item=protection, Value=public|protected|private</c> <br></br> The table access rights.</item> + <item><c>Item=compressed, Value=true|false</c> <br></br> + + Indicates if the table is compressed or not.</item> </list> </desc> </func> @@ -523,31 +512,27 @@ Error: fun containing local Erlang function calls of the reference counter, keeping track of how many times the table has been fixed by the process.</p> <p>If the table never has been fixed, the call returns - <c>false</c>.</p> - </item> + <c>false</c>.</p></item> + <item><p><c>Item=stats, Value=tuple()</c> <br></br> + Returns internal statistics about set, bag and duplicate_bag tables on an internal format used by OTP test suites. + Not for production use.</p></item> </list> </desc> </func> <func> - <name>init_table(Name, InitFun) -> true</name> + <name name="init_table" arity="2"/> <fsummary>Replace all objects of an ETS table.</fsummary> - <type> - <v>Name = atom()</v> - <v>InitFun = fun(Arg) -> Res</v> - <v>Arg = read | close</v> - <v>Res = end_of_input | {[object()], InitFun} | term()</v> - </type> <desc> - <p>Replaces the existing objects of the table <c>Tab</c> with - objects created by calling the input function <c>InitFun</c>, + <p>Replaces the existing objects of the table <c><anno>Tab</anno></c> with + objects created by calling the input function <c><anno>InitFun</anno></c>, see below. This function is provided for compatibility with the <c>dets</c> module, it is not more efficient than filling a table by using <c>ets:insert/2</c>. </p> <p>When called with the argument <c>read</c> the function - <c>InitFun</c> is assumed to return <c>end_of_input</c> when - there is no more input, or <c>{Objects, Fun}</c>, where - <c>Objects</c> is a list of objects and <c>Fun</c> is a new + <c><anno>InitFun</anno></c> is assumed to return <c>end_of_input</c> when + there is no more input, or <c>{<anno>Objects</anno>, Fun}</c>, where + <c><anno>Objects</anno></c> is a list of objects and <c>Fun</c> is a new input function. Any other value Value is returned as an error <c>{error, {init_fun, Value}}</c>. Each input function will be called exactly once, and should an error occur, the last @@ -587,7 +572,7 @@ Error: fun containing local Erlang function calls </desc> </func> <func> - <name>insert_new(Tab, ObjectOrObjects) -> bool()</name> + <name>insert_new(Tab, ObjectOrObjects) -> boolean()</name> <fsummary>Insert an object into an ETS table if the key is not already present.</fsummary> <type> <v>Tab = tid() | atom()</v> @@ -608,7 +593,7 @@ Error: fun containing local Erlang function calls </desc> </func> <func> - <name>is_compiled_ms(Term) -> bool()</name> + <name>is_compiled_ms(Term) -> boolean()</name> <fsummary>Checks if an Erlang term is the result of ets:match_spec_compile</fsummary> <type> <v>Term = term()</v> @@ -675,9 +660,9 @@ ets:is_compiled_ms(Broken).</code> table. The difference being the same as between <c>=:=</c> and <c>==</c>. As an example, one might insert an object with the - <c>integer()</c><c>1</c> as a key in an <c>ordered_set</c> + <c>integer()</c> <c>1</c> as a key in an <c>ordered_set</c> and get the object returned as a result of doing a - <c>lookup/2</c> with the <c>float()</c><c>1.0</c> as the + <c>lookup/2</c> with the <c>float()</c> <c>1.0</c> as the key to search for.</p> <p>If the table is of type <c>set</c> or <c>ordered_set</c>, the function returns either the empty list or a list with one @@ -701,7 +686,7 @@ ets:is_compiled_ms(Broken).</code> <type> <v>Tab = tid() | atom()</v> <v>Key = term()</v> - <v>Pos = int()</v> + <v>Pos = integer()</v> <v>Elem = term() | [term()]</v> </type> <desc> @@ -795,15 +780,11 @@ ets:is_compiled_ms(Broken).</code> </desc> </func> <func> - <name>match_delete(Tab, Pattern) -> true</name> + <name name="match_delete" arity="2"/> <fsummary>Delete all objects which match a given pattern from an ETS table.</fsummary> - <type> - <v>Tab = tid() | atom()</v> - <v>Pattern = tuple()</v> - </type> <desc> - <p>Deletes all objects which match the pattern <c>Pattern</c> - from the table <c>Tab</c>. See <c>match/2</c> for a + <p>Deletes all objects which match the pattern <c><anno>Pattern</anno></c> + from the table <c><anno>Tab</anno></c>. See <c>match/2</c> for a description of patterns.</p> </desc> </func> @@ -947,10 +928,11 @@ ets:select(Table,MatchSpec),</code> <type> <v>Name = atom()</v> <v>Options = [Option]</v> - <v> Option = Type | Access | named_table | {keypos,Pos} | {heir,pid(),HeirData} | {heir,none} | {write_concurrency,bool()}</v> + <v> Option = Type | Access | named_table | {keypos,Pos} | {heir,pid(),HeirData} | {heir,none} | Tweaks</v> <v> Type = set | ordered_set | bag | duplicate_bag</v> <v> Access = public | protected | private</v> - <v> Pos = int()</v> + <v> Tweaks = {write_concurrency,boolean()} | {read_concurrency,boolean()} | compressed</v> + <v> Pos = integer()</v> <v> HeirData = term()</v> </type> <desc> @@ -963,7 +945,7 @@ ets:select(Table,MatchSpec),</code> table is named or not. If one or more options are left out, the default values are used. This means that not specifying any options (<c>[]</c>) is the same as specifying - <c>[set,protected,{keypos,1},{heir,none},{write_concurrency,false}]</c>.</p> + <c>[set, protected, {keypos,1}, {heir,none}, {write_concurrency,false}, {read_concurrency,false}]</c>.</p> <list type="bulleted"> <item> <p><c>set</c> @@ -980,7 +962,7 @@ ets:select(Table,MatchSpec),</code> <c>ordered_set</c> tables regard keys as equal when they <em>compare equal</em>, not only when they match. This means that to an <c>ordered_set</c>, the - <c>integer()</c><c>1</c> and the <c>float()</c><c>1.0</c> are regarded as equal. This also means that the + <c>integer()</c> <c>1</c> and the <c>float()</c> <c>1.0</c> are regarded as equal. This also means that the key used to lookup an element not necessarily <em>matches</em> the key in the elements returned, if <c>float()</c>'s and <c>integer()</c>'s are mixed in @@ -1002,12 +984,14 @@ ets:select(Table,MatchSpec),</code> Any process may read or write to the table.</p> </item> <item> + <marker id="protected"></marker> <p><c>protected</c> The owner process can read and write to the table. Other processes can only read the table. This is the default setting for the access rights.</p> </item> <item> + <marker id="private"></marker> <p><c>private</c> Only the owner process can read or write to the table.</p> </item> @@ -1039,15 +1023,22 @@ ets:select(Table,MatchSpec),</code> the owner terminates.</p> </item> <item> - <p><c>{write_concurrency,bool()}</c> - Performance tuning. Default is <c>false</c>, which means that the table - is optimized towards concurrent read access. An operation that + <marker id="new_2_write_concurrency"></marker> + <p><c>{write_concurrency,boolean()}</c> + Performance tuning. Default is <c>false</c>, in which case an operation that mutates (writes to) the table will obtain exclusive access, blocking any concurrent access of the same table until finished. If set to <c>true</c>, the table is optimized towards concurrent write access. Different objects of the same table can be mutated (and read) by concurrent processes. This is achieved to some degree - at the expense of single access and concurrent reader performance. + at the expense of sequential access and concurrent reader performance. + The <c>write_concurrency</c> option can be combined with the + <seealso marker="#new_2_read_concurrency">read_concurrency</seealso> + option. You typically want to combine these when large concurrent + read bursts and large concurrent write bursts are common (see the + documentation of the + <seealso marker="#new_2_read_concurrency">read_concurrency</seealso> + option for more information). Note that this option does not change any guarantees about <seealso marker="#concurrency">atomicy and isolation</seealso>. Functions that makes such promises over several objects (like @@ -1055,6 +1046,38 @@ ets:select(Table,MatchSpec),</code> <p>Table type <c>ordered_set</c> is not affected by this option in current implementation.</p> </item> + <item> + <marker id="new_2_read_concurrency"></marker> + <p><c>{read_concurrency,boolean()}</c> + Performance tuning. Default is <c>false</c>. When set to + <c>true</c>, the table is optimized for concurrent read + operations. When this option is enabled on a runtime system with + SMP support, read operations become much cheaper; especially on + systems with multiple physical processors. However, switching + between read and write operations becomes more expensive. You + typically want to enable this option when concurrent read + operations are much more frequent than write operations, or when + concurrent reads and writes comes in large read and write + bursts (i.e., lots of reads not interrupted by writes, and lots + of writes not interrupted by reads). You typically do + <em>not</em> want to enable this option when the common access + pattern is a few read operations interleaved with a few write + operations repeatedly. In this case you will get a performance + degradation by enabling this option. The <c>read_concurrency</c> + option can be combined with the + <seealso marker="#new_2_write_concurrency">write_concurrency</seealso> + option. You typically want to combine these when large concurrent + read bursts and large concurrent write bursts are common.</p> + </item> + <item> + <marker id="new_2_compressed"></marker> + <p><c>compressed</c> + If this option is present, the table data will be stored in a more compact format to + consume less memory. The downside is that it will make table operations slower. + Especially operations that need to inspect entire objects, + such as <c>match</c> and <c>select</c>, will get much slower. The key element + is not compressed in current implementation.</p> + </item> </list> </desc> </func> @@ -1111,12 +1134,8 @@ ets:select(Table,MatchSpec),</code> </desc> </func> <func> - <name>repair_continuation(Continuation, MatchSpec) -> Continuation</name> + <name name="repair_continuation" arity="2"/> <fsummary>Repair a continuation from ets:select/1 or ets:select/3 that has passed through external representation</fsummary> - <type> - <v>Continuation = term()</v> - <v>MatchSpec = match_spec()</v> - </type> <desc> <p>This function can be used to restore an opaque continuation returned by <c>ets:select/3</c> or <c>ets:select/1</c> if the @@ -1355,6 +1374,28 @@ is_integer(X), is_integer(Y), X + Y < 4711]]></code> </desc> </func> <func> + <name>select_count(Tab, MatchSpec) -> NumMatched</name> + <fsummary>Match the objects in an ETS table against a match_spec and returns the number of objects for which the match_spec returned 'true'</fsummary> + <type> + <v>Tab = tid() | atom()</v> + <v>Object = tuple()</v> + <v>MatchSpec = match_spec()</v> + <v>NumMatched = integer()</v> + </type> + <desc> + <p>Matches the objects in the table <c>Tab</c> using a + <seealso marker="#match_spec">match_spec</seealso>. If the + match_spec returns <c>true</c> for an object, that object + considered a match and is counted. For any other result from + the match_spec the object is not considered a match and is + therefore not counted.</p> + <p>The function could be described as a <c>match_delete/2</c> + that does not actually delete any elements, but only counts + them.</p> + <p>The function returns the number of objects matched.</p> + </desc> + </func> + <func> <name>select_delete(Tab, MatchSpec) -> NumDeleted</name> <fsummary>Match the objects in an ETS table against a match_spec and deletes objects where the match_spec returns 'true'</fsummary> <type> @@ -1381,25 +1422,82 @@ is_integer(X), is_integer(Y), X + Y < 4711]]></code> </desc> </func> <func> - <name>select_count(Tab, MatchSpec) -> NumMatched</name> - <fsummary>Match the objects in an ETS table against a match_spec and returns the number of objects for which the match_spec returned 'true'</fsummary> + <name>select_reverse(Tab, MatchSpec) -> [Match]</name> + <fsummary>Match the objects in an ETS table against a match_spec.</fsummary> <type> <v>Tab = tid() | atom()</v> - <v>Object = tuple()</v> + <v>Match = term()</v> <v>MatchSpec = match_spec()</v> - <v>NumMatched = integer()</v> </type> <desc> - <p>Matches the objects in the table <c>Tab</c> using a - <seealso marker="#match_spec">match_spec</seealso>. If the - match_spec returns <c>true</c> for an object, that object - considered a match and is counted. For any other result from - the match_spec the object is not considered a match and is - therefore not counted.</p> - <p>The function could be described as a <c>match_delete/2</c> - that does not actually delete any elements, but only counts - them.</p> - <p>The function returns the number of objects matched.</p> + + <p>Works like <c>select/2</c>, but returns the list in reverse + order for the <c>ordered_set</c> table type. For all other table + types, the return value is identical to that of <c>select/2</c>.</p> + + </desc> + </func> + <func> + <name>select_reverse(Tab, MatchSpec, Limit) -> {[Match],Continuation} | '$end_of_table'</name> + <fsummary>Match the objects in an ETS table against a match_spec and returns part of the answers.</fsummary> + <type> + <v>Tab = tid() | atom()</v> + <v>Match = term()</v> + <v>MatchSpec = match_spec()</v> + <v>Continuation = term()</v> + </type> + <desc> + + <p>Works like <c>select/3</c>, but for the <c>ordered_set</c> + table type, traversing is done starting at the last object in + Erlang term order and moves towards the first. For all other + table types, the return value is identical to that of + <c>select/3</c>.</p> + + <p>Note that this is <em>not</em> equivalent to + reversing the result list of a <c>select/3</c> call, as the result list + is not only reversed, but also contains the last <c>Limit</c> + matching objects in the table, not the first.</p> + + </desc> + </func> + <func> + <name>select_reverse(Continuation) -> {[Match],Continuation} | '$end_of_table'</name> + <fsummary>Continue matching objects in an ETS table.</fsummary> + <type> + <v>Match = term()</v> + <v>Continuation = term()</v> + </type> + <desc> + + <p>Continues a match started with + <c>ets:select_reverse/3</c>. If the table is an + <c>ordered_set</c>, the traversal of the table will continue + towards objects with keys earlier in the Erlang term order. The + returned list will also contain objects with keys in reverse + order.</p> + + <p>For all other table types, the behaviour is exatly that of <c>select/1</c>.</p> + <p>Example:</p> + <code> +1> T = ets:new(x,[ordered_set]). +2> [ ets:insert(T,{N}) || N <- lists:seq(1,10) ]. +... +3> {R0,C0} = ets:select_reverse(T,[{'_',[],['$_']}],4). +... +4> R0. +[{10},{9},{8},{7}] +5> {R1,C1} = ets:select_reverse(C0). +... +6> R1. +[{6},{5},{4},{3}] +7> {R2,C2} = ets:select_reverse(C1). +... +8> R2. +[{2},{1}] +9> '$end_of_table' = ets:select_reverse(C2). +... + </code> </desc> </func> <func> @@ -1423,7 +1521,7 @@ is_integer(X), is_integer(Y), X + Y < 4711]]></code> <fsummary>Return all objects in a given slot of an ETS table.</fsummary> <type> <v>Tab = tid() | atom()</v> - <v>I = int()</v> + <v>I = integer()</v> <v>Object = tuple()</v> </type> <desc> @@ -1444,32 +1542,19 @@ is_integer(X), is_integer(Y), X + Y < 4711]]></code> </desc> </func> <func> - <name>tab2file(Tab, Filename) -> ok | {error,Reason}</name> + <name name="tab2file" arity="2"/> <fsummary>Dump an ETS table to a file.</fsummary> - <type> - <v>Tab = tid() | atom()</v> - <v>Filename = string() | atom()</v> - <v>Reason = term()</v> - </type> <desc> - <p>Dumps the table <c>Tab</c> to the file <c>Filename</c>.</p> - <p>Equivalent to <c>tab2file(Tab, Filename,[])</c></p> + <p>Dumps the table <c><anno>Tab</anno></c> to the file <c><anno>Filename</anno></c>.</p> + <p>Equivalent to <c>tab2file(<anno>Tab</anno>, <anno>Filename</anno>,[])</c></p> </desc> </func> <func> - <name>tab2file(Tab, Filename, Options) -> ok | {error,Reason}</name> + <name name="tab2file" arity="3"/> <fsummary>Dump an ETS table to a file.</fsummary> - <type> - <v>Tab = tid() | atom()</v> - <v>Filename = string() | atom()</v> - <v>Options = [Option]</v> - <v>Option = {extended_info, [ExtInfo]}</v> - <v>ExtInfo = object_count | md5sum</v> - <v>Reason = term()</v> - </type> <desc> - <p>Dumps the table <c>Tab</c> to the file <c>Filename</c>.</p> + <p>Dumps the table <c><anno>Tab</anno></c> to the file <c><anno>Filename</anno></c>.</p> <p>When dumping the table, certain information about the table is dumped to a header at the beginning of the dump. This information contains data about the table type, @@ -1506,26 +1591,15 @@ is_integer(X), is_integer(Y), X + Y < 4711]]></code> </desc> </func> <func> - <name>tab2list(Tab) -> [Object]</name> + <name name="tab2list" arity="1"/> <fsummary>Return a list of all objects in an ETS table.</fsummary> - <type> - <v>Tab = tid() | atom()</v> - <v>Object = tuple()</v> - </type> <desc> - <p>Returns a list of all objects in the table <c>Tab</c>.</p> + <p>Returns a list of all objects in the table <c><anno>Tab</anno></c>.</p> </desc> </func> <func> - <name>tabfile_info(Filename) -> {ok, TableInfo} | {error, Reason}</name> + <name name="tabfile_info" arity="1"/> <fsummary>Return a list of all objects in an ETS table.</fsummary> - <type> - <v>Filename = string() | atom()</v> - <v>TableInfo = [InfoItem]</v> - <v>InfoItem = {InfoTag, term()}</v> - <v>InfoTag = name | type | protection | named_table | keypos | size | extended_info | version</v> - <v>Reason = term()</v> - </type> <desc> <p>Returns information about the table dumped to file by <seealso marker="#tab2file/2">tab2file/2</seealso> or @@ -1571,7 +1645,7 @@ is_integer(X), is_integer(Y), X + Y < 4711]]></code> one or more of the atoms <c>object_count</c> and <c>md5sum</c>.</item> <tag>version</tag> - <item>A tuple <c>{Major,Minor}</c> containing the major and + <item>A tuple <c>{<anno>Major</anno>,<anno>Minor</anno>}</c> containing the major and minor version of the file format for ets table dumps. This version field was added beginning with stdlib-1.5.1, files dumped with older versions will return <c>{0,0}</c> in this @@ -1584,20 +1658,11 @@ is_integer(X), is_integer(Y), X + Y < 4711]]></code> </desc> </func> <func> - <name>table(Tab [, Options]) -> QueryHandle</name> + <name name="table" arity="1"/> + <name name="table" arity="2"/> <fsummary>Return a QLC query handle.</fsummary> - <type> - <v>Tab = tid() | atom()</v> - <v>QueryHandle = - a query handle, see qlc(3) -</v> - <v>Options = [Option] | Option</v> - <v>Option = {n_objects, NObjects} | {traverse, TraverseMethod}</v> - <v>NObjects = default | integer() > 0</v> - <v>TraverseMethod = first_next | last_prev | select | {select, MatchSpec}</v> - <v>MatchSpec = match_spec()</v> - </type> <desc> - <p> <marker id="qlc_table"></marker> -Returns a QLC (Query List + <p><marker id="qlc_table"></marker>Returns a QLC (Query List Comprehension) query handle. The module <c>qlc</c> implements a query language aimed mainly at Mnesia but ETS tables, Dets tables, and lists are also recognized by QLC as sources of @@ -1632,7 +1697,7 @@ Returns a QLC (Query List that matches all objects.</p> </item> <item> - <p><c>{select, MatchSpec}</c>. As for <c>select</c> + <p><c>{select, <anno>MatchSpec</anno>}</c>. As for <c>select</c> the table is traversed by calling <c>ets:select/3</c> and <c>ets:select/1</c>. The difference is that the match_spec is explicitly given. This is how to state @@ -1660,41 +1725,31 @@ true</pre> </desc> </func> <func> - <name>test_ms(Tuple, MatchSpec) -> {ok, Result} | {error, Errors}</name> + <name name="test_ms" arity="2"/> <fsummary>Test a match_spec for use in ets:select/2.</fsummary> - <type> - <v>Tuple = tuple()</v> - <v>MatchSpec = match_spec()</v> - <v>Result = term()</v> - <v>Errors = [{warning|error, string()}]</v> - </type> <desc> <p>This function is a utility to test a <seealso marker="#match_spec">match_spec</seealso> used in calls to <c>ets:select/2</c>. The function both tests - <c>MatchSpec</c> for "syntactic" correctness and runs the - match_spec against the object <c>Tuple</c>. If the match_spec - contains errors, the tuple <c>{error, Errors}</c> is returned - where <c>Errors</c> is a list of natural language + <c><anno>MatchSpec</anno></c> for "syntactic" correctness and runs the + match_spec against the object <c><anno>Tuple</anno></c>. If the match_spec + contains errors, the tuple <c>{error, <anno>Errors</anno>}</c> is returned + where <c><anno>Errors</anno></c> is a list of natural language descriptions of what was wrong with the match_spec. If the match_spec is syntactically OK, the function returns - <c>{ok,Term}</c> where <c>Term</c> is what would have been + <c>{ok,<anno>Result</anno>}</c> where <c><anno>Result</anno></c> is what would have been the result in a real <c>ets:select/2</c> call or <c>false</c> - if the match_spec does not match the object <c>Tuple</c>.</p> + if the match_spec does not match the object <c><anno>Tuple</anno></c>.</p> <p>This is a useful debugging and test tool, especially when writing complicated <c>ets:select/2</c> calls.</p> </desc> </func> <func> - <name>to_dets(Tab, DetsTab) -> Tab</name> + <name name="to_dets" arity="2"/> <fsummary>Fill a Dets table with objects from an ETS table.</fsummary> - <type> - <v>Tab = tid() | atom()</v> - <v>DetsTab = atom()</v> - </type> <desc> <p>Fills an already created/opened Dets table with the objects - in the already opened ETS table named <c>Tab</c>. The Dets + in the already opened ETS table named <c><anno>Tab</anno></c>. The Dets table is emptied before the objects are inserted.</p> </desc> </func> @@ -1707,7 +1762,7 @@ true</pre> <v>Tab = tid() | atom()</v> <v>Key = term()</v> <v>UpdateOp = {Pos,Incr} | {Pos,Incr,Threshold,SetValue}</v> - <v>Pos = Incr = Threshold = SetValue = Result = int()</v> + <v>Pos = Incr = Threshold = SetValue = Result = integer()</v> </type> <desc> <p>This function provides an efficient way to update one or more @@ -1769,7 +1824,7 @@ true</pre> <type> <v>Tab = tid() | atom()</v> <v>Key = Value = term()</v> - <v>Pos = int()</v> + <v>Pos = integer()</v> </type> <desc> <p>This function provides an efficient way to update one or more diff --git a/lib/stdlib/doc/src/file_sorter.xml b/lib/stdlib/doc/src/file_sorter.xml index ccb32659a0..a6b3633066 100644 --- a/lib/stdlib/doc/src/file_sorter.xml +++ b/lib/stdlib/doc/src/file_sorter.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>2001</year><year>2010</year> + <year>2001</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -89,7 +89,7 @@ considerably. The <c>keysort</c>, <c>keymerge</c> and <c>keycheck</c> functions do not accept ordering functions. </item> - <item><c>{unique, bool()}</c>. When sorting or merging files, + <item><c>{unique, boolean()}</c>. When sorting or merging files, only the first of a sequence of terms that compare equal (<c>==</c>) is output if this option is set to <c>true</c>. The default value is <c>false</c> which implies that all terms that @@ -112,7 +112,7 @@ overwritten. Temporary files are deleted unless some uncaught EXIT signal occurs. </item> - <item><c>{compressed, bool()}</c>. Temporary files and the + <item><c>{compressed, boolean()}</c>. Temporary files and the output file may be compressed. The default value <c>false</c> implies that written files are not compressed. Regardless of the value of the <c>compressed</c> @@ -128,39 +128,6 @@ merged at a time. This option should rarely be needed. </item> </list> - <p>To summarize, here is the syntax of the options:</p> - <list type="bulleted"> - <item> - <p><c>Options = [Option] | Option</c></p> - </item> - <item> - <p><c>Option = {header, HeaderLength} | {format, Format} | {order, Order} | {unique, bool()} | {tmpdir, TempDirectory} | {compressed, bool()} | {size, Size} | {no_files, NoFiles}</c></p> - </item> - <item> - <p><c>HeaderLength = int() > 0</c></p> - </item> - <item> - <p><c>Format = binary_term | term | binary | FormatFun</c></p> - </item> - <item> - <p><c>FormatFun = fun(Binary) -> Term</c></p> - </item> - <item> - <p><c>Order = ascending | descending | OrderFun</c></p> - </item> - <item> - <p><c>OrderFun = fun(Term, Term) -> bool()</c></p> - </item> - <item> - <p><c>TempDirectory = "" | file_name()</c></p> - </item> - <item> - <p><c>Size = int() >= 0</c></p> - </item> - <item> - <p><c>NoFiles = int() > 1</c></p> - </item> - </list> <p>As an alternative to sorting files, a function of one argument can be given as input. When called with the argument <c>read</c> the function is assumed to return <c>end_of_input</c> or @@ -234,8 +201,8 @@ output(L) -> occurs are:</p> <list type="bulleted"> <item> - <p><c>bad_object</c>, <c>{bad_object, FileName}</c>. - Applying the format function failed for some binary, + <p><c>bad_object</c>, <c>{bad_object, FileName}</c>. + Applying the format function failed for some binary, or the key(s) could not be extracted from some term.</p> </item> <item> @@ -243,148 +210,181 @@ output(L) -> to read some term.</p> </item> <item> - <p><c>{file_error, FileName, Reason2}</c>. See - <c>file(3)</c> for an explanation of <c>Reason2</c>.</p> + <p><c>{file_error, FileName, file:posix()}</c>. See + <c>file(3)</c> for an explanation of <c>file:posix()</c>.</p> </item> <item> - <p><c>{premature_eof, FileName}</c>. End-of-file was + <p><c>{premature_eof, FileName}</c>. End-of-file was encountered inside some binary term.</p> </item> </list> - <p><em>Types</em></p> - <pre> -Binary = binary() -FileName = file_name() -FileNames = [FileName] -ICommand = read | close -IReply = end_of_input | {end_of_input, Value} | {[Object], Infun} | InputReply -Infun = fun(ICommand) -> IReply -Input = FileNames | Infun -InputReply = Term -KeyPos = int() > 0 | [int() > 0] -OCommand = {value, Value} | [Object] | close -OReply = Outfun | OutputReply -Object = Term | Binary -Outfun = fun(OCommand) -> OReply -Output = FileName | Outfun -OutputReply = Term -Term = term() -Value = Term</pre> </description> + + <datatypes> + <datatype> + <name name="file_name"/><br/> + </datatype> + <datatype> + <name name="file_names"/><br/> + </datatype> + <datatype> + <name name="i_command"/><br/> + </datatype> + <datatype> + <name name="i_reply"/><br/> + </datatype> + <datatype> + <name name="infun"/><br/> + </datatype> + <datatype> + <name name="input"/><br/> + </datatype> + <datatype> + <name name="input_reply"/><br/> + </datatype> + <datatype> + <name name="o_command"/><br/> + </datatype> + <datatype> + <name name="o_reply"/><br/> + </datatype> + <datatype> + <name name="object"/><br/> + </datatype> + <datatype> + <name name="outfun"/><br/> + </datatype> + <datatype> + <name name="output"/><br/> + </datatype> + <datatype> + <name name="output_reply"/><br/> + </datatype> + <datatype> + <name name="value"/><br/> + </datatype> + <datatype> + <name name="options"/><br/> + </datatype> + <datatype> + <name name="option"/><br/> + </datatype> + <datatype> + <name name="format"/><br/> + </datatype> + <datatype> + <name name="format_fun"/><br/> + </datatype> + <datatype> + <name name="header_length"/><br/> + </datatype> + <datatype> + <name name="key_pos"/><br/> + </datatype> + <datatype> + <name name="no_files"/><br/> + </datatype> + <datatype> + <name name="order"/><br/> + </datatype> + <datatype> + <name name="order_fun"/><br/> + </datatype> + <datatype> + <name name="size"/><br/> + </datatype> + <datatype> + <name name="tmp_directory"/><br/> + </datatype> + <datatype> + <name name="reason"/><br/> + </datatype> + </datatypes> + <funcs> <func> - <name>sort(FileName) -> Reply</name> - <name>sort(Input, Output) -> Reply</name> - <name>sort(Input, Output, Options) -> Reply</name> + <name name="sort" arity="1"/> <fsummary>Sort terms on files.</fsummary> - <type> - <v>Reply = ok | {error, Reason} | InputReply | OutputReply</v> - </type> <desc> - <p>Sorts terms on files. - </p> - <p><c>sort(FileName)</c> is equivalent to - <c>sort([FileName], FileName)</c>. - </p> - <p><c>sort(Input, Output)</c> is equivalent to - <c>sort(Input, Output, [])</c>. - </p> - <p></p> + <p>Sorts terms on files. <c>sort(FileName)</c> is equivalent + to <c>sort([FileName], FileName)</c>.</p> + </desc> + </func> + <func> + <name name="sort" arity="2"/> + <name name="sort" arity="3"/> + <fsummary>Sort terms on files.</fsummary> + <desc> + <p>Sorts terms on files. <c>sort(Input, Output)</c> is + equivalent to <c>sort(Input, Output, [])</c>.</p> + </desc> + </func> + <func> + <name name="keysort" arity="2"/> + <fsummary>Sort terms on files by key.</fsummary> + <desc> + <p>Sorts tuples on files. <c>keysort(N, FileName)</c> is + equivalent to <c>keysort(N, [FileName], FileName)</c>.</p> </desc> </func> <func> - <name>keysort(KeyPos, FileName) -> Reply</name> - <name>keysort(KeyPos, Input, Output) -> Reply</name> - <name>keysort(KeyPos, Input, Output, Options) -> Reply</name> + <name name="keysort" arity="3"/> + <name name="keysort" arity="4"/> <fsummary>Sort terms on files by key.</fsummary> - <type> - <v>Reply = ok | {error, Reason} | InputReply | OutputReply</v> - </type> <desc> <p>Sorts tuples on files. The sort is performed on the - element(s) mentioned in <c>KeyPos</c>. If two tuples - compare equal (<c>==</c>) on one element, next element according to - <c>KeyPos</c> is compared. The sort is stable. - </p> - <p><c>keysort(N, FileName)</c> is equivalent to - <c>keysort(N, [FileName], FileName)</c>. - </p> + element(s) mentioned in <c><anno>KeyPos</anno></c>. If two + tuples compare equal (<c>==</c>) on one element, next + element according to <c><anno>KeyPos</anno></c> + is compared. The sort is stable.</p> <p><c>keysort(N, Input, Output)</c> is equivalent to - <c>keysort(N, Input, Output, [])</c>. - </p> - <p></p> + <c>keysort(N, Input, Output, [])</c>.</p> </desc> </func> <func> - <name>merge(FileNames, Output) -> Reply</name> - <name>merge(FileNames, Output, Options) -> Reply</name> + <name name="merge" arity="2"/> + <name name="merge" arity="3"/> <fsummary>Merge terms on files.</fsummary> - <type> - <v>Reply = ok | {error, Reason} | OutputReply</v> - </type> <desc> <p>Merges terms on files. Each input file is assumed to be - sorted. - </p> + sorted.</p> <p><c>merge(FileNames, Output)</c> is equivalent to - <c>merge(FileNames, Output, [])</c>. - </p> + <c>merge(FileNames, Output, [])</c>.</p> </desc> </func> <func> - <name>keymerge(KeyPos, FileNames, Output) -> Reply</name> - <name>keymerge(KeyPos, FileNames, Output, Options) -> Reply</name> + <name name="keymerge" arity="3"/> + <name name="keymerge" arity="4"/> <fsummary>Merge terms on files by key.</fsummary> - <type> - <v>Reply = ok | {error, Reason} | OutputReply</v> - </type> <desc> <p>Merges tuples on files. Each input file is assumed to be - sorted on key(s). - </p> + sorted on key(s).</p> <p><c>keymerge(KeyPos, FileNames, Output)</c> is equivalent - to <c>keymerge(KeyPos, FileNames, Output, [])</c>. - </p> - <p></p> + to <c>keymerge(KeyPos, FileNames, Output, [])</c>.</p> </desc> </func> <func> - <name>check(FileName) -> Reply</name> - <name>check(FileNames, Options) -> Reply</name> + <name name="check" arity="1"/> + <name name="check" arity="2"/> <fsummary>Check whether terms on files are sorted.</fsummary> - <type> - <v>Reply = {ok, [Result]} | {error, Reason}</v> - <v>Result = {FileName, TermPosition, Term}</v> - <v>TermPosition = int() > 1</v> - </type> <desc> <p>Checks files for sortedness. If a file is not sorted, the first out-of-order element is returned. The first term on a - file has position 1. - </p> + file has position 1.</p> <p><c>check(FileName)</c> is equivalent to - <c>check([FileName], [])</c>. - </p> + <c>check([FileName], [])</c>.</p> </desc> </func> <func> - <name>keycheck(KeyPos, FileName) -> CheckReply</name> - <name>keycheck(KeyPos, FileNames, Options) -> Reply</name> + <name name="keycheck" arity="2"/> + <name name="keycheck" arity="3"/> <fsummary>Check whether terms on files are sorted by key.</fsummary> - <type> - <v>Reply = {ok, [Result]} | {error, Reason}</v> - <v>Result = {FileName, TermPosition, Term}</v> - <v>TermPosition = int() > 1</v> - </type> <desc> <p>Checks files for sortedness. If a file is not sorted, the first out-of-order element is returned. The first term on a - file has position 1. - </p> + file has position 1.</p> <p><c>keycheck(KeyPos, FileName)</c> is equivalent - to <c>keycheck(KeyPos, [FileName], [])</c>. - </p> - <p></p> + to <c>keycheck(KeyPos, [FileName], [])</c>.</p> </desc> </func> </funcs> diff --git a/lib/stdlib/doc/src/filelib.xml b/lib/stdlib/doc/src/filelib.xml index c1c4ca9350..f3079c7337 100644 --- a/lib/stdlib/doc/src/filelib.xml +++ b/lib/stdlib/doc/src/filelib.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>2003</year><year>2009</year> + <year>2003</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -36,101 +36,94 @@ <description> <p>This module contains utilities on a higher level than the <c>file</c> module.</p> + <p>The module supports Unicode file names, so that it will match against regular expressions given in Unicode and that it will find and process raw file names (i.e. files named in a way that does not confirm to the expected encoding).</p> + <p>If the VM operates in Unicode file naming mode on a machine with transparent file naming, the <c>fun()</c> provided to <c>fold_files/5</c> needs to be prepared to handle binary file names.</p> + <p>For more information about raw file names, see the <seealso marker="kernel:file">file</seealso> module.</p> </description> - <section> - <title>DATA TYPES</title> - <code type="none"> -filename() = string() | atom() | DeepList -dirname() = filename() -DeepList = [char() | atom() | DeepList]</code> - </section> + <datatypes> + <datatype> + <name name="filename"/> + </datatype> + <datatype> + <name name="dirname"/> + </datatype> + </datatypes> <funcs> <func> - <name>ensure_dir(Name) -> ok | {error, Reason}</name> + <name name="ensure_dir" arity="1"/> <fsummary>Ensure that all parent directories for a file or directory exist.</fsummary> - <type> - <v>Name = filename() | dirname()</v> - <v>Reason = posix() -- see file(3)</v> - </type> <desc> <p>The <c>ensure_dir/1</c> function ensures that all parent - directories for the given file or directory name <c>Name</c> + directories for the given file or directory name <c><anno>Name</anno></c> exist, trying to create them if necessary.</p> <p>Returns <c>ok</c> if all parent directories already exist - or could be created, or <c>{error, Reason}</c> if some parent + or could be created, or <c>{error, <anno>Reason</anno>}</c> if some parent directory does not exist and could not be created for some reason.</p> </desc> </func> <func> - <name>file_size(Filename) -> integer()</name> + <name name="file_size" arity="1"/> <fsummary>Return the size in bytes of the file.</fsummary> <desc> <p>The <c>file_size</c> function returns the size of the given file.</p> </desc> </func> <func> - <name>fold_files(Dir, RegExp, Recursive, Fun, AccIn) -> AccOut </name> + <name name="fold_files" arity="5"/> <fsummary>Fold over all files matching a regular expression.</fsummary> - <type> - <v>Dir = dirname()</v> - <v>RegExp = regular_expression_string()</v> - <v>Recursive = true|false</v> - <v>Fun = fun(F, AccIn) -> AccOut</v> - <v>AccIn = AccOut = term()</v> - </type> <desc> <p>The <c>fold_files/5</c> function folds the function - <c>Fun</c> over all (regular) files <c>F</c> in the - directory <c>Dir</c> that match the regular expression <c>RegExp</c> + <c><anno>Fun</anno></c> over all (regular) files <c><anno>F</anno></c> in the + directory <c><anno>Dir</anno></c> that match the regular expression <c><anno>RegExp</anno></c> (see the <seealso marker="re">re</seealso> module for a description of the allowed regular expressions). - If <c>Recursive</c> is true all sub-directories to <c>Dir</c> + If <c><anno>Recursive</anno></c> is true all sub-directories to <c>Dir</c> are processed. The regular expression matching is done on just the filename without the directory part.</p> + + <p>If Unicode file name translation is in effect and the file + system is completely transparent, file names that cannot be + interpreted as Unicode may be encountered, in which case the + <c>fun()</c> must be prepared to handle raw file names + (i.e. binaries). If the regular expression contains + codepoints beyond 255, it will not match file names that do + not conform to the expected character encoding (i.e. are not + encoded in valid UTF-8).</p> + + <p>For more information about raw file names, see the + <seealso marker="kernel:file">file</seealso> module.</p> </desc> </func> <func> - <name>is_dir(Name) -> true | false</name> + <name name="is_dir" arity="1"/> <fsummary>Test whether Name refer to a directory or not</fsummary> - <type> - <v>Name = filename() | dirname()</v> - </type> <desc> - <p>The <c>is_dir/1</c> function returns <c>true</c> if <c>Name</c> + <p>The <c>is_dir/1</c> function returns <c>true</c> if <c><anno>Name</anno></c> refers to a directory, and <c>false</c> otherwise.</p> </desc> </func> <func> - <name>is_file(Name) -> true | false</name> + <name name="is_file" arity="1"/> <fsummary>Test whether Name refer to a file or directory.</fsummary> - <type> - <v>Name = filename() | dirname()</v> - </type> <desc> - <p>The <c>is_file/1</c> function returns <c>true</c> if <c>Name</c> + <p>The <c>is_file/1</c> function returns <c>true</c> if <c><anno>Name</anno></c> refers to a file or a directory, and <c>false</c> otherwise.</p> </desc> </func> <func> - <name>is_regular(Name) -> true | false</name> + <name name="is_regular" arity="1"/> <fsummary>Test whether Name refer to a (regular) file.</fsummary> - <type> - <v>Name = filename()</v> - </type> <desc> - <p>The <c>is_regular/1</c> function returns <c>true</c> if <c>Name</c> + <p>The <c>is_regular/1</c> function returns <c>true</c> if <c><anno>Name</anno></c> refers to a file (regular file), and <c>false</c> otherwise.</p> </desc> </func> <func> - <name>last_modified(Name) -> {{Year,Month,Day},{Hour,Min,Sec}} | 0</name> + <name name="last_modified" arity="1"/> <fsummary>Return the local date and time when a file was last modified.</fsummary> - <type> - <v>Name = filename() | dirname()</v> - </type> <desc> <p>The <c>last_modified/1</c> function returns the date and time the given file or directory was last modified, or 0 if the file @@ -138,14 +131,11 @@ DeepList = [char() | atom() | DeepList]</code> </desc> </func> <func> - <name>wildcard(Wildcard) -> list()</name> + <name name="wildcard" arity="1"/> <fsummary>Match filenames using Unix-style wildcards.</fsummary> - <type> - <v>Wildcard = filename() | dirname()</v> - </type> <desc> <p>The <c>wildcard/1</c> function returns a list of all files - that match Unix-style wildcard-string <c>Wildcard</c>.</p> + that match Unix-style wildcard-string <c><anno>Wildcard</anno></c>.</p> <p>The wildcard string looks like an ordinary filename, except that certain "wildcard characters" are interpreted in a special way. The following characters are special: @@ -160,6 +150,12 @@ DeepList = [char() | atom() | DeepList]</code> <p>Matches any number of characters up to the end of the filename, the next dot, or the next slash.</p> </item> + <tag>[Character1,Character2,...]</tag> + <item> + <p>Matches any of the characters listed. Two characters + separated by a hyphen will match a range of characters. + Example: <c>[A-Z]</c> will match any uppercase letter.</p> + </item> <tag>{Item,...}</tag> <item> <p>Alternation. Matches one of the alternatives.</p> @@ -199,15 +195,11 @@ DeepList = [char() | atom() | DeepList]</code> </desc> </func> <func> - <name>wildcard(Wildcard, Cwd) -> list()</name> + <name name="wildcard" arity="2"/> <fsummary>Match filenames using Unix-style wildcards starting at a specified directory.</fsummary> - <type> - <v>Wildcard = filename() | dirname()</v> - <v>Cwd = dirname()</v> - </type> <desc> <p>The <c>wildcard/2</c> function works like <c>wildcard/1</c>, - except that instead of the actual working directory, <c>Cwd</c> + except that instead of the actual working directory, <c><anno>Cwd</anno></c> will be used.</p> </desc> </func> diff --git a/lib/stdlib/doc/src/filename.xml b/lib/stdlib/doc/src/filename.xml index 0cf82fa48b..bc3a616d39 100644 --- a/lib/stdlib/doc/src/filename.xml +++ b/lib/stdlib/doc/src/filename.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1997</year><year>2009</year> + <year>1997</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -43,23 +43,16 @@ only, even if the arguments contain back slashes. Use <c>join/1</c> to normalize a file name by removing redundant directory separators.</p> + <p>The module supports raw file names in the way that if a binary is present, or the file name cannot be interpreted according to the return value of + <seealso marker="kernel:file#native_name_encoding/0">file:native_name_encoding/0</seealso>, a raw file name will also be returned. For example filename:join/1 provided with a path component being a binary (and also not being possible to interpret under the current native file name encoding) will result in a raw file name being returned (the join operation will have been performed of course). For more information about raw file names, see the <seealso marker="kernel:file">file</seealso> module.</p> </description> - <section> - <title>DATA TYPES</title> - <code type="none"> -name() = string() | atom() | DeepList - DeepList = [char() | atom() | DeepList]</code> - </section> <funcs> <func> - <name>absname(Filename) -> string()</name> + <name name="absname" arity="1"/> <fsummary>Convert a filename to an absolute name, relative the working directory</fsummary> - <type> - <v>Filename = name()</v> - </type> <desc> - <p>Converts a relative <c>Filename</c> and returns an absolute + <p>Converts a relative <c><anno>Filename</anno></c> and returns an absolute name. No attempt is made to create the shortest absolute name, because this can give incorrect results on file systems which allow links.</p> @@ -86,44 +79,33 @@ name() = string() | atom() | DeepList </desc> </func> <func> - <name>absname(Filename, Dir) -> string()</name> + <name name="absname" arity="2"/> <fsummary>Convert a filename to an absolute name, relative a specified directory</fsummary> - <type> - <v>Filename = name()</v> - <v>Dir = string()</v> - </type> <desc> <p>This function works like <c>absname/1</c>, except that the directory to which the file name should be made relative - is given explicitly in the <c>Dir</c> argument.</p> + is given explicitly in the <c><anno>Dir</anno></c> argument.</p> </desc> </func> <func> - <name>absname_join(Dir, Filename) -> string()</name> + <name name="absname_join" arity="2"/> <fsummary>Join an absolute directory with a relative filename</fsummary> - <type> - <v>Dir = string()</v> - <v>Filename = name()</v> - </type> <desc> <p>Joins an absolute directory with a relative filename. Similar to <c>join/2</c>, but on platforms with tight restrictions on raw filename length and no support for symbolic links (read: VxWorks), leading parent directory - components in <c>Filename</c> are matched against trailing - directory components in <c>Dir</c> so they can be removed + components in <c><anno>Filename</anno></c> are matched against trailing + directory components in <c><anno>Dir</anno></c> so they can be removed from the result - minimizing its length.</p> </desc> </func> <func> - <name>basename(Filename) -> string()</name> + <name name="basename" arity="1"/> <fsummary>Return the last component of a filename</fsummary> - <type> - <v>Filename = name()</v> - </type> <desc> - <p>Returns the last component of <c>Filename</c>, or - <c>Filename</c> itself if it does not contain any directory + <p>Returns the last component of <c><anno>Filename</anno></c>, or + <c><anno>Filename</anno></c> itself if it does not contain any directory separators.</p> <pre> 5> <input>filename:basename("foo").</input> @@ -135,14 +117,11 @@ name() = string() | atom() | DeepList </desc> </func> <func> - <name>basename(Filename, Ext) -> string()</name> + <name name="basename" arity="2"/> <fsummary>Return the last component of a filename, stripped of the specified extension</fsummary> - <type> - <v>Filename = Ext = name()</v> - </type> <desc> - <p>Returns the last component of <c>Filename</c> with the - extension <c>Ext</c> stripped. This function should be used + <p>Returns the last component of <c><anno>Filename</anno></c> with the + extension <c><anno>Ext</anno></c> stripped. This function should be used to remove a specific extension which might, or might not, be there. Use <c>rootname(basename(Filename))</c> to remove an extension that exists, but you are not sure which one it is.</p> @@ -160,13 +139,10 @@ name() = string() | atom() | DeepList </desc> </func> <func> - <name>dirname(Filename) -> string()</name> + <name name="dirname" arity="1"/> <fsummary>Return the directory part of a path name</fsummary> - <type> - <v>Filename = name()</v> - </type> <desc> - <p>Returns the directory part of <c>Filename</c>.</p> + <p>Returns the directory part of <c><anno>Filename</anno></c>.</p> <pre> 13> <input>filename:dirname("/usr/src/kalle.erl").</input> "/usr/src" @@ -178,13 +154,10 @@ name() = string() | atom() | DeepList </desc> </func> <func> - <name>extension(Filename) -> string()</name> + <name name="extension" arity="1"/> <fsummary>Return the file extension</fsummary> - <type> - <v>Filename = name()</v> - </type> <desc> - <p>Returns the file extension of <c>Filename</c>, including + <p>Returns the file extension of <c><anno>Filename</anno></c>, including the period. Returns an empty string if there is no extension.</p> <pre> 15> <input>filename:extension("foo.erl").</input> @@ -194,11 +167,8 @@ name() = string() | atom() | DeepList </desc> </func> <func> - <name>flatten(Filename) -> string()</name> + <name name="flatten" arity="1"/> <fsummary>Convert a filename to a flat string</fsummary> - <type> - <v>Filename = name()</v> - </type> <desc> <p>Converts a possibly deep list filename consisting of characters and atoms into the corresponding flat string @@ -206,14 +176,11 @@ name() = string() | atom() | DeepList </desc> </func> <func> - <name>join(Components) -> string()</name> + <name name="join" arity="1"/> <fsummary>Join a list of filename components with directory separators</fsummary> - <type> - <v>Components = [string()]</v> - </type> <desc> - <p>Joins a list of file name <c>Components</c> with directory - separators. If one of the elements of <c>Components</c> + <p>Joins a list of file name <c><anno>Components</anno></c> with directory + separators. If one of the elements of <c><anno>Components</anno></c> includes an absolute path, for example <c>"/xxx"</c>, the preceding elements, if any, are removed from the result.</p> <p>The result is "normalized":</p> @@ -233,24 +200,18 @@ name() = string() | atom() | DeepList </desc> </func> <func> - <name>join(Name1, Name2) -> string()</name> + <name name="join" arity="2"/> <fsummary>Join two filename components with directory separators</fsummary> - <type> - <v>Name1 = Name2 = string()</v> - </type> <desc> <p>Joins two file name components with directory separators. - Equivalent to <c>join([Name1, Name2])</c>.</p> + Equivalent to <c>join([<anno>Name1</anno>, <anno>Name2</anno>])</c>.</p> </desc> </func> <func> - <name>nativename(Path) -> string()</name> + <name name="nativename" arity="1"/> <fsummary>Return the native form of a file path</fsummary> - <type> - <v>Path = string()</v> - </type> <desc> - <p>Converts <c>Path</c> to a form accepted by the command shell + <p>Converts <c><anno>Path</anno></c> to a form accepted by the command shell and native applications on the current platform. On Windows, forward slashes is converted to backward slashes. On all platforms, the name is normalized as done by <c>join/1</c>.</p> @@ -263,7 +224,7 @@ name() = string() | atom() | DeepList </desc> </func> <func> - <name>pathtype(Path) -> absolute | relative | volumerelative</name> + <name name="pathtype" arity="1"/> <fsummary>Return the type of a path</fsummary> <desc> <p>Returns the type of path, one of <c>absolute</c>, @@ -293,16 +254,13 @@ name() = string() | atom() | DeepList </desc> </func> <func> - <name>rootname(Filename) -> string()</name> - <name>rootname(Filename, Ext) -> string()</name> + <name name="rootname" arity="1"/> + <name name="rootname" arity="2"/> <fsummary>Remove a filename extension</fsummary> - <type> - <v>Filename = Ext = name()</v> - </type> <desc> <p>Remove a filename extension. <c>rootname/2</c> works as <c>rootname/1</c>, except that the extension is removed only - if it is <c>Ext</c>.</p> + if it is <c><anno>Ext</anno></c>.</p> <pre> 20> <input>filename:rootname("/beam.src/kalle").</input> /beam.src/kalle" @@ -315,15 +273,11 @@ name() = string() | atom() | DeepList </desc> </func> <func> - <name>split(Filename) -> Components</name> + <name name="split" arity="1"/> <fsummary>Split a filename into its path components</fsummary> - <type> - <v>Filename = name()</v> - <v>Components = [string()]</v> - </type> <desc> <p>Returns a list whose elements are the path components of - <c>Filename</c>.</p> + <c><anno>Filename</anno></c>.</p> <pre> 24> <input>filename:split("/usr/local/bin").</input> ["/","usr","local","bin"] @@ -334,47 +288,38 @@ name() = string() | atom() | DeepList </desc> </func> <func> - <name>find_src(Beam) -> {SourceFile, Options} | {error,{ErrorReason,Module}}</name> - <name>find_src(Beam, Rules) -> {SourceFile, Options} | {error,{ErrorReason,Module}}</name> + <name name="find_src" arity="1"/> + <name name="find_src" arity="2"/> <fsummary>Find the filename and compiler options for a module</fsummary> - <type> - <v>Beam = Module | Filename</v> - <v> Module = atom()</v> - <v> Filename = string() | atom()</v> - <v>SourceFile = string()</v> - <v>Options = [Opt]</v> - <v> Opt = {i, string()} | {outdir, string()} | {d, atom()}</v> - <v>ErrorReason = non_existing | preloaded | interpreted</v> - </type> <desc> <p>Finds the source filename and compiler options for a module. The result can be fed to <c>compile:file/2</c> in order to compile the file again.</p> - <p>The <c>Beam</c> argument, which can be a string or an atom, + <p>The <c><anno>Beam</anno></c> argument, which can be a string or an atom, specifies either the module name or the path to the source code, with or without the <c>".erl"</c> extension. In either case, the module must be known by the code server, i.e. - <c>code:which(Module)</c> must succeed.</p> - <p><c>Rules</c> describes how the source directory can be found, + <c>code:which(<anno>Module</anno>)</c> must succeed.</p> + <p><c><anno>Rules</anno></c> describes how the source directory can be found, when the object code directory is known. It is a list of - tuples <c>{BinSuffix, SourceSuffix}</c> and is interpreted + tuples <c>{<anno>BinSuffix</anno>, <anno>SourceSuffix</anno>}</c> and is interpreted as follows: If the end of the directory name where the object - is located matches <c>BinSuffix</c>, then the source code - directory has the same name, but with <c>BinSuffix</c> - replaced by <c>SourceSuffix</c>. <c>Rules</c> defaults to:</p> + is located matches <c><anno>BinSuffix</anno></c>, then the source code + directory has the same name, but with <c><anno>BinSuffix</anno></c> + replaced by <c><anno>SourceSuffix</anno></c>. <c><anno>Rules</anno></c> defaults to:</p> <code type="none"> [{"", ""}, {"ebin", "src"}, {"ebin", "esrc"}]</code> <p>If the source file is found in the resulting directory, then the function returns that location together with - <c>Options</c>. Otherwise, the next rule is tried, and so on.</p> + <c><anno>Options</anno></c>. Otherwise, the next rule is tried, and so on.</p> - <p>The function returns <c>{SourceFile, Options}</c> if it succeeds. - <c>SourceFile</c> is the absolute path to the source file - without the <c>".erl"</c> extension. <c>Options</c> include + <p>The function returns <c>{<anno>SourceFile</anno>, <anno>Options</anno>}</c> if it succeeds. + <c><anno>SourceFile</anno></c> is the absolute path to the source file + without the <c>".erl"</c> extension. <c><anno>Options</anno></c> include the options which are necessary to recompile the file with <c>compile:file/2</c>, but excludes options such as <c>report</c> or <c>verbose</c> which do not change the way - code is generated. The paths in the <c>{outdir, Path}</c> + code is generated. The paths in the <c>{outdir, <anno>Path</anno>}</c> and <c>{i, Path}</c> options are guaranteed to be absolute.</p> diff --git a/lib/stdlib/doc/src/gb_sets.xml b/lib/stdlib/doc/src/gb_sets.xml index 60d8bcbfa3..f91fac9c82 100644 --- a/lib/stdlib/doc/src/gb_sets.xml +++ b/lib/stdlib/doc/src/gb_sets.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>2001</year><year>2010</year> + <year>2001</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -61,7 +61,6 @@ and do the same thing in the <c>sets</c> and <c>ordsets</c> modules. That is, by only changing the module name for each call, you can try out different set representations.</p> - <p></p> <list type="bulleted"> <item> <p><c>add_element/2</c></p> @@ -114,34 +113,32 @@ </list> </section> - <section> - <title>DATA TYPES</title> - <code type="none"> -gb_set() = a GB set</code> - </section> + <datatypes> + <datatype> + <name><marker id="type-gb_set">gb_set()</marker></name> + <desc><p>A GB set.</p></desc> + </datatype> + <datatype> + <name name="iter"/> + <desc><p>A GB set iterator.</p></desc> + </datatype> + </datatypes> <funcs> <func> - <name>add(Element, Set1) -> Set2</name> - <name>add_element(Element, Set1) -> Set2</name> + <name name="add" arity="2"/> + <name name="add_element" arity="2"/> <fsummary>Add a (possibly existing) element to a gb_set</fsummary> - <type> - <v>Element = term()</v> - <v>Set1 = Set2 = gb_set()</v> - </type> <desc> - <p>Returns a new gb_set formed from <c>Set1</c> with - <c>Element</c> inserted. If <c>Element</c> is already an - element in <c>Set1</c>, nothing is changed.</p> + <p>Returns a new gb_set formed from <c><anno>Set1</anno></c> with + <c><anno>Element</anno></c> inserted. If <c><anno>Element</anno></c> is already an + element in <c><anno>Set1</anno></c>, nothing is changed.</p> </desc> </func> <func> - <name>balance(Set1) -> Set2</name> + <name name="balance" arity="1"/> <fsummary>Rebalance tree representation of a gb_set</fsummary> - <type> - <v>Set1 = Set2 = gb_set()</v> - </type> <desc> - <p>Rebalances the tree representation of <c>Set1</c>. Note that + <p>Rebalances the tree representation of <c><anno>Set1</anno></c>. Note that this is rarely necessary, but may be motivated when a large number of elements have been deleted from the tree without further insertions. Rebalancing could then be forced in order @@ -150,208 +147,144 @@ gb_set() = a GB set</code> </desc> </func> <func> - <name>delete(Element, Set1) -> Set2</name> + <name name="delete" arity="2"/> <fsummary>Remove an element from a gb_set</fsummary> - <type> - <v>Element = term()</v> - <v>Set1 = Set2 = gb_set()</v> - </type> <desc> - <p>Returns a new gb_set formed from <c>Set1</c> with - <c>Element</c> removed. Assumes that <c>Element</c> is present - in <c>Set1</c>.</p> + <p>Returns a new gb_set formed from <c><anno>Set1</anno></c> with + <c><anno>Element</anno></c> removed. Assumes that <c><anno>Element</anno></c> is present + in <c><anno>Set1</anno></c>.</p> </desc> </func> <func> - <name>delete_any(Element, Set1) -> Set2</name> - <name>del_element(Element, Set1) -> Set2</name> + <name name="delete_any" arity="2"/> + <name name="del_element" arity="2"/> <fsummary>Remove a (possibly non-existing) element from a gb_set</fsummary> - <type> - <v>Element = term()</v> - <v>Set1 = Set2 = gb_set()</v> - </type> <desc> - <p>Returns a new gb_set formed from <c>Set1</c> with - <c>Element</c> removed. If <c>Element</c> is not an element - in <c>Set1</c>, nothing is changed.</p> + <p>Returns a new gb_set formed from <c><anno>Set1</anno></c> with + <c><anno>Element</anno></c> removed. If <c><anno>Element</anno></c> is not an element + in <c><anno>Set1</anno></c>, nothing is changed.</p> </desc> </func> <func> - <name>difference(Set1, Set2) -> Set3</name> - <name>subtract(Set1, Set2) -> Set3</name> + <name name="difference" arity="2"/> + <name name="subtract" arity="2"/> <fsummary>Return the difference of two gb_sets</fsummary> - <type> - <v>Set1 = Set2 = Set3 = gb_set()</v> - </type> <desc> - <p>Returns only the elements of <c>Set1</c> which are not also - elements of <c>Set2</c>.</p> + <p>Returns only the elements of <c><anno>Set1</anno></c> which are not also + elements of <c><anno>Set2</anno></c>.</p> </desc> </func> <func> - <name>empty() -> Set</name> - <name>new() -> Set</name> + <name name="empty" arity="0"/> + <name name="new" arity="0"/> <fsummary>Return an empty gb_set</fsummary> - <type> - <v>Set = gb_set()</v> - </type> <desc> <p>Returns a new empty gb_set.</p> </desc> </func> <func> - <name>filter(Pred, Set1) -> Set2</name> + <name name="filter" arity="2"/> <fsummary>Filter gb_set elements</fsummary> - <type> - <v>Pred = fun (E) -> bool()</v> - <v> E = term()</v> - <v>Set1 = Set2 = gb_set()</v> - </type> <desc> - <p>Filters elements in <c>Set1</c> using predicate function - <c>Pred</c>.</p> + <p>Filters elements in <c><anno>Set1</anno></c> using predicate function + <c><anno>Pred</anno></c>.</p> </desc> </func> <func> - <name>fold(Function, Acc0, Set) -> Acc1</name> + <name name="fold" arity="3"/> <fsummary>Fold over gb_set elements</fsummary> - <type> - <v>Function = fun (E, AccIn) -> AccOut</v> - <v>Acc0 = Acc1 = AccIn = AccOut = term()</v> - <v> E = term()</v> - <v>Set = gb_set()</v> - </type> <desc> - <p>Folds <c>Function</c> over every element in <c>Set</c> + <p>Folds <c><anno>Function</anno></c> over every element in <c><anno>Set</anno></c> returning the final value of the accumulator.</p> </desc> </func> <func> - <name>from_list(List) -> Set</name> + <name name="from_list" arity="1"/> <fsummary>Convert a list into a gb_set</fsummary> - <type> - <v>List = [term()]</v> - <v>Set = gb_set()</v> - </type> <desc> - <p>Returns a gb_set of the elements in <c>List</c>, where - <c>List</c> may be unordered and contain duplicates.</p> + <p>Returns a gb_set of the elements in <c><anno>List</anno></c>, where + <c><anno>List</anno></c> may be unordered and contain duplicates.</p> </desc> </func> <func> - <name>from_ordset(List) -> Set</name> + <name name="from_ordset" arity="1"/> <fsummary>Make a gb_set from an ordset list</fsummary> - <type> - <v>List = [term()]</v> - <v>Set = gb_set()</v> - </type> <desc> - <p>Turns an ordered-set list <c>List</c> into a gb_set. The list + <p>Turns an ordered-set list <c><anno>List</anno></c> into a gb_set. The list must not contain duplicates.</p> </desc> </func> <func> - <name>insert(Element, Set1) -> Set2</name> + <name name="insert" arity="2"/> <fsummary>Add a new element to a gb_set</fsummary> - <type> - <v>Element = term()</v> - <v>Set1 = Set2 = gb_set()</v> - </type> <desc> - <p>Returns a new gb_set formed from <c>Set1</c> with - <c>Element</c> inserted. Assumes that <c>Element</c> is not - present in <c>Set1</c>.</p> + <p>Returns a new gb_set formed from <c><anno>Set1</anno></c> with + <c><anno>Element</anno></c> inserted. Assumes that <c><anno>Element</anno></c> is not + present in <c><anno>Set1</anno></c>.</p> </desc> </func> <func> - <name>intersection(Set1, Set2) -> Set3</name> + <name name="intersection" arity="2"/> <fsummary>Return the intersection of two gb_sets</fsummary> - <type> - <v>Set1 = Set2 = Set3 = gb_set()</v> - </type> <desc> - <p>Returns the intersection of <c>Set1</c> and <c>Set2</c>.</p> + <p>Returns the intersection of <c><anno>Set1</anno></c> and <c><anno>Set2</anno></c>.</p> </desc> </func> <func> - <name>intersection(SetList) -> Set</name> + <name name="intersection" arity="1"/> <fsummary>Return the intersection of a list of gb_sets</fsummary> - <type> - <v>SetList = [gb_set()]</v> - <v>Set = gb_set()</v> - </type> <desc> <p>Returns the intersection of the non-empty list of gb_sets.</p> </desc> </func> <func> - <name>is_disjoint(Set1, Set2) -> bool()</name> + <name name="is_disjoint" arity="2"/> <fsummary>Check whether two gb_sets are disjoint</fsummary> - <type> - <v>Set1 = Set2 = gb_set()</v> - </type> <desc> - <p>Returns <c>true</c> if <c>Set1</c> and - <c>Set2</c> are disjoint (have no elements in common), + <p>Returns <c>true</c> if <c><anno>Set1</anno></c> and + <c><anno>Set2</anno></c> are disjoint (have no elements in common), and <c>false</c> otherwise.</p> </desc> </func> <func> - <name>is_empty(Set) -> bool()</name> + <name name="is_empty" arity="1"/> <fsummary>Test for empty gb_set</fsummary> - <type> - <v>Set = gb_set()</v> - </type> <desc> - <p>Returns <c>true</c> if <c>Set</c> is an empty set, and + <p>Returns <c>true</c> if <c><anno>Set</anno></c> is an empty set, and <c>false</c> otherwise.</p> </desc> </func> <func> - <name>is_member(Element, Set) -> bool()</name> - <name>is_element(Element, Set) -> bool()</name> + <name name="is_member" arity="2"/> + <name name="is_element" arity="2"/> <fsummary>Test for membership of a gb_set</fsummary> - <type> - <v>Element = term()</v> - <v>Set = gb_set()</v> - </type> <desc> - <p>Returns <c>true</c> if <c>Element</c> is an element of - <c>Set</c>, otherwise <c>false</c>.</p> + <p>Returns <c>true</c> if <c><anno>Element</anno></c> is an element of + <c><anno>Set</anno></c>, otherwise <c>false</c>.</p> </desc> </func> <func> - <name>is_set(Term) -> bool()</name> + <name name="is_set" arity="1"/> <fsummary>Test for a gb_set</fsummary> - <type> - <v>Term = term()</v> - </type> <desc> - <p>Returns <c>true</c> if <c>Set</c> appears to be a gb_set, + <p>Returns <c>true</c> if <c><anno>Term</anno></c> appears to be a gb_set, otherwise <c>false</c>.</p> </desc> </func> <func> - <name>is_subset(Set1, Set2) -> bool()</name> + <name name="is_subset" arity="2"/> <fsummary>Test for subset</fsummary> - <type> - <v>Set1 = Set2 = gb_set()</v> - </type> <desc> - <p>Returns <c>true</c> when every element of <c>Set1</c> is - also a member of <c>Set2</c>, otherwise <c>false</c>.</p> + <p>Returns <c>true</c> when every element of <c><anno>Set1</anno></c> is + also a member of <c><anno>Set2</anno></c>, otherwise <c>false</c>.</p> </desc> </func> <func> - <name>iterator(Set) -> Iter</name> + <name name="iterator" arity="1"/> <fsummary>Return an iterator for a gb_set</fsummary> - <type> - <v>Set = gb_set()</v> - <v>Iter = term()</v> - </type> <desc> <p>Returns an iterator that can be used for traversing the - entries of <c>Set</c>; see <c>next/1</c>. The implementation + entries of <c><anno>Set</anno></c>; see <c>next/1</c>. The implementation of this is very efficient; traversing the whole set using <c>next/1</c> is only slightly slower than getting the list of all elements using <c>to_list/1</c> and traversing that. @@ -361,118 +294,84 @@ gb_set() = a GB set</code> </desc> </func> <func> - <name>largest(Set) -> term()</name> + <name name="largest" arity="1"/> <fsummary>Return largest element</fsummary> - <type> - <v>Set = gb_set()</v> - </type> <desc> - <p>Returns the largest element in <c>Set</c>. Assumes that - <c>Set</c> is nonempty.</p> + <p>Returns the largest element in <c><anno>Set</anno></c>. Assumes that + <c><anno>Set</anno></c> is nonempty.</p> </desc> </func> <func> - <name>next(Iter1) -> {Element, Iter2} | none</name> + <name name="next" arity="1"/> <fsummary>Traverse a gb_set with an iterator</fsummary> - <type> - <v>Iter1 = Iter2 = Element = term()</v> - </type> <desc> - <p>Returns <c>{Element, Iter2}</c> where <c>Element</c> is the - smallest element referred to by the iterator <c>Iter1</c>, - and <c>Iter2</c> is the new iterator to be used for + <p>Returns <c>{<anno>Element</anno>, <anno>Iter2</anno>}</c> where <c><anno>Element</anno></c> is the + smallest element referred to by the iterator <c><anno>Iter1</anno></c>, + and <c><anno>Iter2</anno></c> is the new iterator to be used for traversing the remaining elements, or the atom <c>none</c> if no elements remain.</p> </desc> </func> <func> - <name>singleton(Element) -> gb_set()</name> + <name name="singleton" arity="1"/> <fsummary>Return a gb_set with one element</fsummary> - <type> - <v>Element = term()</v> - </type> <desc> - <p>Returns a gb_set containing only the element <c>Element</c>.</p> + <p>Returns a gb_set containing only the element <c><anno>Element</anno></c>.</p> </desc> </func> <func> - <name>size(Set) -> int()</name> + <name name="size" arity="1"/> <fsummary>Return the number of elements in a gb_set</fsummary> - <type> - <v>Set = gb_set()</v> - </type> <desc> - <p>Returns the number of elements in <c>Set</c>.</p> + <p>Returns the number of elements in <c><anno>Set</anno></c>.</p> </desc> </func> <func> - <name>smallest(Set) -> term()</name> + <name name="smallest" arity="1"/> <fsummary>Return smallest element</fsummary> - <type> - <v>Set = gb_set()</v> - </type> <desc> - <p>Returns the smallest element in <c>Set</c>. Assumes that - <c>Set</c> is nonempty.</p> + <p>Returns the smallest element in <c><anno>Set</anno></c>. Assumes that + <c><anno>Set</anno></c> is nonempty.</p> </desc> </func> <func> - <name>take_largest(Set1) -> {Element, Set2}</name> + <name name="take_largest" arity="1"/> <fsummary>Extract largest element</fsummary> - <type> - <v>Set1 = Set2 = gb_set()</v> - <v>Element = term()</v> - </type> <desc> - <p>Returns <c>{Element, Set2}</c>, where <c>Element</c> is the - largest element in <c>Set1</c>, and <c>Set2</c> is this set - with <c>Element</c> deleted. Assumes that <c>Set1</c> is + <p>Returns <c>{<anno>Element</anno>, <anno>Set2</anno>}</c>, where <c><anno>Element</anno></c> is the + largest element in <c><anno>Set1</anno></c>, and <c><anno>Set2</anno></c> is this set + with <c><anno>Element</anno></c> deleted. Assumes that <c><anno>Set1</anno></c> is nonempty.</p> </desc> </func> <func> - <name>take_smallest(Set1) -> {Element, Set2}</name> + <name name="take_smallest" arity="1"/> <fsummary>Extract smallest element</fsummary> - <type> - <v>Set1 = Set2 = gb_set()</v> - <v>Element = term()</v> - </type> <desc> - <p>Returns <c>{Element, Set2}</c>, where <c>Element</c> is the - smallest element in <c>Set1</c>, and <c>Set2</c> is this set - with <c>Element</c> deleted. Assumes that <c>Set1</c> is + <p>Returns <c>{<anno>Element</anno>, <anno>Set2</anno>}</c>, where <c><anno>Element</anno></c> is the + smallest element in <c><anno>Set1</anno></c>, and <c><anno>Set2</anno></c> is this set + with <c><anno>Element</anno></c> deleted. Assumes that <c><anno>Set1</anno></c> is nonempty.</p> </desc> </func> <func> - <name>to_list(Set) -> List</name> + <name name="to_list" arity="1"/> <fsummary>Convert a gb_set into a list</fsummary> - <type> - <v>Set = gb_set()</v> - <v>List = [term()]</v> - </type> <desc> - <p>Returns the elements of <c>Set</c> as a list.</p> + <p>Returns the elements of <c><anno>Set</anno></c> as a list.</p> </desc> </func> <func> - <name>union(Set1, Set2) -> Set3</name> + <name name="union" arity="2"/> <fsummary>Return the union of two gb_sets</fsummary> - <type> - <v>Set1 = Set2 = Set3 = gb_set()</v> - </type> <desc> - <p>Returns the merged (union) gb_set of <c>Set1</c> and - <c>Set2</c>.</p> + <p>Returns the merged (union) gb_set of <c><anno>Set1</anno></c> and + <c><anno>Set2</anno></c>.</p> </desc> </func> <func> - <name>union(SetList) -> Set</name> + <name name="union" arity="1"/> <fsummary>Return the union of a list of gb_sets</fsummary> - <type> - <v>SetList = [gb_set()]</v> - <v>Set = gb_set()</v> - </type> <desc> <p>Returns the merged (union) gb_set of the list of gb_sets.</p> </desc> diff --git a/lib/stdlib/doc/src/gb_trees.xml b/lib/stdlib/doc/src/gb_trees.xml index 94f40c28bd..65c866efbe 100644 --- a/lib/stdlib/doc/src/gb_trees.xml +++ b/lib/stdlib/doc/src/gb_trees.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>2001</year><year>2010</year> + <year>2001</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -57,20 +57,22 @@ trees. Behaviour is logarithmic (as it should be).</p> </section> - <section> - <title>DATA TYPES</title> - <code type="none"> -gb_tree() = a GB tree</code> - </section> + <datatypes> + <datatype> + <name><marker id="type-gb_tree">gb_tree()</marker></name> + <desc><p>A GB tree.</p></desc> + </datatype> + <datatype> + <name name="iter"/> + <desc><p>A GB tree iterator.</p></desc> + </datatype> + </datatypes> <funcs> <func> - <name>balance(Tree1) -> Tree2</name> + <name name="balance" arity="1"/> <fsummary>Rebalance a tree</fsummary> - <type> - <v>Tree1 = Tree2 = gb_tree()</v> - </type> <desc> - <p>Rebalances <c>Tree1</c>. Note that this is rarely necessary, + <p>Rebalances <c><anno>Tree1</anno></c>. Note that this is rarely necessary, but may be motivated when a large number of nodes have been deleted from the tree without further insertions. Rebalancing could then be forced in order to minimise lookup times, since @@ -78,139 +80,97 @@ gb_tree() = a GB tree</code> </desc> </func> <func> - <name>delete(Key, Tree1) -> Tree2</name> + <name name="delete" arity="2"/> <fsummary>Remove a node from a tree</fsummary> - <type> - <v>Key = term()</v> - <v>Tree1 = Tree2 = gb_tree()</v> - </type> <desc> - <p>Removes the node with key <c>Key</c> from <c>Tree1</c>; + <p>Removes the node with key <c><anno>Key</anno></c> from <c><anno>Tree1</anno></c>; returns new tree. Assumes that the key is present in the tree, crashes otherwise.</p> </desc> </func> <func> - <name>delete_any(Key, Tree1) -> Tree2</name> + <name name="delete_any" arity="2"/> <fsummary>Remove a (possibly non-existing) node from a tree</fsummary> - <type> - <v>Key = term()</v> - <v>Tree1 = Tree2 = gb_tree()</v> - </type> <desc> - <p>Removes the node with key <c>Key</c> from <c>Tree1</c> if + <p>Removes the node with key <c><anno>Key</anno></c> from <c><anno>Tree1</anno></c> if the key is present in the tree, otherwise does nothing; returns new tree.</p> </desc> </func> <func> - <name>empty() -> Tree</name> + <name name="empty" arity="0"/> <fsummary>Return an empty tree</fsummary> - <type> - <v>Tree = gb_tree()</v> - </type> <desc> <p>Returns a new empty tree</p> </desc> </func> <func> - <name>enter(Key, Val, Tree1) -> Tree2</name> + <name name="enter" arity="3"/> <fsummary>Insert or update key with value in a tree</fsummary> - <type> - <v>Key = Val = term()</v> - <v>Tree1 = Tree2 = gb_tree()</v> - </type> <desc> - <p>Inserts <c>Key</c> with value <c>Val</c> into <c>Tree1</c> if + <p>Inserts <c><anno>Key</anno></c> with value <c><anno>Val</anno></c> into <c><anno>Tree1</anno></c> if the key is not present in the tree, otherwise updates - <c>Key</c> to value <c>Val</c> in <c>Tree1</c>. Returns the + <c><anno>Key</anno></c> to value <c><anno>Val</anno></c> in <c><anno>Tree1</anno></c>. Returns the new tree.</p> </desc> </func> <func> - <name>from_orddict(List) -> Tree</name> + <name name="from_orddict" arity="1"/> <fsummary>Make a tree from an orddict</fsummary> - <type> - <v>List = [{Key, Val}]</v> - <v> Key = Val = term()</v> - <v>Tree = gb_tree()</v> - </type> <desc> - <p>Turns an ordered list <c>List</c> of key-value tuples into a + <p>Turns an ordered list <c><anno>List</anno></c> of key-value tuples into a tree. The list must not contain duplicate keys.</p> </desc> </func> <func> - <name>get(Key, Tree) -> Val</name> + <name name="get" arity="2"/> <fsummary>Look up a key in a tree, if present</fsummary> - <type> - <v>Key = Val = term()</v> - <v>Tree = gb_tree()</v> - </type> <desc> - <p>Retrieves the value stored with <c>Key</c> in <c>Tree</c>. + <p>Retrieves the value stored with <c><anno>Key</anno></c> in <c><anno>Tree</anno></c>. Assumes that the key is present in the tree, crashes otherwise.</p> </desc> </func> <func> - <name>lookup(Key, Tree) -> {value, Val} | none</name> + <name name="lookup" arity="2"/> <fsummary>Look up a key in a tree</fsummary> - <type> - <v>Key = Val = term()</v> - <v>Tree = gb_tree()</v> - </type> <desc> - <p>Looks up <c>Key</c> in <c>Tree</c>; returns - <c>{value, Val}</c>, or <c>none</c> if <c>Key</c> is not + <p>Looks up <c><anno>Key</anno></c> in <c><anno>Tree</anno></c>; returns + <c>{value, <anno>Val</anno>}</c>, or <c>none</c> if <c><anno>Key</anno></c> is not present.</p> </desc> </func> <func> - <name>insert(Key, Val, Tree1) -> Tree2</name> + <name name="insert" arity="3"/> <fsummary>Insert a new key and value in a tree</fsummary> - <type> - <v>Key = Val = term()</v> - <v>Tree1 = Tree2 = gb_tree()</v> - </type> <desc> - <p>Inserts <c>Key</c> with value <c>Val</c> into <c>Tree1</c>; + <p>Inserts <c><anno>Key</anno></c> with value <c><anno>Val</anno></c> into <c><anno>Tree1</anno></c>; returns the new tree. Assumes that the key is not present in the tree, crashes otherwise.</p> </desc> </func> <func> - <name>is_defined(Key, Tree) -> bool()</name> + <name name="is_defined" arity="2"/> <fsummary>Test for membership of a tree</fsummary> - <type> - <v>Tree = gb_tree()</v> - </type> <desc> - <p>Returns <c>true</c> if <c>Key</c> is present in <c>Tree</c>, + <p>Returns <c>true</c> if <c><anno>Key</anno></c> is present in <c><anno>Tree</anno></c>, otherwise <c>false</c>.</p> </desc> </func> <func> - <name>is_empty(Tree) -> bool()</name> + <name name="is_empty" arity="1"/> <fsummary>Test for empty tree</fsummary> - <type> - <v>Tree = gb_tree()</v> - </type> <desc> - <p>Returns <c>true</c> if <c>Tree</c> is an empty tree, and + <p>Returns <c>true</c> if <c><anno>Tree</anno></c> is an empty tree, and <c>false</c> otherwise.</p> </desc> </func> <func> - <name>iterator(Tree) -> Iter</name> + <name name="iterator" arity="1"/> <fsummary>Return an iterator for a tree</fsummary> - <type> - <v>Tree = gb_tree()</v> - <v>Iter = term()</v> - </type> <desc> <p>Returns an iterator that can be used for traversing the - entries of <c>Tree</c>; see <c>next/1</c>. The implementation + entries of <c><anno>Tree</anno></c>; see <c>next/1</c>. The implementation of this is very efficient; traversing the whole tree using <c>next/1</c> is only slightly slower than getting the list of all elements using <c>to_list/1</c> and traversing that. @@ -220,141 +180,99 @@ gb_tree() = a GB tree</code> </desc> </func> <func> - <name>keys(Tree) -> [Key]</name> + <name name="keys" arity="1"/> <fsummary>Return a list of the keys in a tree</fsummary> - <type> - <v>Tree = gb_tree()</v> - <v>Key = term()</v> - </type> <desc> - <p>Returns the keys in <c>Tree</c> as an ordered list.</p> + <p>Returns the keys in <c><anno>Tree</anno></c> as an ordered list.</p> </desc> </func> <func> - <name>largest(Tree) -> {Key, Val}</name> + <name name="largest" arity="1"/> <fsummary>Return largest key and value</fsummary> - <type> - <v>Tree = gb_tree()</v> - <v>Key = Val = term()</v> - </type> <desc> - <p>Returns <c>{Key, Val}</c>, where <c>Key</c> is the largest - key in <c>Tree</c>, and <c>Val</c> is the value associated + <p>Returns <c>{<anno>Key</anno>, <anno>Val</anno>}</c>, where <c><anno>Key</anno></c> is the largest + key in <c><anno>Tree</anno></c>, and <c><anno>Val</anno></c> is the value associated with this key. Assumes that the tree is nonempty.</p> </desc> </func> <func> - <name>map(Function, Tree1) -> Tree2</name> + <name name="map" arity="2"/> <fsummary>Return largest key and value</fsummary> - <type> - <v>Function = fun(K, V1) -> V2</v> - <v>Tree1 = Tree2 = gb_tree()</v> - </type> - <desc><p>maps the function F(K, V1) -> V2 to all key-value pairs - of the tree Tree1 and returns a new tree Tree2 with the same set of keys - as Tree1 and the new set of values V2.</p> + <desc><p>Maps the function F(<anno>K</anno>, <anno>V1</anno>) -> <anno>V2</anno> to all key-value pairs + of the tree <c><anno>Tree1</anno></c> and returns a new tree <c><anno>Tree2</anno></c> with the same set of keys + as <c><anno>Tree1</anno></c> and the new set of values <c><anno>V2</anno></c>.</p> </desc> </func> <func> - <name>next(Iter1) -> {Key, Val, Iter2} | none</name> + <name name="next" arity="1"/> <fsummary>Traverse a tree with an iterator</fsummary> - <type> - <v>Iter1 = Iter2 = Key = Val = term()</v> - </type> <desc> - <p>Returns <c>{Key, Val, Iter2}</c> where <c>Key</c> is the - smallest key referred to by the iterator <c>Iter1</c>, and - <c>Iter2</c> is the new iterator to be used for + <p>Returns <c>{<anno>Key</anno>, <anno>Val</anno>, <anno>Iter2</anno>}</c> where <c><anno>Key</anno></c> is the + smallest key referred to by the iterator <c><anno>Iter1</anno></c>, and + <c><anno>Iter2</anno></c> is the new iterator to be used for traversing the remaining nodes, or the atom <c>none</c> if no nodes remain.</p> </desc> </func> <func> - <name>size(Tree) -> int()</name> + <name name="size" arity="1"/> <fsummary>Return the number of nodes in a tree</fsummary> - <type> - <v>Tree = gb_tree()</v> - </type> <desc> - <p>Returns the number of nodes in <c>Tree</c>.</p> + <p>Returns the number of nodes in <c><anno>Tree</anno></c>.</p> </desc> </func> <func> - <name>smallest(Tree) -> {Key, Val}</name> + <name name="smallest" arity="1"/> <fsummary>Return smallest key and value</fsummary> - <type> - <v>Tree = gb_tree()</v> - <v>Key = Val = term()</v> - </type> <desc> - <p>Returns <c>{Key, Val}</c>, where <c>Key</c> is the smallest - key in <c>Tree</c>, and <c>Val</c> is the value associated + <p>Returns <c>{<anno>Key</anno>, <anno>Val</anno>}</c>, where <c><anno>Key</anno></c> is the smallest + key in <c><anno>Tree</anno></c>, and <c><anno>Val</anno></c> is the value associated with this key. Assumes that the tree is nonempty.</p> </desc> </func> <func> - <name>take_largest(Tree1) -> {Key, Val, Tree2}</name> + <name name="take_largest" arity="1"/> <fsummary>Extract largest key and value</fsummary> - <type> - <v>Tree1 = Tree2 = gb_tree()</v> - <v>Key = Val = term()</v> - </type> <desc> - <p>Returns <c>{Key, Val, Tree2}</c>, where <c>Key</c> is the - largest key in <c>Tree1</c>, <c>Val</c> is the value - associated with this key, and <c>Tree2</c> is this tree with + <p>Returns <c>{<anno>Key</anno>, <anno>Val</anno>, <anno>Tree2</anno>}</c>, where <c><anno>Key</anno></c> is the + largest key in <c><anno>Tree1</anno></c>, <c><anno>Val</anno></c> is the value + associated with this key, and <c><anno>Tree2</anno></c> is this tree with the corresponding node deleted. Assumes that the tree is nonempty.</p> </desc> </func> <func> - <name>take_smallest(Tree1) -> {Key, Val, Tree2}</name> + <name name="take_smallest" arity="1"/> <fsummary>Extract smallest key and value</fsummary> - <type> - <v>Tree1 = Tree2 = gb_tree()</v> - <v>Key = Val = term()</v> - </type> <desc> - <p>Returns <c>{Key, Val, Tree2}</c>, where <c>Key</c> is the - smallest key in <c>Tree1</c>, <c>Val</c> is the value - associated with this key, and <c>Tree2</c> is this tree with + <p>Returns <c>{<anno>Key</anno>, <anno>Val</anno>, <anno>Tree2</anno>}</c>, where <c><anno>Key</anno></c> is the + smallest key in <c><anno>Tree1</anno></c>, <c><anno>Val</anno></c> is the value + associated with this key, and <c><anno>Tree2</anno></c> is this tree with the corresponding node deleted. Assumes that the tree is nonempty.</p> </desc> </func> <func> - <name>to_list(Tree) -> [{Key, Val}]</name> + <name name="to_list" arity="1"/> <fsummary>Convert a tree into a list</fsummary> - <type> - <v>Tree = gb_tree()</v> - <v>Key = Val = term()</v> - </type> <desc> <p>Converts a tree into an ordered list of key-value tuples.</p> </desc> </func> <func> - <name>update(Key, Val, Tree1) -> Tree2</name> + <name name="update" arity="3"/> <fsummary>Update a key to new value in a tree</fsummary> - <type> - <v>Key = Val = term()</v> - <v>Tree1 = Tree2 = gb_tree()</v> - </type> <desc> - <p>Updates <c>Key</c> to value <c>Val</c> in <c>Tree1</c>; + <p>Updates <c><anno>Key</anno></c> to value <c><anno>Val</anno></c> in <c><anno>Tree1</anno></c>; returns the new tree. Assumes that the key is present in the tree.</p> </desc> </func> <func> - <name>values(Tree) -> [Val]</name> + <name name="values" arity="1"/> <fsummary>Return a list of the values in a tree</fsummary> - <type> - <v>Tree = gb_tree()</v> - <v>Val = term()</v> - </type> <desc> - <p>Returns the values in <c>Tree</c> as an ordered list, sorted + <p>Returns the values in <c><anno>Tree</anno></c> as an ordered list, sorted by their corresponding keys. Duplicates are not removed.</p> </desc> </func> diff --git a/lib/stdlib/doc/src/gen_event.xml b/lib/stdlib/doc/src/gen_event.xml index df09294de6..24bcb419fe 100644 --- a/lib/stdlib/doc/src/gen_event.xml +++ b/lib/stdlib/doc/src/gen_event.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2009</year> + <year>1996</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>gen_event</title> @@ -100,6 +100,20 @@ gen_event:stop -----> Module:terminate/2 the specified event manager does not exist or if bad arguments are given.</p> </description> + <datatypes> + <datatype> + <name name="handler"/> + </datatype> + <datatype> + <name name="handler_args"/> + </datatype> + <datatype> + <name name="add_handler_ret"/> + </datatype> + <datatype> + <name name="del_handler_ret"/> + </datatype> + </datatypes> <funcs> <func> <name>start_link() -> Result</name> @@ -630,12 +644,66 @@ gen_event:stop -----> Module:terminate/2 <p>The function should return the updated internal state.</p> </desc> </func> + <func> + <name>Module:format_status(Opt, [PDict, State]) -> Status</name> + <fsummary>Optional function for providing a term describing the + current event handler state.</fsummary> + <type> + <v>Opt = normal | terminate</v> + <v>PDict = [{Key, Value}]</v> + <v>State = term()</v> + <v>Status = term()</v> + </type> + <desc> + <note> + <p>This callback is optional, so event handler modules need + not export it. If a handler does not export this function, + the gen_event module uses the handler state directly for + the purposes described below.</p> + </note> + <p>This function is called by a gen_event process when:</p> + <list typed="bulleted"> + <item>One + of <seealso marker="sys#get_status/1">sys:get_status/1,2</seealso> + is invoked to get the gen_event status. <c>Opt</c> is set + to the atom <c>normal</c> for this case.</item> + <item>The event handler terminates abnormally and gen_event + logs an error. <c>Opt</c> is set to the + atom <c>terminate</c> for this case.</item> + </list> + <p>This function is useful for customising the form and + appearance of the event handler state for these cases. An + event handler callback module wishing to customise + the <c>sys:get_status/1,2</c> return value as well as how + its state appears in termination error logs exports an + instance of <c>format_status/2</c> that returns a term + describing the current state of the event handler.</p> + <p><c>PDict</c> is the current value of the gen_event's + process dictionary.</p> + <p><c>State</c> is the internal state of the event + handler.</p> + <p>The function should return <c>Status</c>, a term that + customises the details of the current state of the event + handler. Any term is allowed for <c>Status</c>. The + gen_event module uses <c>Status</c> as follows:</p> + <list typed="bulleted"> + <item>When <c>sys:get_status/1,2</c> is called, gen_event + ensures that its return value contains <c>Status</c> in + place of the event handler's actual state term.</item> + <item>When an event handler terminates abnormally, gen_event + logs <c>Status</c> in place of the event handler's actual + state term.</item> + </list> + <p>One use for this function is to return compact alternative + state representations to avoid having large state terms + printed in logfiles.</p> + </desc> + </func> </funcs> <section> <title>SEE ALSO</title> - <p><seealso marker="supervisor">supervisor(3)</seealso>, + <p><seealso marker="supervisor">supervisor(3)</seealso>, <seealso marker="sys">sys(3)</seealso></p> </section> </erlref> - diff --git a/lib/stdlib/doc/src/gen_fsm.xml b/lib/stdlib/doc/src/gen_fsm.xml index 739cd0bffd..421eeb4fd3 100644 --- a/lib/stdlib/doc/src/gen_fsm.xml +++ b/lib/stdlib/doc/src/gen_fsm.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2009</year> + <year>1996</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>gen_fsm</title> @@ -430,7 +430,6 @@ gen_fsm:sync_send_all_state_event -----> Module:handle_sync_event/4 denote a state of the state machine. <em>state data</em> is used to denote the internal state of the Erlang process which implements the state machine.</p> - <p></p> </section> <funcs> <func> @@ -438,7 +437,7 @@ gen_fsm:sync_send_all_state_event -----> Module:handle_sync_event/4 <fsummary>Initialize process and internal state name and state data.</fsummary> <type> <v>Args = term()</v> - <v>Return = {ok,StateName,StateData} | {ok,StateName,StateData,Timeout}</v> + <v>Result = {ok,StateName,StateData} | {ok,StateName,StateData,Timeout}</v> <v> | {ok,StateName,StateData,hibernate}</v> <v> | {stop,Reason} | ignore</v> <v> StateName = atom()</v> @@ -639,9 +638,9 @@ gen_fsm:sync_send_all_state_event -----> Module:handle_sync_event/4 <v>StateName = atom()</v> <v>StateData = term()</v> <v>Result = {next_state,NextStateName,NewStateData}</v> - <v> > | {next_state,NextStateName,NewStateData,Timeout}</v> - <v> > | {next_state,NextStateName,NewStateData,hibernate}</v> - <v> > | {stop,Reason,NewStateData}</v> + <v> | {next_state,NextStateName,NewStateData,Timeout}</v> + <v> | {next_state,NextStateName,NewStateData,hibernate}</v> + <v> | {stop,Reason,NewStateData}</v> <v> NextStateName = atom()</v> <v> NewStateData = term()</v> <v> Timeout = int()>0 | infinity</v> @@ -730,33 +729,58 @@ gen_fsm:sync_send_all_state_event -----> Module:handle_sync_event/4 </desc> </func> <func> - <name>Module:format_status(normal, [PDict, StateData]) -> Status</name> + <name>Module:format_status(Opt, [PDict, StateData]) -> Status</name> <fsummary>Optional function for providing a term describing the current gen_fsm status.</fsummary> <type> + <v>Opt = normal | terminate</v> <v>PDict = [{Key, Value}]</v> <v>StateData = term()</v> - <v>Status = [term()]</v> + <v>Status = term()</v> </type> <desc> - <p><em>This callback is optional, so callback modules need not - export it. The gen_fsm module provides a default - implementation of this function that returns the callback - module state data.</em></p> - <p>This function is called by a gen_fsm process when one - of <seealso marker="sys#get_status/1">sys:get_status/1,2</seealso> - is invoked to get the gen_fsm status. A callback module - wishing to customise the <c>sys:get_status/1,2</c> return - value exports an instance of <c>format_status/2</c> that - returns a term describing the current status of the - gen_fsm.</p> + <note> + <p>This callback is optional, so callback modules need not + export it. The gen_fsm module provides a default + implementation of this function that returns the callback + module state data.</p> + </note> + <p>This function is called by a gen_fsm process when:</p> + <list typed="bulleted"> + <item>One + of <seealso marker="sys#get_status/1">sys:get_status/1,2</seealso> + is invoked to get the gen_fsm status. <c>Opt</c> is set to + the atom <c>normal</c> for this case.</item> + <item>The gen_fsm terminates abnormally and logs an + error. <c>Opt</c> is set to the atom <c>terminate</c> for + this case.</item> + </list> + <p>This function is useful for customising the form and + appearance of the gen_fsm status for these cases. A callback + module wishing to customise the <c>sys:get_status/1,2</c> + return value as well as how its status appears in + termination error logs exports an instance + of <c>format_status/2</c> that returns a term describing the + current status of the gen_fsm.</p> <p><c>PDict</c> is the current value of the gen_fsm's process dictionary.</p> <p><c>StateData</c> is the internal state data of the gen_fsm.</p> - <p>The function should return <c>Status</c>, a list of one or - more terms that customise the details of the current state - and status of the gen_fsm.</p> + <p>The function should return <c>Status</c>, a term that + customises the details of the current state and status of + the gen_fsm. There are no restrictions on the + form <c>Status</c> can take, but for + the <c>sys:get_status/1,2</c> case (when <c>Opt</c> + is <c>normal</c>), the recommended form for + the <c>Status</c> value is <c>[{data, [{"StateData", + Term}]}]</c> where <c>Term</c> provides relevant details of + the gen_fsm state data. Following this recommendation isn't + required, but doing so will make the callback module status + consistent with the rest of the <c>sys:get_status/1,2</c> + return value.</p> + <p>One use for this function is to return compact alternative + state data representations to avoid having large state terms + printed in logfiles.</p> </desc> </func> </funcs> @@ -770,4 +794,3 @@ gen_fsm:sync_send_all_state_event -----> Module:handle_sync_event/4 <seealso marker="sys">sys(3)</seealso></p> </section> </erlref> - diff --git a/lib/stdlib/doc/src/gen_server.xml b/lib/stdlib/doc/src/gen_server.xml index 30c04d1d52..1045766e01 100644 --- a/lib/stdlib/doc/src/gen_server.xml +++ b/lib/stdlib/doc/src/gen_server.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2009</year> + <year>1996</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>gen_server</title> @@ -599,32 +599,57 @@ gen_server:abcast -----> Module:handle_cast/2 </desc> </func> <func> - <name>Module:format_status(normal, [PDict, State]) -> Status</name> + <name>Module:format_status(Opt, [PDict, State]) -> Status</name> <fsummary>Optional function for providing a term describing the current gen_server status.</fsummary> <type> + <v>Opt = normal | terminate</v> <v>PDict = [{Key, Value}]</v> <v>State = term()</v> - <v>Status = [term()]</v> + <v>Status = term()</v> </type> <desc> - <p><em>This callback is optional, so callback modules need not - export it. The gen_server module provides a default - implementation of this function that returns the callback - module state.</em></p> - <p>This function is called by a gen_server process when one + <note> + <p>This callback is optional, so callback modules need not + export it. The gen_server module provides a default + implementation of this function that returns the callback + module state.</p> + </note> + <p>This function is called by a gen_server process when:</p> + <list typed="bulleted"> + <item>One of <seealso marker="sys#get_status/1">sys:get_status/1,2</seealso> - is invoked to get the gen_server status. A callback module - wishing to customise the <c>sys:get_status/1,2</c> return - value exports an instance of <c>format_status/2</c> that - returns a term describing the current status of the - gen_server.</p> + is invoked to get the gen_server status. <c>Opt</c> is set + to the atom <c>normal</c> for this case.</item> + <item>The gen_server terminates abnormally and logs an + error. <c>Opt</c> is set to the atom <c>terminate</c> for this + case.</item> + </list> + <p>This function is useful for customising the form and + appearance of the gen_server status for these cases. A + callback module wishing to customise + the <c>sys:get_status/1,2</c> return value as well as how + its status appears in termination error logs exports an + instance of <c>format_status/2</c> that returns a term + describing the current status of the gen_server.</p> <p><c>PDict</c> is the current value of the gen_server's process dictionary.</p> <p><c>State</c> is the internal state of the gen_server.</p> - <p>The function should return <c>Status</c>, a list of one or - more terms that customise the details of the current state - and status of the gen_server.</p> + <p>The function should return <c>Status</c>, a term that + customises the details of the current state and status of + the gen_server. There are no restrictions on the + form <c>Status</c> can take, but for + the <c>sys:get_status/1,2</c> case (when <c>Opt</c> + is <c>normal</c>), the recommended form for + the <c>Status</c> value is <c>[{data, [{"State", + Term}]}]</c> where <c>Term</c> provides relevant details of + the gen_server state. Following this recommendation isn't + required, but doing so will make the callback module status + consistent with the rest of the <c>sys:get_status/1,2</c> + return value.</p> + <p>One use for this function is to return compact alternative + state representations to avoid having large state terms + printed in logfiles.</p> </desc> </func> </funcs> diff --git a/lib/stdlib/doc/src/io.xml b/lib/stdlib/doc/src/io.xml index efbb1fc078..667d758e29 100644 --- a/lib/stdlib/doc/src/io.xml +++ b/lib/stdlib/doc/src/io.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2010</year> + <year>1996</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -43,7 +43,7 @@ <p>As of R13A, data supplied to the <seealso marker="#put_chars/2">put_chars</seealso> function should be in the - <c>chardata()</c> format described below. This means that programs + <seealso marker="unicode#type-chardata"><c>unicode:chardata()</c></seealso> format. This means that programs supplying binaries to this function need to convert them to UTF-8 before trying to output the data on an <c>io_device()</c>.</p> @@ -64,72 +64,84 @@ </description> - <section> - <title>DATA TYPES</title> - <code type="none"> -io_device() - as returned by file:open/2, a process handling IO protocols</code> - - <code type="none"> -unicode_binary() = binary() with characters encoded in UTF-8 coding standard -unicode_char() = integer() representing valid unicode codepoint - -chardata() = charlist() | unicode_binary() + <datatypes> + <datatype> + <name name="device"/> + <desc> + <p>Either <c>standard_io</c>, <c>standard_error</c>, a + registered name, or a pid handling IO protocols (returned from + <seealso marker="file#open/2">file:open/2</seealso>).</p> + </desc> + </datatype> + <datatype> + <name name="opt_pair"/> + </datatype> + <datatype> + <name name="expand_fun"/> + </datatype> + <datatype> + <name name="encoding"/> + </datatype> + <datatype> + <name name="setopt"/> + </datatype> + <datatype> + <name name="format"/> + </datatype> + <datatype> + <name name="line"/> + </datatype> + <datatype> + <name name="prompt"/> + </datatype> + <datatype> + <name name="request_error"/> + </datatype> + <datatype> + <name name="error_description"/> + <desc><p>Whatever the I/O-server sends.</p></desc> + </datatype> + </datatypes> -charlist() = [unicode_char() | unicode_binary() | charlist()] - a unicode_binary is allowed as the tail of the list</code> - </section> <funcs> <func> - <name>columns([IoDevice]) -> {ok,int()} | {error, enotsup}</name> + <name name="columns" arity="0"/> + <name name="columns" arity="1"/> <fsummary>Get the number of columns of a device</fsummary> - <type> - <v>IoDevice = io_device()</v> - </type> <desc> <p>Retrieves the number of columns of the - <c>IoDevice</c> (i.e. the width of a terminal). The function + <c><anno>IoDevice</anno></c> (i.e. the width of a terminal). The function only succeeds for terminal devices, for all other devices the function returns <c>{error, enotsup}</c></p> </desc> </func> <func> - <name>put_chars([IoDevice,] IoData) -> ok</name> + <name name="put_chars" arity="1"/> + <name name="put_chars" arity="2"/> <fsummary>Write a list of characters</fsummary> - <type> - <v>IoDevice = io_device()</v> - <v>IoData = chardata()</v> - </type> <desc> - <p>Writes the characters of <c>IoData</c> to the io_server() - (<c>IoDevice</c>).</p> + <p>Writes the characters of <c><anno>CharData</anno></c> to the io_server() + (<c><anno>IoDevice</anno></c>).</p> </desc> </func> <func> - <name>nl([IoDevice]) -> ok</name> + <name name="nl" arity="0"/> + <name name="nl" arity="1"/> <fsummary>Write a newline</fsummary> - <type> - <v>IoDevice = io_device()</v> - </type> <desc> - <p>Writes new line to the standard output (<c>IoDevice</c>).</p> + <p>Writes new line to the standard output (<c><anno>IoDevice</anno></c>).</p> </desc> </func> <func> - <name>get_chars([IoDevice,] Prompt, Count) -> Data | eof</name> + <name name="get_chars" arity="2"/> + <name name="get_chars" arity="3"/> <fsummary>Read a specified number of characters</fsummary> - <type> - <v>IoDevice = io_device()</v> - <v>Prompt = atom() | string()</v> - <v>Count = int()</v> - <v>Data = [ unicode_char() ] | unicode_binary()</v> - </type> <desc> - <p>Reads <c>Count</c> characters from standard input - (<c>IoDevice</c>), prompting it with <c>Prompt</c>. It + <p>Reads <c><anno>Count</anno></c> characters from standard input + (<c><anno>IoDevice</anno></c>), prompting it with <c><anno>Prompt</anno></c>. It returns:</p> <taglist> - <tag><c>Data</c></tag> + <tag><c><anno>Data</anno></c></tag> <item> <p>The input characters. If the device supports Unicode, the data may represent codepoints larger than 255 (the @@ -141,7 +153,7 @@ charlist() = [unicode_char() | unicode_binary() | charlist()] <item> <p>End of file was encountered.</p> </item> - <tag><c>{error,Reason}</c></tag> + <tag><c>{error,<anno>Reason</anno>}</c></tag> <item> <p>Other (rare) error condition, for instance <c>{error,estale}</c> if reading from an NFS file system.</p> @@ -150,18 +162,14 @@ charlist() = [unicode_char() | unicode_binary() | charlist()] </desc> </func> <func> - <name>get_line([IoDevice,] Prompt) -> Data | eof | {error,Reason}</name> + <name name="get_line" arity="1"/> + <name name="get_line" arity="2"/> <fsummary>Read a line</fsummary> - <type> - <v>IoDevice = io_device()</v> - <v>Prompt = atom() | string()</v> - <v>Data = [ unicode_char() ] | unicode_binary()</v> - </type> <desc> - <p>Reads a line from the standard input (<c>IoDevice</c>), - prompting it with <c>Prompt</c>. It returns:</p> + <p>Reads a line from the standard input (<c><anno>IoDevice</anno></c>), + prompting it with <c><anno>Prompt</anno></c>. It returns:</p> <taglist> - <tag><c>Data</c></tag> + <tag><c><anno>Data</anno></c></tag> <item> <p>The characters in the line terminated by a LF (or end of file). If the device supports Unicode, @@ -174,7 +182,7 @@ charlist() = [unicode_char() | unicode_binary() | charlist()] <item> <p>End of file was encountered.</p> </item> - <tag><c>{error,Reason}</c></tag> + <tag><c>{error,<anno>Reason</anno>}</c></tag> <item> <p>Other (rare) error condition, for instance <c>{error,estale}</c> if reading from an NFS file system.</p> @@ -183,14 +191,9 @@ charlist() = [unicode_char() | unicode_binary() | charlist()] </desc> </func> <func> - <name>getopts([IoDevice]) -> Opts</name> + <name name="getopts" arity="0"/> + <name name="getopts" arity="1"/> <fsummary>Get the supported options and values from an I/O-server</fsummary> - <type> - <v>IoDevice = io_device()</v> - <v>Opts = [Opt]</v> - <v> Opt = {atom(),Value}</v> - <v> Value = term()</v> - </type> <desc> <p>This function requests all available options and their current values for a specific io_device(). Example:</p> <pre> @@ -210,17 +213,11 @@ charlist() = [unicode_char() | unicode_binary() | charlist()] </desc> </func> <func> - <name>setopts([IoDevice,] Opts) -> ok | {error, Reason}</name> + <name name="setopts" arity="1"/> + <name name="setopts" arity="2"/> <fsummary>Set options</fsummary> - <type> - <v>IoDevice = io_device()</v> - <v>Opts = [Opt]</v> - <v> Opt = atom() | {atom(),Value}</v> - <v> Value = term()</v> - <v>Reason = term()</v> - </type> <desc> - <p>Set options for the io_device() (<c>IoDevice</c>).</p> + <p>Set options for the io_device() (<c><anno>IoDevice</anno></c>).</p> <p>Possible options and values vary depending on the actual io_device(). For a list of supported options and their current values @@ -229,17 +226,17 @@ charlist() = [unicode_char() | unicode_binary() | charlist()] <p>The options and values supported by the current OTP io_devices are:</p> <taglist> - <tag><c>binary, list or {binary, bool()}</c></tag> + <tag><c>binary, list or {binary, boolean()}</c></tag> <item> <p>If set in binary mode (binary or {binary,true}), the io_server() sends binary data (encoded in UTF-8) as answers to the get_line, get_chars and, if possible, get_until requests (see the I/O protocol description in STDLIB User's Guide for details). The immediate effect is that <c>get_chars/2,3</c> and <c>get_line/1,2</c> return UTF-8 binaries instead of lists of chars for the affected device.</p> <p>By default, all io_devices in OTP are set in list mode, but the io functions can handle any of these modes and so should other, user written, modules behaving as clients to I/O-servers.</p> <p>This option is supported by the standard shell (group.erl), the 'oldshell' (user.erl) and the file I/O servers.</p> </item> - <tag><c>{echo, bool()}</c></tag> + <tag><c>{echo, boolean()}</c></tag> <item> <p>Denotes if the terminal should echo input. Only supported for the standard shell I/O-server (group.erl)</p> </item> - <tag><c>{expand_fun, fun()}</c></tag> + <tag><c>{expand_fun, expand_fun()}</c></tag> <item> <p>Provide a function for tab-completion (expansion) like the erlang shell. This function is called @@ -281,33 +278,24 @@ charlist() = [unicode_char() | unicode_binary() | charlist()] </desc> </func> <func> - <name>write([IoDevice,] Term) -> ok</name> + <name name="write" arity="1"/> + <name name="write" arity="2"/> <fsummary>Write a term</fsummary> - <type> - <v>IoDevice = io_device()</v> - <v>Term = term()</v> - </type> <desc> - <p>Writes the term <c>Term</c> to the standard output - (<c>IoDevice</c>).</p> + <p>Writes the term <c><anno>Term</anno></c> to the standard output + (<c><anno>IoDevice</anno></c>).</p> </desc> </func> <func> - <name>read([IoDevice,] Prompt) -> Result</name> + <name name="read" arity="1"/> + <name name="read" arity="2"/> <fsummary>Read a term</fsummary> - <type> - <v>IoDevice = io_device()</v> - <v>Prompt = atom() | string()</v> - <v>Result = {ok, Term} | eof | {error, ErrorInfo}</v> - <v> Term = term()</v> - <v> ErrorInfo -- see section Error Information below</v> - </type> <desc> - <p>Reads a term <c>Term</c> from the standard input - (<c>IoDevice</c>), prompting it with <c>Prompt</c>. It + <p>Reads a term <c><anno>Term</anno></c> from the standard input + (<c><anno>IoDevice</anno></c>), prompting it with <c><anno>Prompt</anno></c>. It returns:</p> <taglist> - <tag><c>{ok, Term}</c></tag> + <tag><c>{ok, <anno>Term</anno>}</c></tag> <item> <p>The parsing was successful.</p> </item> @@ -315,7 +303,7 @@ charlist() = [unicode_char() | unicode_binary() | charlist()] <item> <p>End of file was encountered.</p> </item> - <tag><c>{error, ErrorInfo}</c></tag> + <tag><c>{error, <anno>ErrorInfo</anno>}</c></tag> <item> <p>The parsing failed.</p> </item> @@ -323,31 +311,22 @@ charlist() = [unicode_char() | unicode_binary() | charlist()] </desc> </func> <func> - <name>read(IoDevice, Prompt, StartLine) -> Result</name> + <name name="read" arity="3"/> <fsummary>Read a term</fsummary> - <type> - <v>IoDevice = io_device()</v> - <v>Prompt = atom() | string()</v> - <v>StartLine = int()</v> - <v>Result = {ok, Term, EndLine} | {eof, EndLine} | {error, ErrorInfo, EndLine}</v> - <v> Term = term()</v> - <v> EndLine = int()</v> - <v> ErrorInfo -- see section Error Information below</v> - </type> <desc> - <p>Reads a term <c>Term</c> from <c>IoDevice</c>, prompting it - with <c>Prompt</c>. Reading starts at line number - <c>StartLine</c>. It returns:</p> + <p>Reads a term <c><anno>Term</anno></c> from <c><anno>IoDevice</anno></c>, prompting it + with <c><anno>Prompt</anno></c>. Reading starts at line number + <c><anno>StartLine</anno></c>. It returns:</p> <taglist> - <tag><c>{ok, Term, EndLine}</c></tag> + <tag><c>{ok, Term, <anno>EndLine</anno>}</c></tag> <item> <p>The parsing was successful.</p> </item> - <tag><c>{eof, EndLine}</c></tag> + <tag><c>{eof, <anno>EndLine</anno>}</c></tag> <item> <p>End of file was encountered.</p> </item> - <tag><c>{error, ErrorInfo, EndLine}</c></tag> + <tag><c>{error, <anno>ErrorInfo</anno>, <anno>ErrorLine</anno>}</c></tag> <item> <p>The parsing failed.</p> </item> @@ -355,22 +334,19 @@ charlist() = [unicode_char() | unicode_binary() | charlist()] </desc> </func> <func> - <name>fwrite(Format) -></name> - <name>fwrite([IoDevice,] Format, Data) -> ok</name> - <name>format(Format) -></name> - <name>format([IoDevice,] Format, Data) -> ok</name> + <name name="fwrite" arity="1"/> + <name name="fwrite" arity="2"/> + <name name="fwrite" arity="3"/> + <name name="format" arity="1"/> + <name name="format" arity="2"/> + <name name="format" arity="3"/> <fsummary>Write formatted output</fsummary> - <type> - <v>IoDevice = io_device()</v> - <v>Format = atom() | string() | binary()</v> - <v>Data = [term()]</v> - </type> <desc> - <p>Writes the items in <c>Data</c> (<c>[]</c>) on the standard - output (<c>IoDevice</c>) in accordance with <c>Format</c>. - <c>Format</c> contains plain characters which are copied to + <p>Writes the items in <c><anno>Data</anno></c> (<c>[]</c>) on the standard + output (<c><anno>IoDevice</anno></c>) in accordance with <c><anno>Format</anno></c>. + <c><anno>Format</anno></c> contains plain characters which are copied to the output device, and control sequences for formatting, see - below. If <c>Format</c> is an atom or a binary, it is first + below. If <c><anno>Format</anno></c> is an atom or a binary, it is first converted to a list with the aid of <c>atom_to_list/1</c> or <c>binary_to_list/1</c>.</p> <pre> @@ -463,10 +439,10 @@ ok</pre> <item> <p>Prints the argument with the <c>string</c> syntax. The argument is, if no Unicode translation modifier is present, an - <seealso marker="erts:erlang#iolist_definition">I/O list</seealso>, a binary, or an atom. If the Unicode translation modifier ('t') is in effect, the argument is chardata(), meaning that binaries are in UTF-8. The characters - are printed without quotes. In this format, the printed - argument is truncated to the given precision and field - width.</p> + iolist(), a binary, or an atom. If the Unicode translation modifier ('t') is in effect, the argument is unicode:chardata(), meaning that binaries are in UTF-8. The characters + are printed without quotes. The string is first truncated + by the given precision and then padded and justified + to the given field width. The default precision is the field width.</p> <p>This format can be used for printing any object and truncating the output so it fits a specified field:</p> <pre> @@ -475,6 +451,8 @@ ok</pre> ok 4> <input>io:fwrite("|~10s|~n", [io_lib:write({hey, hey, hey})]).</input> |{hey,hey,h| +5> <input>io:fwrite("|~-10.8s|~n", [io_lib:write({hey, hey, hey})]).</input> +|{hey,hey | ok</pre> <p>A list with integers larger than 255 is considered an error if the Unicode translation modifier is not given:</p> <pre> @@ -660,22 +638,15 @@ ok </desc> </func> <func> - <name>fread([IoDevice,] Prompt, Format) -> Result</name> + <name name="fread" arity="2"/> + <name name="fread" arity="3"/> <fsummary>Read formatted input</fsummary> - <type> - <v>IoDevice = io_device()</v> - <v>Prompt = atom() | string()</v> - <v>Format = string()</v> - <v>Result = {ok, Terms} | eof | {error, What}</v> - <v> Terms = [term()]</v> - <v> What = term()</v> - </type> <desc> - <p>Reads characters from the standard input (<c>IoDevice</c>), - prompting it with <c>Prompt</c>. Interprets the characters in - accordance with <c>Format</c>. <c>Format</c> contains control + <p>Reads characters from the standard input (<c><anno>IoDevice</anno></c>), + prompting it with <c><anno>Prompt</anno></c>. Interprets the characters in + accordance with <c><anno>Format</anno></c>. <c><anno>Format</anno></c> contains control sequences which directs the interpretation of the input.</p> - <p><c>Format</c> may contain:</p> + <p><c><anno>Format</anno></c> may contain:</p> <list type="bulleted"> <item> <p>White space characters (SPACE, TAB and NEWLINE) which @@ -789,19 +760,19 @@ Prompt> <input><Character beyond latin1 range not printable in this medium> </taglist> <p>It returns:</p> <taglist> - <tag><c>{ok, Terms}</c></tag> + <tag><c>{ok, <anno>Terms</anno>}</c></tag> <item> - <p>The read was successful and <c>Terms</c> is the list + <p>The read was successful and <c><anno>Terms</anno></c> is the list of successfully matched and read items.</p> </item> <tag><c>eof</c></tag> <item> <p>End of file was encountered.</p> </item> - <tag><c>{error, What}</c></tag> + <tag><c>{error, <anno>What</anno>}</c></tag> <item> <p>The read operation failed and the parameter - <c>What</c> gives a hint about the error.</p> + <c><anno>What</anno></c> gives a hint about the error.</p> </item> </taglist> </item> @@ -820,31 +791,21 @@ enter><input>:</input> <input>alan</input> <input>:</input> <input>joe</in </desc> </func> <func> - <name>rows([IoDevice]) -> {ok,int()} | {error, enotsup}</name> + <name name="rows" arity="0"/> + <name name="rows" arity="1"/> <fsummary>Get the number of rows of a device</fsummary> - <type> - <v>IoDevice = io_device()</v> - </type> <desc> <p>Retrieves the number of rows of the - <c>IoDevice</c> (i.e. the height of a terminal). The function + <c><anno>IoDevice</anno></c> (i.e. the height of a terminal). The function only succeeds for terminal devices, for all other devices the function returns <c>{error, enotsup}</c></p> </desc> </func> <func> - <name>scan_erl_exprs(Prompt) -></name> - <name>scan_erl_exprs([IoDevice,] Prompt, StartLine) -> Result</name> + <name name="scan_erl_exprs" arity="1"/> + <name name="scan_erl_exprs" arity="2"/> + <name name="scan_erl_exprs" arity="3"/> <fsummary>Read and tokenize Erlang expressions</fsummary> - <type> - <v>IoDevice = io_device()</v> - <v>Prompt = atom() | string()</v> - <v>StartLine = int()</v> - <v>Result = {ok, Tokens, EndLine} | {eof, EndLine} | {error, ErrorInfo, EndLine}</v> - <v> Tokens -- see erl_scan(3)</v> - <v> EndLine = int()</v> - <v> ErrorInfo -- see section Error Information below</v> - </type> <desc> <p>Reads data from the standard input (<c>IoDevice</c>), prompting it with <c>Prompt</c>. Reading starts at line number @@ -860,7 +821,7 @@ enter><input>:</input> <input>alan</input> <input>:</input> <input>joe</in <item> <p>End of file was encountered.</p> </item> - <tag><c>{error, ErrorInfo, EndLine}</c></tag> + <tag><c>{error, ErrorInfo, ErrorLine}</c></tag> <item> <p>An error occurred.</p> </item> @@ -876,22 +837,14 @@ enter><input>1.0er.</input> </desc> </func> <func> - <name>scan_erl_form(Prompt) -></name> - <name>scan_erl_form([IoDevice,] Prompt, StartLine) -> Result</name> + <name name="scan_erl_form" arity="1"/> + <name name="scan_erl_form" arity="2"/> + <name name="scan_erl_form" arity="3"/> <fsummary>Read and tokenize an Erlang form</fsummary> - <type> - <v>IoDevice = io_device()</v> - <v>Prompt = atom() | string()</v> - <v>StartLine = int()</v> - <v>Result = {ok, Tokens, EndLine} | {eof, EndLine} | {error, ErrorInfo, EndLine}</v> - <v> Tokens -- see erl_scan(3)</v> - <v> EndLine = int()</v> - <v> ErrorInfo -- see section Error Information below</v> - </type> <desc> - <p>Reads data from the standard input (<c>IoDevice</c>), - prompting it with <c>Prompt</c>. Starts reading at line number - <c>StartLine</c> (1). The data is tokenized as if it were an + <p>Reads data from the standard input (<c><anno>IoDevice</anno></c>), + prompting it with <c><anno>Prompt</anno></c>. Starts reading at line number + <c><anno>StartLine</anno></c> (1). The data is tokenized as if it were an Erlang form - one of the valid Erlang expressions in an Erlang source file - until a final <c>'.'</c> is reached. This last token is also returned. The return values are the @@ -899,26 +852,19 @@ enter><input>1.0er.</input> </desc> </func> <func> - <name>parse_erl_exprs(Prompt) -></name> - <name>parse_erl_exprs([IoDevice,] Prompt, StartLine) -> Result</name> + <name name="parse_erl_exprs" arity="1"/> + <name name="parse_erl_exprs" arity="2"/> + <name name="parse_erl_exprs" arity="3"/> + <type name="parse_ret"/> <fsummary>Read, tokenize and parse Erlang expressions</fsummary> - <type> - <v>IoDevice = io_device()</v> - <v>Prompt = atom() | string()</v> - <v>StartLine = int()</v> - <v>Result = {ok, Expr_list, EndLine} | {eof, EndLine} | {error, ErrorInfo, EndLine}</v> - <v> Expr_list -- see erl_parse(3)</v> - <v> EndLine = int()</v> - <v> ErrorInfo -- see section Error Information below</v> - </type> <desc> - <p>Reads data from the standard input (<c>IoDevice</c>), - prompting it with <c>Prompt</c>. Starts reading at line number - <c>StartLine</c> (1). The data is tokenized and parsed as if + <p>Reads data from the standard input (<c><anno>IoDevice</anno></c>), + prompting it with <c><anno>Prompt</anno></c>. Starts reading at line number + <c><anno>StartLine</anno></c> (1). The data is tokenized and parsed as if it were a sequence of Erlang expressions until a final '.' is reached. It returns:</p> <taglist> - <tag><c>{ok, Expr_list, EndLine}</c></tag> + <tag><c>{ok, ExprList, EndLine}</c></tag> <item> <p>The parsing was successful.</p> </item> @@ -926,7 +872,7 @@ enter><input>1.0er.</input> <item> <p>End of file was encountered.</p> </item> - <tag><c>{error, ErrorInfo, EndLine}</c></tag> + <tag><c>{error, ErrorInfo, ErrorLine}</c></tag> <item> <p>An error occurred.</p> </item> @@ -942,22 +888,15 @@ enter><input>abc("hey".</input> </desc> </func> <func> - <name>parse_erl_form(Prompt) -></name> - <name>parse_erl_form([IoDevice,] Prompt, StartLine) -> Result</name> + <name name="parse_erl_form" arity="1"/> + <name name="parse_erl_form" arity="2"/> + <name name="parse_erl_form" arity="3"/> + <type name="parse_form_ret"/> <fsummary>Read, tokenize and parse an Erlang form</fsummary> - <type> - <v>IoDevice = io_device()</v> - <v>Prompt = atom() | string()</v> - <v>StartLine = int()</v> - <v>Result = {ok, AbsForm, EndLine} | {eof, EndLine} | {error, ErrorInfo, EndLine}</v> - <v> AbsForm -- see erl_parse(3)</v> - <v> EndLine = int()</v> - <v> ErrorInfo -- see section Error Information below</v> - </type> <desc> - <p>Reads data from the standard input (<c>IoDevice</c>), - prompting it with <c>Prompt</c>. Starts reading at line number - <c>StartLine</c> (1). The data is tokenized and parsed as if + <p>Reads data from the standard input (<c><anno>IoDevice</anno></c>), + prompting it with <c><anno>Prompt</anno></c>. Starts reading at line number + <c><anno>StartLine</anno></c> (1). The data is tokenized and parsed as if it were an Erlang form - one of the valid Erlang expressions in an Erlang source file - until a final '.' is reached. It returns:</p> @@ -970,7 +909,7 @@ enter><input>abc("hey".</input> <item> <p>End of file was encountered.</p> </item> - <tag><c>{error, ErrorInfo, EndLine}</c></tag> + <tag><c>{error, ErrorInfo, ErrorLine}</c></tag> <item> <p>An error occurred.</p> </item> diff --git a/lib/stdlib/doc/src/io_lib.xml b/lib/stdlib/doc/src/io_lib.xml index 399f968c5f..506c1792f1 100644 --- a/lib/stdlib/doc/src/io_lib.xml +++ b/lib/stdlib/doc/src/io_lib.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2009</year> + <year>1996</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -38,14 +38,22 @@ flattening deep lists.</p> </description> - <section> - <title>DATA TYPES</title> - <code type="none"> -chars() = [char() | chars()]</code> - </section> + <datatypes> + <datatype> + <name name="chars"/> + </datatype> + <datatype> + <name name="continuation"/> + <desc><p>A continuation as returned by <seealso marker="#fread/3"><c>fread/3</c></seealso>.</p> + </desc> + </datatype> + <datatype> + <name name="depth"/> + </datatype> + </datatypes> <funcs> <func> - <name>nl() -> chars()</name> + <name name="nl" arity="0"/> <fsummary>Write a newline</fsummary> <desc> <p>Returns a character list which represents a new line @@ -53,16 +61,12 @@ chars() = [char() | chars()]</code> </desc> </func> <func> - <name>write(Term) -></name> - <name>write(Term, Depth) -> chars()</name> + <name name="write" arity="1"/> + <name name="write" arity="2"/> <fsummary>Write a term</fsummary> - <type> - <v>Term = term()</v> - <v>Depth = int()</v> - </type> <desc> - <p>Returns a character list which represents <c>Term</c>. The - <c>Depth</c> (-1) argument controls the depth of the + <p>Returns a character list which represents <c><anno>Term</anno></c>. The + <c><anno>Depth</anno></c> (-1) argument controls the depth of the structures written. When the specified depth is reached, everything below this level is replaced by "...". For example:</p> @@ -74,36 +78,26 @@ chars() = [char() | chars()]</code> </desc> </func> <func> - <name>print(Term) -></name> - <name>print(Term, Column, LineLength, Depth) -> chars()</name> + <name name="print" arity="1"/> + <name name="print" arity="4"/> <fsummary>Pretty print a term</fsummary> - <type> - <v>Term = term()</v> - <v>Column = LineLenght = Depth = int()</v> - </type> <desc> <p>Also returns a list of characters which represents - <c>Term</c>, but breaks representations which are longer than + <c><anno>Term</anno></c>, but breaks representations which are longer than one line into many lines and indents each line sensibly. It also tries to detect and output lists of printable characters - as strings. <c>Column</c> is the starting column (1), - <c>LineLength</c> the maximum line length (80), and - <c>Depth</c> (-1) the maximum print depth.</p> + as strings. <c><anno>Column</anno></c> is the starting column (1), + <c><anno>LineLength</anno></c> the maximum line length (80), and + <c><anno>Depth</anno></c> (-1) the maximum print depth.</p> </desc> </func> <func> - <name>fwrite(Format, Data) -></name> - <name>format(Format, Data) -> chars() | UnicodeList</name> + <name name="fwrite" arity="2"/> + <name name="format" arity="2"/> <fsummary>Write formatted output</fsummary> - <type> - <v>Format = atom() | string() | binary()</v> - <v>Data = [term()]</v> - <v>UnicodeList = [Unicode]</v> - <v>Unicode = int() representing valid unicode codepoint</v> - </type> <desc> - <p>Returns a character list which represents <c>Data</c> - formatted in accordance with <c>Format</c>. See + <p>Returns a character list which represents <c><anno>Data</anno></c> + formatted in accordance with <c><anno>Format</anno></c>. See <seealso marker="io#fwrite/1">io:fwrite/1,2,3</seealso> for a detailed description of the available formatting options. A fault is generated if there is an error in the format string or @@ -119,42 +113,32 @@ chars() = [char() | chars()]</code> </desc> </func> <func> - <name>fread(Format, String) -> Result</name> + <name name="fread" arity="2"/> <fsummary>Read formatted input</fsummary> - <type> - <v>Format = String = string()</v> - <v>Result = {ok, InputList, LeftOverChars} | {more, RestFormat, Nchars, InputStack} | {error, What}</v> - <v> InputList = chars()</v> - <v> LeftOverChars = string()</v> - <v> RestFormat = string()</v> - <v> Nchars = int()</v> - <v> InputStack = chars()</v> - <v> What = term()</v> - </type> <desc> - <p>Tries to read <c>String</c> in accordance with the control - sequences in <c>Format</c>. See + <p>Tries to read <c><anno>String</anno></c> in accordance with the control + sequences in <c><anno>Format</anno></c>. See <seealso marker="io#fread/3">io:fread/3</seealso> for a detailed description of the available formatting options. It is - assumed that <c>String</c> contains whole lines. It returns:</p> + assumed that <c><anno>String</anno></c> contains whole lines. It returns:</p> <taglist> - <tag><c>{ok, InputList, LeftOverChars}</c></tag> + <tag><c>{ok, <anno>InputList</anno>, <anno>LeftOverChars</anno>}</c></tag> <item> - <p>The string was read. <c>InputList</c> is the list of + <p>The string was read. <c><anno>InputList</anno></c> is the list of successfully matched and read items, and - <c>LeftOverChars</c> are the input characters not used.</p> + <c><anno>LeftOverChars</anno></c> are the input characters not used.</p> </item> - <tag><c>{more, RestFormat, Nchars, InputStack}</c></tag> + <tag><c>{more, <anno>RestFormat</anno>, <anno>Nchars</anno>, <anno>InputStack</anno>}</c></tag> <item> <p>The string was read, but more input is needed in order - to complete the original format string. <c>RestFormat</c> - is the remaining format string, <c>NChars</c> the number - of characters scanned, and <c>InputStack</c> is the + to complete the original format string. <c><anno>RestFormat</anno></c> + is the remaining format string, <c><anno>Nchars</anno></c> the number + of characters scanned, and <c><anno>InputStack</anno></c> is the reversed list of inputs matched up to that point.</p> </item> - <tag><c>{error, What}</c></tag> + <tag><c>{error, <anno>What</anno>}</c></tag> <item> - <p>The read operation failed and the parameter <c>What</c> + <p>The read operation failed and the parameter <c><anno>What</anno></c> gives a hint about the error.</p> </item> </taglist> @@ -165,17 +149,8 @@ chars() = [char() | chars()]</code> </desc> </func> <func> - <name>fread(Continuation, String, Format) -> Return</name> + <name name="fread" arity="3"/> <fsummary>Re-entrant formatted reader</fsummary> - <type> - <v>Continuation = see below</v> - <v>String = Format = string()</v> - <v>Return = {done, Result, LeftOverChars} | {more, Continuation}</v> - <v> Result = {ok, InputList} | eof | {error, What}</v> - <v> InputList = chars()</v> - <v> What = term()()</v> - <v> LeftOverChars = string()</v> - </type> <desc> <p>This is the re-entrant formatted reader. The continuation of the first call to the functions must be <c>[]</c>. Refer to @@ -184,114 +159,92 @@ chars() = [char() | chars()]</code> re-entrant input scheme works.</p> <p>The function returns:</p> <taglist> - <tag><c>{done, Result, LeftOverChars}</c></tag> + <tag><c>{done, <anno>Result</anno>, <anno>LeftOverChars</anno>}</c></tag> <item> <p>The input is complete. The result is one of the following:</p> <taglist> - <tag><c>{ok, InputList}</c></tag> + <tag><c>{ok, <anno>InputList</anno>}</c></tag> <item> - <p>The string was read. <c>InputList</c> is the list of + <p>The string was read. <c><anno>InputList</anno></c> is the list of successfully matched and read items, and - <c>LeftOverChars</c> are the remaining characters.</p> + <c><anno>LeftOverChars</anno></c> are the remaining characters.</p> </item> <tag><c>eof</c></tag> <item> <p>End of file has been encountered. - <c>LeftOverChars</c> are the input characters not + <c><anno>LeftOverChars</anno></c> are the input characters not used.</p> </item> - <tag><c>{error, What}</c></tag> + <tag><c>{error, <anno>What</anno>}</c></tag> <item> - <p>An error occurred and the parameter <c>What</c> gives + <p>An error occurred and the parameter <c><anno>What</anno></c> gives a hint about the error.</p> </item> </taglist> </item> - <tag><c>{more, Continuation}</c></tag> + <tag><c>{more, <anno>Continuation</anno>}</c></tag> <item> <p>More data is required to build a term. - <c>Continuation</c> must be passed to <c>fread/3</c>, + <c><anno>Continuation</anno></c> must be passed to <c>fread/3</c>, when more data becomes available.</p> </item> </taglist> </desc> </func> <func> - <name>write_atom(Atom) -> chars()</name> + <name name="write_atom" arity="1"/> <fsummary>Write an atom</fsummary> - <type> - <v>Atom = atom()</v> - </type> <desc> <p>Returns the list of characters needed to print the atom - <c>Atom</c>.</p> + <c><anno>Atom</anno></c>.</p> </desc> </func> <func> - <name>write_string(String) -> chars()</name> + <name name="write_string" arity="1"/> <fsummary>Write a string</fsummary> - <type> - <v>String = string()</v> - </type> <desc> - <p>Returns the list of characters needed to print <c>String</c> + <p>Returns the list of characters needed to print <c><anno>String</anno></c> as a string.</p> </desc> </func> <func> - <name>write_char(Integer) -> chars()</name> + <name name="write_char" arity="1"/> <fsummary>Write a character</fsummary> - <type> - <v>Integer = int()</v> - </type> <desc> <p>Returns the list of characters needed to print a character constant in the ISO-latin-1 character set.</p> </desc> </func> <func> - <name>indentation(String, StartIndent) -> int()</name> + <name name="indentation" arity="2"/> <fsummary>Indentation after printing string</fsummary> - <type> - <v>String = string()</v> - <v>StartIndent = int()</v> - </type> <desc> - <p>Returns the indentation if <c>String</c> has been printed, - starting at <c>StartIndent</c>.</p> + <p>Returns the indentation if <c><anno>String</anno></c> has been printed, + starting at <c><anno>StartIndent</anno></c>.</p> </desc> </func> <func> - <name>char_list(Term) -> bool()</name> + <name name="char_list" arity="1"/> <fsummary>Test for a list of characters</fsummary> - <type> - <v>Term = term()</v> - </type> <desc> - <p>Returns <c>true</c> if <c>Term</c> is a flat list of + <p>Returns <c>true</c> if <c><anno>Term</anno></c> is a flat list of characters in the ISO-latin-1 range, otherwise it returns <c>false</c>.</p> </desc> </func> <func> - <name>deep_char_list(Term) -> bool()</name> + <name name="deep_char_list" arity="1"/> <fsummary>Test for a deep list of characters</fsummary> - <type> - <v>Term = term()</v> - </type> <desc> - <p>Returns <c>true</c> if <c>Term</c> is a, possibly deep, list + <p>Returns <c>true</c> if <c><anno>Term</anno></c> is a, possibly deep, list of characters in the ISO-latin-1 range, otherwise it returns <c>false</c>.</p> </desc> </func> <func> - <name>printable_list(Term) -> bool()</name> + <name name="printable_list" arity="1"/> <fsummary>Test for a list of printable ISO-latin-1 characters</fsummary> - <type> - <v>Term = term()</v> - </type> <desc> - <p>Returns <c>true</c> if <c>Term</c> is a flat list of + <p>Returns <c>true</c> if <c><anno>Term</anno></c> is a flat list of printable ISO-latin-1 characters, otherwise it returns <c>false</c>.</p> </desc> </func> diff --git a/lib/stdlib/doc/src/io_protocol.xml b/lib/stdlib/doc/src/io_protocol.xml index 201787f7b5..3e8ab1affc 100644 --- a/lib/stdlib/doc/src/io_protocol.xml +++ b/lib/stdlib/doc/src/io_protocol.xml @@ -5,7 +5,7 @@ <header> <copyright> <year>1999</year> - <year>2009</year> + <year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -79,7 +79,7 @@ sends the reply to.</item> io_reply. The io-module in the Erlang standard library simply uses the pid() of the io_server as the ReplyAs datum, but a more complicated client could have several outstanding io-requests to the same server and -would then use i.e. a ref() or something else to differentiate among +would then use i.e. a reference() or something else to differentiate among the incoming io_reply's. The ReplyAs element should be considered opaque by the io_server. Note that the pid() of the server is not explicitly present in the io_reply. The reply can be sent from any @@ -195,7 +195,7 @@ latin1, Module, Function, Args} respectively. </p> below).</p> <p>The function will be called with the data the io_server finds on - it's device, returning {done, Result, RestChars} when enough data is + its device, returning {done, Result, RestChars} when enough data is read (in which case Result is sent to the client and RestChars are kept in the io_server as a buffer for subsequent input) or {more, Continuation}, indicating that more characters are needed to @@ -741,7 +741,7 @@ optimize anything however. It is important though that the returned data is of the right type depending on the options set, so we convert the lists to binaries in the correct encoding <em>if possible</em> before returning. The function supplied in the get_until request may, -as it's final result return anything, so only functions actually +as its final result return anything, so only functions actually returning lists can get them converted to binaries. If the request contained the encoding tag unicode, the lists can contain all unicode codepoints and the binaries should be in UTF-8, if the encoding tag diff --git a/lib/stdlib/doc/src/lib.xml b/lib/stdlib/doc/src/lib.xml index 046add48e8..19fb827cbf 100644 --- a/lib/stdlib/doc/src/lib.xml +++ b/lib/stdlib/doc/src/lib.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2009</year> + <year>1996</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -37,27 +37,23 @@ </description> <funcs> <func> - <name>flush_receive() -> void()</name> + <name name="flush_receive" arity="0"/> <fsummary>Flush messages</fsummary> <desc> <p>Flushes the message buffer of the current process.</p> </desc> </func> <func> - <name>error_message(Format, Args) -> ok</name> + <name name="error_message" arity="2"/> <fsummary>Print error message</fsummary> - <type> - <v>Format = atom() | string() | binary()</v> - <v>Args = [term()]</v> - </type> <desc> - <p>Prints error message <c>Args</c> in accordance with - <c>Format</c>. Similar to <c>io:format/2</c>, see + <p>Prints error message <c><anno>Args</anno></c> in accordance with + <c><anno>Format</anno></c>. Similar to <c>io:format/2</c>, see <seealso marker="io#fwrite/1">io(3)</seealso>.</p> </desc> </func> <func> - <name>progname() -> atom()</name> + <name name="progname" arity="0"/> <fsummary>Return name of Erlang start script</fsummary> <desc> <p>Returns the name of the script that started the current @@ -65,37 +61,24 @@ </desc> </func> <func> - <name>nonl(String1) -> String2</name> + <name name="nonl" arity="1"/> <fsummary>Remove last newline</fsummary> - <type> - <v>String1 = String2 = string()</v> - </type> <desc> <p>Removes the last newline character, if any, in - <c>String1</c>.</p> + <c><anno>String1</anno></c>.</p> </desc> </func> <func> - <name>send(To, Msg)</name> + <name name="send" arity="2"/> <fsummary>Send a message</fsummary> - <type> - <v>To = pid() | Name | {Name,Node}</v> - <v> Name = Node = atom()</v> - <v>Msg = term()</v> - </type> <desc> <p>This function to makes it possible to send a message using the <c>apply/3</c> BIF.</p> </desc> </func> <func> - <name>sendw(To, Msg)</name> + <name name="sendw" arity="2"/> <fsummary>Send a message and wait for an answer</fsummary> - <type> - <v>To = pid() | Name | {Name,Node}</v> - <v> Name = Node = atom()</v> - <v>Msg = term()</v> - </type> <desc> <p>As <c>send/2</c>, but waits for an answer. It is implemented as follows:</p> diff --git a/lib/stdlib/doc/src/lists.xml b/lib/stdlib/doc/src/lists.xml index 855a7e0244..6f3ed7af98 100644 --- a/lib/stdlib/doc/src/lists.xml +++ b/lib/stdlib/doc/src/lists.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2010</year> + <year>1996</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -48,7 +48,7 @@ <item><p>if x <c>F</c> y and y <c>F</c> x then x = y (<c>F</c> is antisymmetric);</p> </item> - <item><p>if x <c>F</c> y and and y <c>F</c> z then x <c>F</c> z + <item><p>if x <c>F</c> y and y <c>F</c> z then x <c>F</c> z (<c>F</c> is transitive);</p> </item> <item><p>x <c>F</c> y or y <c>F</c> x (<c>F</c> is total).</p> @@ -60,58 +60,41 @@ </description> <funcs> <func> - <name>all(Pred, List) -> bool()</name> + <name name="all" arity="2"/> <fsummary>Return true if all elements in the list satisfy<c>Pred</c></fsummary> - <type> - <v>Pred = fun(Elem) -> bool()</v> - <v> Elem = term()</v> - <v>List = [term()]</v> - </type> <desc> - <p>Returns <c>true</c> if <c>Pred(Elem)</c> returns - <c>true</c> for all elements <c>Elem</c> in <c>List</c>, + <p>Returns <c>true</c> if <c><anno>Pred</anno>(<anno>Elem</anno>)</c> returns + <c>true</c> for all elements <c><anno>Elem</anno></c> in <c><anno>List</anno></c>, otherwise <c>false</c>.</p> </desc> </func> <func> - <name>any(Pred, List) -> bool()</name> + <name name="any" arity="2"/> <fsummary>Return true if any of the elements in the list satisfies<c>Pred</c></fsummary> - <type> - <v>Pred = fun(Elem) -> bool()</v> - <v> Elem = term()</v> - <v>List = [term()]</v> - </type> <desc> - <p>Returns <c>true</c> if <c>Pred(Elem)</c> returns - <c>true</c> for at least one element <c>Elem</c> in - <c>List</c>.</p> + <p>Returns <c>true</c> if <c><anno>Pred</anno>(<anno>Elem</anno>)</c> returns + <c>true</c> for at least one element <c><anno>Elem</anno></c> in + <c><anno>List</anno></c>.</p> </desc> </func> <func> - <name>append(ListOfLists) -> List1</name> + <name name="append" arity="1"/> <fsummary>Append a list of lists</fsummary> - <type> - <v>ListOfLists = [List]</v> - <v>List = List1 = [term()]</v> - </type> <desc> <p>Returns a list in which all the sub-lists of - <c>ListOfLists</c> have been appended. For example:</p> + <c><anno>ListOfLists</anno></c> have been appended. For example:</p> <pre> > <input>lists:append([[1, 2, 3], [a, b], [4, 5, 6]]).</input> [1,2,3,a,b,4,5,6]</pre> </desc> </func> <func> - <name>append(List1, List2) -> List3</name> + <name name="append" arity="2"/> <fsummary>Append two lists</fsummary> - <type> - <v>List1 = List2 = List3 = [term()]</v> - </type> <desc> - <p>Returns a new list <c>List3</c> which is made from - the elements of <c>List1</c> followed by the elements of - <c>List2</c>. For example:</p> + <p>Returns a new list <c><anno>List3</anno></c> which is made from + the elements of <c><anno>List1</anno></c> followed by the elements of + <c><anno>List2</anno></c>. For example:</p> <pre> > <input>lists:append("abc", "def").</input> "abcdef"</pre> @@ -119,15 +102,11 @@ </desc> </func> <func> - <name>concat(Things) -> string()</name> + <name name="concat" arity="1"/> <fsummary>Concatenate a list of atoms</fsummary> - <type> - <v>Things = [Thing]</v> - <v> Thing = atom() | integer() | float() | string()</v> - </type> <desc> <p>Concatenates the text representation of the elements - of <c>Things</c>. The elements of <c>Things</c> can be atoms, + of <c><anno>Things</anno></c>. The elements of <c><anno>Things</anno></c> can be atoms, integers, floats or strings.</p> <pre> > <input>lists:concat([doc, '/', file, '.', 3]).</input> @@ -135,92 +114,64 @@ </desc> </func> <func> - <name>delete(Elem, List1) -> List2</name> + <name name="delete" arity="2"/> <fsummary>Delete an element from a list</fsummary> - <type> - <v>Elem = term()</v> - <v>List1 = List2 = [term()]</v> - </type> <desc> - <p>Returns a copy of <c>List1</c> where the first element - matching <c>Elem</c> is deleted, if there is such an + <p>Returns a copy of <c><anno>List1</anno></c> where the first element + matching <c><anno>Elem</anno></c> is deleted, if there is such an element.</p> </desc> </func> <func> - <name>dropwhile(Pred, List1) -> List2</name> + <name name="dropwhile" arity="2"/> <fsummary>Drop elements from a list while a predicate is true</fsummary> - <type> - <v>Pred = fun(Elem) -> bool()</v> - <v> Elem = term()</v> - <v>List1 = List2 = [term()]</v> - </type> <desc> - <p>Drops elements <c>Elem</c> from <c>List1</c> while - <c>Pred(Elem)</c> returns <c>true</c> and returns + <p>Drops elements <c><anno>Elem</anno></c> from <c><anno>List1</anno></c> while + <c><anno>Pred</anno>(<anno>Elem</anno>)</c> returns <c>true</c> and returns the remaining list.</p> </desc> </func> <func> - <name>duplicate(N, Elem) -> List</name> + <name name="duplicate" arity="2"/> <fsummary>Make N copies of element</fsummary> - <type> - <v>N = int()</v> - <v>Elem = term()</v> - <v>List = [term()]</v> - </type> <desc> - <p>Returns a list which contains N copies of the term - <c>Elem</c>. For example:</p> + <p>Returns a list which contains <c><anno>N</anno></c> copies of the term + <c><anno>Elem</anno></c>. For example:</p> <pre> > <input>lists:duplicate(5, xx).</input> [xx,xx,xx,xx,xx]</pre> </desc> </func> <func> - <name>filter(Pred, List1) -> List2</name> + <name name="filter" arity="2"/> <fsummary>Choose elements which satisfy a predicate</fsummary> - <type> - <v>Pred = fun(Elem) -> bool()</v> - <v> Elem = term()</v> - <v>List1 = List2 = [term()]</v> - </type> <desc> - <p><c>List2</c> is a list of all elements <c>Elem</c> in - <c>List1</c> for which <c>Pred(Elem)</c> returns + <p><c><anno>List2</anno></c> is a list of all elements <c><anno>Elem</anno></c> in + <c><anno>List1</anno></c> for which <c><anno>Pred</anno>(<anno>Elem</anno>)</c> returns <c>true</c>.</p> </desc> </func> <func> - <name>flatlength(DeepList) -> int()</name> + <name name="flatlength" arity="1"/> <fsummary>Length of flattened deep list</fsummary> - <type> - <v>DeepList = [term() | DeepList]</v> - </type> <desc> - <p>Equivalent to <c>length(flatten(DeepList))</c>, but more + <p>Equivalent to <c>length(flatten(<anno>DeepList</anno>))</c>, but more efficient.</p> </desc> </func> <func> - <name>flatmap(Fun, List1) -> List2</name> + <name name="flatmap" arity="2"/> <fsummary>Map and flatten in one pass</fsummary> - <type> - <v>Fun = fun(A) -> [B]</v> - <v>List1 = [A]</v> - <v>List2 = [B]</v> - <v> A = B = term()</v> - </type> <desc> - <p>Takes a function from <c>A</c>s to lists of <c>B</c>s, and a - list of <c>A</c>s (<c>List1</c>) and produces a list of - <c>B</c>s by applying the function to every element in - <c>List1</c> and appending the resulting lists.</p> + <p>Takes a function from <c><anno>A</anno></c>s to lists of <c><anno>B</anno></c>s, and a + list of <c><anno>A</anno></c>s (<c><anno>List1</anno></c>) and produces a list of + <c><anno>B</anno></c>s by applying the function to every element in + <c><anno>List1</anno></c> and appending the resulting lists.</p> <p>That is, <c>flatmap</c> behaves as if it had been defined as follows:</p> <code type="none"> flatmap(Fun, List1) -> - append(map(Fun, List1))</code> + append(map(Fun, List1)).</code> <p>Example:</p> <pre> > <input>lists:flatmap(fun(X)->[X,X] end, [a,b,c]).</input> @@ -228,43 +179,29 @@ flatmap(Fun, List1) -> </desc> </func> <func> - <name>flatten(DeepList) -> List</name> + <name name="flatten" arity="1"/> <fsummary>Flatten a deep list</fsummary> - <type> - <v>DeepList = [term() | DeepList]</v> - <v>List = [term()]</v> - </type> <desc> - <p>Returns a flattened version of <c>DeepList</c>.</p> + <p>Returns a flattened version of <c><anno>DeepList</anno></c>.</p> </desc> </func> <func> - <name>flatten(DeepList, Tail) -> List</name> + <name name="flatten" arity="2"/> <fsummary>Flatten a deep list</fsummary> - <type> - <v>DeepList = [term() | DeepList]</v> - <v>Tail = List = [term()]</v> - </type> <desc> - <p>Returns a flattened version of <c>DeepList</c> with the tail - <c>Tail</c> appended.</p> + <p>Returns a flattened version of <c><anno>DeepList</anno></c> with the tail + <c><anno>Tail</anno></c> appended.</p> </desc> </func> <func> - <name>foldl(Fun, Acc0, List) -> Acc1</name> + <name name="foldl" arity="3"/> <fsummary>Fold a function over a list</fsummary> - <type> - <v>Fun = fun(Elem, AccIn) -> AccOut</v> - <v> Elem = term()</v> - <v>Acc0 = Acc1 = AccIn = AccOut = term()</v> - <v>List = [term()]</v> - </type> <desc> - <p>Calls <c>Fun(Elem, AccIn)</c> on successive elements <c>A</c> - of <c>List</c>, starting with <c>AccIn == Acc0</c>. - <c>Fun/2</c> must return a new accumulator which is passed to + <p>Calls <c><anno>Fun</anno>(<anno>Elem</anno>, <anno>AccIn</anno>)</c> on successive elements <c>A</c> + of <c><anno>List</anno></c>, starting with <c><anno>AccIn</anno> == <anno>Acc0</anno></c>. + <c><anno>Fun</anno>/2</c> must return a new accumulator which is passed to the next call. The function returns the final value of - the accumulator. <c>Acc0</c> is returned if the list is empty. + the accumulator. <c><anno>Acc0</anno></c> is returned if the list is empty. For example:</p> <pre> > <input>lists:foldl(fun(X, Sum) -> X + Sum end, 0, [1,2,3,4,5]).</input> @@ -274,14 +211,8 @@ flatmap(Fun, List1) -> </desc> </func> <func> - <name>foldr(Fun, Acc0, List) -> Acc1</name> + <name name="foldr" arity="3"/> <fsummary>Fold a function over a list</fsummary> - <type> - <v>Fun = fun(Elem, AccIn) -> AccOut</v> - <v> Elem = term()</v> - <v>Acc0 = Acc1 = AccIn = AccOut = term()</v> - <v>List = [term()]</v> - </type> <desc> <p>Like <c>foldl/3</c>, but the list is traversed from right to left. For example:</p> @@ -297,33 +228,23 @@ flatmap(Fun, List1) -> </desc> </func> <func> - <name>foreach(Fun, List) -> void()</name> + <name name="foreach" arity="2"/> <fsummary>Apply a function to each element of a list</fsummary> - <type> - <v>Fun = fun(Elem) -> void()</v> - <v> Elem = term()</v> - <v>List = [term()]</v> - </type> <desc> - <p>Calls <c>Fun(Elem)</c> for each element <c>Elem</c> in - <c>List</c>. This function is used for its side effects and + <p>Calls <c><anno>Fun</anno>(<anno>Elem</anno>)</c> for each element <c><anno>Elem</anno></c> in + <c><anno>List</anno></c>. This function is used for its side effects and the evaluation order is defined to be the same as the order of the elements in the list.</p> </desc> </func> <func> - <name>keydelete(Key, N, TupleList1) -> TupleList2</name> + <name name="keydelete" arity="3"/> <fsummary>Delete an element from a list of tuples</fsummary> - <type> - <v>Key = term()</v> - <v>N = 1..tuple_size(Tuple)</v> - <v>TupleList1 = TupleList2 = [Tuple]</v> - <v> Tuple = tuple()</v> - </type> + <type_desc variable="N">1..tuple_size(Tuple)</type_desc> <desc> - <p>Returns a copy of <c>TupleList1</c> where the first - occurrence of a tuple whose <c>N</c>th element compares equal to - <c>Key</c> is deleted, if there is such a tuple.</p> + <p>Returns a copy of <c><anno>TupleList1</anno></c> where the first + occurrence of a tuple whose <c><anno>N</anno></c>th element compares equal to + <c><anno>Key</anno></c> is deleted, if there is such a tuple.</p> </desc> </func> <func> @@ -343,19 +264,14 @@ flatmap(Fun, List1) -> </desc> </func> <func> - <name>keymap(Fun, N, TupleList1) -> TupleList2</name> + <name name="keymap" arity="3"/> <fsummary>Map a function over a list of tuples</fsummary> - <type> - <v>Fun = fun(Term1) -> Term2</v> - <v> Term1 = Term2 = term()</v> - <v>N = 1..tuple_size(Tuple)</v> - <v>TupleList1 = TupleList2 = [tuple()]</v> - </type> + <type_desc variable="N">1..tuple_size(Tuple)</type_desc> <desc> <p>Returns a list of tuples where, for each tuple in - <c>TupleList1</c>, the <c>N</c>th element <c>Term1</c> of the tuple + <c><anno>TupleList1</anno></c>, the <c><anno>N</anno></c>th element <c><anno>Term1</anno></c> of the tuple has been replaced with the result of calling - <c>Fun(Term1)</c>.</p> + <c><anno>Fun</anno>(<anno>Term1</anno>)</c>.</p> <p>Examples:</p> <pre> > <input>Fun = fun(Atom) -> atom_to_list(Atom) end.</input> @@ -365,7 +281,7 @@ flatmap(Fun, List1) -> </desc> </func> <func> - <name>keymember(Key, N, TupleList) -> bool()</name> + <name>keymember(Key, N, TupleList) -> boolean()</name> <fsummary>Test for membership of a list of tuples</fsummary> <type> <v>Key = term()</v> @@ -380,37 +296,28 @@ flatmap(Fun, List1) -> </desc> </func> <func> - <name>keymerge(N, TupleList1, TupleList2) -> TupleList3</name> + <name name="keymerge" arity="3"/> <fsummary>Merge two key-sorted lists of tuples</fsummary> - <type> - <v>N = 1..tuple_size(Tuple)</v> - <v>TupleList1 = TupleList2 = TupleList3 = [Tuple]</v> - <v> Tuple = tuple()</v> - </type> + <type_desc variable="N">1..tuple_size(Tuple)</type_desc> <desc> - <p>Returns the sorted list formed by merging <c>TupleList1</c> - and <c>TupleList2</c>. The merge is performed on - the <c>N</c>th element of each tuple. Both <c>TupleList1</c> and - <c>TupleList2</c> must be key-sorted prior to evaluating this + <p>Returns the sorted list formed by merging <c><anno>TupleList1</anno></c> + and <c><anno>TupleList2</anno></c>. The merge is performed on + the <c><anno>N</anno></c>th element of each tuple. Both <c><anno>TupleList1</anno></c> and + <c><anno>TupleList2</anno></c> must be key-sorted prior to evaluating this function. When two tuples compare equal, the tuple from - <c>TupleList1</c> is picked before the tuple from - <c>TupleList2</c>.</p> + <c><anno>TupleList1</anno></c> is picked before the tuple from + <c><anno>TupleList2</anno></c>.</p> </desc> </func> <func> - <name>keyreplace(Key, N, TupleList1, NewTuple) -> TupleList2</name> + <name name="keyreplace" arity="4"/> <fsummary>Replace an element in a list of tuples</fsummary> - <type> - <v>Key = term()</v> - <v>N = 1..tuple_size(Tuple)</v> - <v>TupleList1 = TupleList2 = [Tuple]</v> - <v>NewTuple = Tuple = tuple()</v> - </type> + <type_desc variable="N">1..tuple_size(Tuple)</type_desc> <desc> - <p>Returns a copy of <c>TupleList1</c> where the first - occurrence of a <c>T</c> tuple whose <c>N</c>th element - compares equal to <c>Key</c> is replaced with - <c>NewTuple</c>, if there is such a tuple <c>T</c>.</p> + <p>Returns a copy of <c><anno>TupleList1</anno></c> where the first + occurrence of a <c>T</c> tuple whose <c><anno>N</anno></c>th element + compares equal to <c><anno>Key</anno></c> is replaced with + <c><anno>NewTuple</anno></c>, if there is such a tuple <c>T</c>.</p> </desc> </func> <func> @@ -433,97 +340,65 @@ flatmap(Fun, List1) -> </desc> </func> <func> - <name>keysort(N, TupleList1) -> TupleList2</name> + <name name="keysort" arity="2"/> <fsummary>Sort a list of tuples</fsummary> - <type> - <v>N = 1..tuple_size(Tuple)</v> - <v>TupleList1 = TupleList2 = [Tuple]</v> - <v> Tuple = tuple()</v> - </type> + <type_desc variable="N">1..tuple_size(Tuple)</type_desc> <desc> <p>Returns a list containing the sorted elements of the list - <c>TupleList1</c>. Sorting is performed on the <c>N</c>th - element of the tuples.</p> + <c><anno>TupleList1</anno></c>. Sorting is performed on the <c><anno>N</anno></c>th + element of the tuples. The sort is stable.</p> </desc> </func> <func> - <name>keystore(Key, N, TupleList1, NewTuple) -> TupleList2</name> + <name name="keystore" arity="4"/> <fsummary>Store an element in a list of tuples</fsummary> - <type> - <v>Key = term()</v> - <v>N = 1..tuple_size(Tuple)</v> - <v>TupleList1 = TupleList2 = [Tuple]</v> - <v>NewTuple = Tuple = tuple()</v> - </type> - <desc> - <p>Returns a copy of <c>TupleList1</c> where the first - occurrence of a tuple <c>T</c> whose <c>N</c>th element - compares equal to <c>Key</c> is replaced with - <c>NewTuple</c>, if there is such a tuple <c>T</c>. If there - is no such tuple <c>T</c> a copy of <c>TupleList1</c> where - [<c>NewTuple</c>] has been appended to the end is + <type_desc variable="N">1..tuple_size(Tuple)</type_desc> + <desc> + <p>Returns a copy of <c><anno>TupleList1</anno></c> where the first + occurrence of a tuple <c>T</c> whose <c><anno>N</anno></c>th element + compares equal to <c><anno>Key</anno></c> is replaced with + <c><anno>NewTuple</anno></c>, if there is such a tuple <c>T</c>. If there + is no such tuple <c>T</c> a copy of <c><anno>TupleList1</anno></c> where + [<c><anno>NewTuple</anno></c>] has been appended to the end is returned.</p> </desc> </func> <func> - <name>keytake(Key, N, TupleList1) -> {value, Tuple, TupleList2} - | false</name> + <name name="keytake" arity="3"/> <fsummary>Extract an element from a list of tuples</fsummary> - <type> - <v>Key = term()</v> - <v>N = 1..tuple_size(Tuple)</v> - <v>TupleList1 = TupleList2 = [Tuple]</v> - <v>Tuple = tuple()</v> - </type> + <type_desc variable="N">1..tuple_size(Tuple)</type_desc> <desc> - <p>Searches the list of tuples <c>TupleList1</c> for a tuple - whose <c>N</c>th element compares equal to <c>Key</c>. - Returns <c>{value, Tuple, TupleList2}</c> if such a tuple is - found, otherwise <c>false</c>. <c>TupleList2</c> is a copy - of <c>TupleList1</c> where the first occurrence of - <c>Tuple</c> has been removed.</p> + <p>Searches the list of tuples <c><anno>TupleList1</anno></c> for a tuple + whose <c><anno>N</anno></c>th element compares equal to <c><anno>Key</anno></c>. + Returns <c>{value, <anno>Tuple</anno>, <anno>TupleList2</anno>}</c> if such a tuple is + found, otherwise <c>false</c>. <c><anno>TupleList2</anno></c> is a copy + of <c><anno>TupleList1</anno></c> where the first occurrence of + <c><anno>Tuple</anno></c> has been removed.</p> </desc> </func> <func> - <name>last(List) -> Last</name> + <name name="last" arity="1"/> <fsummary>Return last element in a list</fsummary> - <type> - <v>List = [term()], length(List) > 0</v> - <v>Last = term()</v> - </type> <desc> - <p>Returns the last element in <c>List</c>.</p> + <p>Returns the last element in <c><anno>List</anno></c>.</p> </desc> </func> <func> - <name>map(Fun, List1) -> List2</name> + <name name="map" arity="2"/> <fsummary>Map a function over a list</fsummary> - <type> - <v>Fun = fun(A) -> B</v> - <v>List1 = [A]</v> - <v>List2 = [B]</v> - <v> A = B = term()</v> - </type> <desc> - <p>Takes a function from <c>A</c>s to <c>B</c>s, and a list of - <c>A</c>s and produces a list of <c>B</c>s by applying + <p>Takes a function from <c><anno>A</anno></c>s to <c><anno>B</anno></c>s, and a list of + <c><anno>A</anno></c>s and produces a list of <c><anno>B</anno></c>s by applying the function to every element in the list. This function is used to obtain the return values. The evaluation order is implementation dependent.</p> </desc> </func> <func> - <name>mapfoldl(Fun, Acc0, List1) -> {List2, Acc1}</name> + <name name="mapfoldl" arity="3"/> <fsummary>Map and fold in one pass</fsummary> - <type> - <v>Fun = fun(A, AccIn) -> {B, AccOut}</v> - <v>Acc0 = Acc1 = AccIn = AccOut = term()</v> - <v>List1 = [A]</v> - <v>List2 = [B]</v> - <v> A = B = term()</v> - </type> <desc> - <p><c>mapfold</c> combines the operations of <c>map/2</c> and + <p><c>mapfoldl</c> combines the operations of <c>map/2</c> and <c>foldl/3</c> into one pass. An example, summing the elements in a list and double them at the same time:</p> <pre> @@ -533,35 +408,24 @@ flatmap(Fun, List1) -> </desc> </func> <func> - <name>mapfoldr(Fun, Acc0, List1) -> {List2, Acc1}</name> + <name name="mapfoldr" arity="3"/> <fsummary>Map and fold in one pass</fsummary> - <type> - <v>Fun = fun(A, AccIn) -> {B, AccOut}</v> - <v>Acc0 = Acc1 = AccIn = AccOut = term()</v> - <v>List1 = [A]</v> - <v>List2 = [B]</v> - <v> A = B = term()</v> - </type> <desc> - <p><c>mapfold</c> combines the operations of <c>map/2</c> and + <p><c>mapfoldr</c> combines the operations of <c>map/2</c> and <c>foldr/3</c> into one pass.</p> </desc> </func> <func> - <name>max(List) -> Max</name> + <name name="max" arity="1"/> <fsummary>Return maximum element of a list</fsummary> - <type> - <v>List = [term()], length(List) > 0</v> - <v>Max = term()</v> - </type> <desc> - <p>Returns the first element of <c>List</c> that compares + <p>Returns the first element of <c><anno>List</anno></c> that compares greater than or equal to all other elements of - <c>List</c>.</p> + <c><anno>List</anno></c>.</p> </desc> </func> <func> - <name>member(Elem, List) -> bool()</name> + <name>member(Elem, List) -> boolean()</name> <fsummary>Test for membership of a list</fsummary> <type> <v>Elem = term()</v> @@ -573,112 +437,84 @@ flatmap(Fun, List1) -> </desc> </func> <func> - <name>merge(ListOfLists) -> List1</name> + <name name="merge" arity="1"/> <fsummary>Merge a list of sorted lists</fsummary> - <type> - <v>ListOfLists = [List]</v> - <v>List = List1 = [term()]</v> - </type> <desc> <p>Returns the sorted list formed by merging all the sub-lists - of <c>ListOfLists</c>. All sub-lists must be sorted prior to + of <c><anno>ListOfLists</anno></c>. All sub-lists must be sorted prior to evaluating this function. When two elements compare equal, the element from the sub-list with the lowest position in - <c>ListOfLists</c> is picked before the other element.</p> + <c><anno>ListOfLists</anno></c> is picked before the other element.</p> </desc> </func> <func> - <name>merge(List1, List2) -> List3</name> + <name name="merge" arity="2"/> <fsummary>Merge two sorted lists</fsummary> - <type> - <v>List1 = List2 = List3 = [term()]</v> - </type> <desc> - <p>Returns the sorted list formed by merging <c>List1</c> and - <c>List2</c>. Both <c>List1</c> and <c>List2</c> must be + <p>Returns the sorted list formed by merging <c><anno>List1</anno></c> and + <c><anno>List2</anno></c>. Both <c><anno>List1</anno></c> and <c><anno>List2</anno></c> must be sorted prior to evaluating this function. When two elements - compare equal, the element from <c>List1</c> is picked - before the element from <c>List2</c>.</p> + compare equal, the element from <c><anno>List1</anno></c> is picked + before the element from <c><anno>List2</anno></c>.</p> </desc> </func> <func> - <name>merge(Fun, List1, List2) -> List3</name> + <name name="merge" arity="3"/> <fsummary>Merge two sorted list</fsummary> - <type> - <v>Fun = fun(A, B) -> bool()</v> - <v>List1 = [A]</v> - <v>List2 = [B]</v> - <v>List3 = [A | B]</v> - <v> A = B = term()</v> - </type> <desc> - <p>Returns the sorted list formed by merging <c>List1</c> and - <c>List2</c>. Both <c>List1</c> and <c>List2</c> must be + <p>Returns the sorted list formed by merging <c><anno>List1</anno></c> and + <c><anno>List2</anno></c>. Both <c><anno>List1</anno></c> and <c><anno>List2</anno></c> must be sorted according to the <seealso marker="#ordering_function">ordering function</seealso> - <c>Fun</c> prior to evaluating this function. <c>Fun(A, - B)</c> should return <c>true</c> if <c>A</c> compares less - than or equal to <c>B</c> in the ordering, <c>false</c> + <c><anno>Fun</anno></c> prior to evaluating this function. <c><anno>Fun</anno>(<anno>A</anno>, + <anno>B</anno>)</c> should return <c>true</c> if <c><anno>A</anno></c> compares less + than or equal to <c><anno>B</anno></c> in the ordering, <c>false</c> otherwise. When two elements compare equal, the element from - <c>List1</c> is picked before the element from - <c>List2</c>.</p> + <c><anno>List1</anno></c> is picked before the element from + <c><anno>List2</anno></c>.</p> </desc> </func> <func> - <name>merge3(List1, List2, List3) -> List4</name> + <name name="merge3" arity="3"/> <fsummary>Merge three sorted lists</fsummary> - <type> - <v>List1 = List2 = List3 = List4 = [term()]</v> - </type> <desc> - <p>Returns the sorted list formed by merging <c>List1</c>, - <c>List2</c> and <c>List3</c>. All of <c>List1</c>, - <c>List2</c> and <c>List3</c> must be sorted prior to + <p>Returns the sorted list formed by merging <c><anno>List1</anno></c>, + <c><anno>List2</anno></c> and <c><anno>List3</anno></c>. All of <c><anno>List1</anno></c>, + <c><anno>List2</anno></c> and <c><anno>List3</anno></c> must be sorted prior to evaluating this function. When two elements compare equal, - the element from <c>List1</c>, if there is such an element, + the element from <c><anno>List1</anno></c>, if there is such an element, is picked before the other element, otherwise the element - from <c>List2</c> is picked before the element from - <c>List3</c>.</p> + from <c><anno>List2</anno></c> is picked before the element from + <c><anno>List3</anno></c>.</p> </desc> </func> <func> - <name>min(List) -> Min</name> + <name name="min" arity="1"/> <fsummary>Return minimum element of a list</fsummary> - <type> - <v>List = [term()], length(List) > 0</v> - <v>Min = term()</v> - </type> <desc> - <p>Returns the first element of <c>List</c> that compares + <p>Returns the first element of <c><anno>List</anno></c> that compares less than or equal to all other elements of - <c>List</c>.</p> + <c><anno>List</anno></c>.</p> </desc> </func> <func> - <name>nth(N, List) -> Elem</name> + <name name="nth" arity="2"/> <fsummary>Return the Nth element of a list</fsummary> - <type> - <v>N = 1..length(List)</v> - <v>List = [term()]</v> - <v>Elem = term()</v> - </type> + <type_desc variable="N">1..length(List)</type_desc> <desc> - <p>Returns the <c>N</c>th element of <c>List</c>. For example:</p> + <p>Returns the <c><anno>N</anno></c>th element of <c><anno>List</anno></c>. For example:</p> <pre> > <input>lists:nth(3, [a, b, c, d, e]).</input> c</pre> </desc> </func> <func> - <name>nthtail(N, List1) -> Tail</name> + <name name="nthtail" arity="2"/> <fsummary>Return the Nth tail of a list</fsummary> - <type> - <v>N = 0..length(List1)</v> - <v>List1 = Tail = [term()]</v> - </type> + <type_desc variable="N">0..length(List)</type_desc> <desc> - <p>Returns the <c>N</c>th tail of <c>List</c>, that is, the sublist of - <c>List</c> starting at <c>N+1</c> and continuing up to + <p>Returns the <c><anno>N</anno></c>th tail of <c><anno>List</anno></c>, that is, the sublist of + <c><anno>List</anno></c> starting at <c><anno>N</anno>+1</c> and continuing up to the end of the list. For example:</p> <pre> > <input>lists:nthtail(3, [a, b, c, d, e]).</input> @@ -692,18 +528,13 @@ c</pre> </desc> </func> <func> - <name>partition(Pred, List) -> {Satisfying, NonSatisfying}</name> + <name name="partition" arity="2"/> <fsummary>Partition a list into two lists based on a predicate</fsummary> - <type> - <v>Pred = fun(Elem) -> bool()</v> - <v> Elem = term()</v> - <v>List = Satisfying = NonSatisfying = [term()]</v> - </type> <desc> - <p>Partitions <c>List</c> into two lists, where the first list - contains all elements for which <c>Pred(Elem)</c> returns + <p>Partitions <c><anno>List</anno></c> into two lists, where the first list + contains all elements for which <c><anno>Pred</anno>(<anno>Elem</anno>)</c> returns <c>true</c>, and the second list contains all elements for - which <c>Pred(Elem)</c> returns <c>false</c>.</p> + which <c><anno>Pred</anno>(<anno>Elem</anno>)</c> returns <c>false</c>.</p> <p>Examples:</p> <pre> > <input>lists:partition(fun(A) -> A rem 2 == 1 end, [1,2,3,4,5,6,7]).</input> @@ -715,24 +546,18 @@ c</pre> </desc> </func> <func> - <name>prefix(List1, List2) -> bool()</name> + <name name="prefix" arity="2"/> <fsummary>Test for list prefix</fsummary> - <type> - <v>List1 = List2 = [term()]</v> - </type> <desc> - <p>Returns <c>true</c> if <c>List1</c> is a prefix of - <c>List2</c>, otherwise <c>false</c>.</p> + <p>Returns <c>true</c> if <c><anno>List1</anno></c> is a prefix of + <c><anno>List2</anno></c>, otherwise <c>false</c>.</p> </desc> </func> <func> - <name>reverse(List1) -> List2</name> + <name name="reverse" arity="1"/> <fsummary>Reverse a list</fsummary> - <type> - <v>List1 = List2 = [term()]</v> - </type> <desc> - <p>Returns a list with the top level elements in <c>List1</c> + <p>Returns a list with the elements in <c><anno>List1</anno></c> in reverse order.</p> </desc> </func> @@ -743,7 +568,7 @@ c</pre> <v>List1 = Tail = List2 = [term()]</v> </type> <desc> - <p>Returns a list with the top level elements in <c>List1</c> + <p>Returns a list with the elements in <c>List1</c> in reverse order, with the tail <c>Tail</c> appended. For example:</p> <pre> @@ -752,22 +577,18 @@ c</pre> </desc> </func> <func> - <name>seq(From, To) -> Seq</name> - <name>seq(From, To, Incr) -> Seq</name> + <name name="seq" arity="2"/> + <name name="seq" arity="3"/> <fsummary>Generate a sequence of integers</fsummary> - <type> - <v>From = To = Incr = int()</v> - <v>Seq = [int()]</v> - </type> <desc> - <p>Returns a sequence of integers which starts with <c>From</c> - and contains the successive results of adding <c>Incr</c> to - the previous element, until <c>To</c> has been reached or - passed (in the latter case, <c>To</c> is not an element of - the sequence). <c>Incr</c> defaults to 1.</p> - <p>Failure: If <c><![CDATA[To<From-Incr]]></c> and <c>Incr</c> - is positive, or if <c>To>From-Incr</c> and <c>Incr</c> is - negative, or if <c>Incr==0</c> and <c>From/=To</c>.</p> + <p>Returns a sequence of integers which starts with <c><anno>From</anno></c> + and contains the successive results of adding <c><anno>Incr</anno></c> to + the previous element, until <c><anno>To</anno></c> has been reached or + passed (in the latter case, <c><anno>To</anno></c> is not an element of + the sequence). <c><anno>Incr</anno></c> defaults to 1.</p> + <p>Failure: If <c><anno>To</anno><<anno>From</anno>-<anno>Incr</anno></c> and <c><anno>Incr</anno></c> + is positive, or if <c><anno>To</anno>><anno>From</anno>-<anno>Incr</anno></c> and <c><anno>Incr</anno></c> is + negative, or if <c><anno>Incr</anno>==0</c> and <c><anno>From</anno>/=<anno>To</anno></c>.</p> <p>The following equalities hold for all sequences:</p> <code type="none"> length(lists:seq(From, To)) == To-From+1 @@ -787,60 +608,44 @@ length(lists:seq(From, To, Incr)) == (To-From+Incr) div Incr</code> </desc> </func> <func> - <name>sort(List1) -> List2</name> + <name name="sort" arity="1"/> <fsummary>Sort a list</fsummary> - <type> - <v>List1 = List2 = [term()]</v> - </type> <desc> <p>Returns a list containing the sorted elements of - <c>List1</c>.</p> + <c><anno>List1</anno></c>.</p> </desc> </func> <func> - <name>sort(Fun, List1) -> List2</name> + <name name="sort" arity="2"/> <fsummary>Sort a list</fsummary> - <type> - <v>Fun = fun(Elem1, Elem2) -> bool()</v> - <v> Elem1 = Elem2 = term()</v> - <v>List1 = List2 = [term()]</v> - </type> <desc> <p>Returns a list containing the sorted elements of - <c>List1</c>, according to the <seealso + <c><anno>List1</anno></c>, according to the <seealso marker="#ordering_function">ordering function</seealso> - <c>Fun</c>. <c>Fun(A, B)</c> should return <c>true</c> if - <c>A</c> compares less than or equal to <c>B</c> in the + <c><anno>Fun</anno></c>. <c><anno>Fun</anno>(<anno>A</anno>, <anno>B</anno>)</c> should return <c>true</c> if + <c><anno>A</anno></c> compares less than or equal to <c><anno>B</anno></c> in the ordering, <c>false</c> otherwise.</p> </desc> </func> <func> - <name>split(N, List1) -> {List2, List3}</name> + <name name="split" arity="2"/> <fsummary>Split a list into two lists</fsummary> - <type> - <v>N = 0..length(List1)</v> - <v>List1 = List2 = List3 = [term()]</v> - </type> + <type_desc variable="N">0..length(List1)</type_desc> <desc> - <p>Splits <c>List1</c> into <c>List2</c> and <c>List3</c>. - <c>List2</c> contains the first <c>N</c> elements and - <c>List3</c> the rest of the elements (the <c>N</c>th tail).</p> + <p>Splits <c><anno>List1</anno></c> into <c><anno>List2</anno></c> and <c><anno>List3</anno></c>. + <c><anno>List2</anno></c> contains the first <c><anno>N</anno></c> elements and + <c><anno>List3</anno></c> the rest of the elements (the <c><anno>N</anno></c>th tail).</p> </desc> </func> <func> - <name>splitwith(Pred, List) -> {List1, List2}</name> + <name name="splitwith" arity="2"/> <fsummary>Split a list into two lists based on a predicate</fsummary> - <type> - <v>Pred = fun(Elem) -> bool()</v> - <v> Elem = term()</v> - <v>List = List1 = List2 = [term()]</v> - </type> <desc> - <p>Partitions <c>List</c> into two lists according to - <c>Pred</c>. <c>splitwith/2</c> behaves as if it is defined + <p>Partitions <c><anno>List</anno></c> into two lists according to + <c><anno>Pred</anno></c>. <c>splitwith/2</c> behaves as if it is defined as follows:</p> <code type="none"> -splitwith(Pred, List) -> +splitwith(Pred, List) -> {takewhile(Pred, List), dropwhile(Pred, List)}.</code> <p>Examples:</p> <pre> @@ -853,31 +658,23 @@ splitwith(Pred, List) -> </desc> </func> <func> - <name>sublist(List1, Len) -> List2</name> + <name name="sublist" arity="2"/> <fsummary>Return a sub-list of a certain length, starting at the first position</fsummary> - <type> - <v>List1 = List2 = [term()]</v> - <v>Len = int()</v> - </type> <desc> - <p>Returns the sub-list of <c>List1</c> starting at position 1 - and with (max) <c>Len</c> elements. It is not an error for - <c>Len</c> to exceed the length of the list -- in that case + <p>Returns the sub-list of <c><anno>List1</anno></c> starting at position 1 + and with (max) <c><anno>Len</anno></c> elements. It is not an error for + <c><anno>Len</anno></c> to exceed the length of the list -- in that case the whole list is returned.</p> </desc> </func> <func> - <name>sublist(List1, Start, Len) -> List2</name> + <name name="sublist" arity="3"/> <fsummary>Return a sub-list starting at a given position and with a given number of elements</fsummary> - <type> - <v>List1 = List2 = [term()]</v> - <v>Start = 1..(length(List1)+1)</v> - <v>Len = int()</v> - </type> + <type_desc variable="Start">1..(length(List1)+1)</type_desc> <desc> - <p>Returns the sub-list of <c>List1</c> starting at <c>Start</c> - and with (max) <c>Len</c> elements. It is not an error for - <c>Start+Len</c> to exceed the length of the list.</p> + <p>Returns the sub-list of <c><anno>List1</anno></c> starting at <c><anno>Start</anno></c> + and with (max) <c><anno>Len</anno></c> elements. It is not an error for + <c><anno>Start</anno>+<anno>Len</anno></c> to exceed the length of the list.</p> <pre> > <input>lists:sublist([1,2,3,4], 2, 2).</input> [2,3] @@ -888,15 +685,12 @@ splitwith(Pred, List) -> </desc> </func> <func> - <name>subtract(List1, List2) -> List3</name> + <name name="subtract" arity="2"/> <fsummary>Subtract the element in one list from another list</fsummary> - <type> - <v>List1 = List2 = List3 = [term()]</v> - </type> <desc> - <p>Returns a new list <c>List3</c> which is a copy of - <c>List1</c>, subjected to the following procedure: for each - element in <c>List2</c>, its first occurrence in <c>List1</c> + <p>Returns a new list <c><anno>List3</anno></c> which is a copy of + <c><anno>List1</anno></c>, subjected to the following procedure: for each + element in <c><anno>List2</anno></c>, its first occurrence in <c><anno>List1</anno></c> is deleted. For example:</p> <pre> > <input>lists:subtract("123212", "212").</input> @@ -911,151 +705,112 @@ splitwith(Pred, List) -> </desc> </func> <func> - <name>suffix(List1, List2) -> bool()</name> + <name name="suffix" arity="2"/> <fsummary>Test for list suffix</fsummary> <desc> - <p>Returns <c>true</c> if <c>List1</c> is a suffix of - <c>List2</c>, otherwise <c>false</c>.</p> + <p>Returns <c>true</c> if <c><anno>List1</anno></c> is a suffix of + <c><anno>List2</anno></c>, otherwise <c>false</c>.</p> </desc> </func> <func> - <name>sum(List) -> number()</name> + <name name="sum" arity="1"/> <fsummary>Return sum of elements in a list</fsummary> - <type> - <v>List = [number()]</v> - </type> <desc> - <p>Returns the sum of the elements in <c>List</c>.</p> + <p>Returns the sum of the elements in <c><anno>List</anno></c>.</p> </desc> </func> <func> - <name>takewhile(Pred, List1) -> List2</name> + <name name="takewhile" arity="2"/> <fsummary>Take elements from a list while a predicate is true</fsummary> - <type> - <v>Pred = fun(Elem) -> bool()</v> - <v> Elem = term()</v> - <v>List1 = List2 = [term()]</v> - </type> <desc> - <p>Takes elements <c>Elem</c> from <c>List1</c> while - <c>Pred(Elem)</c> returns <c>true</c>, that is, + <p>Takes elements <c><anno>Elem</anno></c> from <c><anno>List1</anno></c> while + <c><anno>Pred</anno>(<anno>Elem</anno>)</c> returns <c>true</c>, that is, the function returns the longest prefix of the list for which all elements satisfy the predicate.</p> </desc> </func> <func> - <name>ukeymerge(N, TupleList1, TupleList2) -> TupleList3</name> + <name name="ukeymerge" arity="3"/> <fsummary>Merge two key-sorted lists of tuples, removing duplicates</fsummary> - <type> - <v>N = 1..tuple_size(Tuple)</v> - <v>TupleList1 = TupleList2 = TupleList3 = [Tuple]</v> - <v> Tuple = tuple()</v> - </type> + <type_desc variable="N">1..tuple_size(Tuple)</type_desc> <desc> - <p>Returns the sorted list formed by merging <c>TupleList1</c> - and <c>TupleList2</c>. The merge is performed on the - <c>N</c>th element of each tuple. Both <c>TupleList1</c> and - <c>TupleList2</c> must be key-sorted without duplicates + <p>Returns the sorted list formed by merging <c><anno>TupleList1</anno></c> + and <c><anno>TupleList2</anno></c>. The merge is performed on the + <c><anno>N</anno></c>th element of each tuple. Both <c><anno>TupleList1</anno></c> and + <c><anno>TupleList2</anno></c> must be key-sorted without duplicates prior to evaluating this function. When two tuples compare - equal, the tuple from <c>TupleList1</c> is picked and the - one from <c>TupleList2</c> deleted.</p> + equal, the tuple from <c><anno>TupleList1</anno></c> is picked and the + one from <c><anno>TupleList2</anno></c> deleted.</p> </desc> </func> <func> - <name>ukeysort(N, TupleList1) -> TupleList2</name> + <name name="ukeysort" arity="2"/> <fsummary>Sort a list of tuples, removing duplicates</fsummary> - <type> - <v>N = 1..tuple_size(Tuple)</v> - <v>TupleList1 = TupleList2 = [Tuple]</v> - <v> Tuple = tuple()</v> - </type> + <type_desc variable="N">1..tuple_size(Tuple)</type_desc> <desc> <p>Returns a list containing the sorted elements of the list - <c>TupleList1</c> where all but the first tuple of the + <c><anno>TupleList1</anno></c> where all but the first tuple of the tuples comparing equal have been deleted. Sorting is - performed on the <c>N</c>th element of the tuples.</p> + performed on the <c><anno>N</anno></c>th element of the tuples.</p> </desc> </func> <func> - <name>umerge(ListOfLists) -> List1</name> + <name name="umerge" arity="1"/> <fsummary>Merge a list of sorted lists, removing duplicates</fsummary> - <type> - <v>ListOfLists = [List]</v> - <v>List = List1 = [term()]</v> - </type> <desc> <p>Returns the sorted list formed by merging all the sub-lists - of <c>ListOfLists</c>. All sub-lists must be sorted and + of <c><anno>ListOfLists</anno></c>. All sub-lists must be sorted and contain no duplicates prior to evaluating this function. When two elements compare equal, the element from the - sub-list with the lowest position in <c>ListOfLists</c> is + sub-list with the lowest position in <c><anno>ListOfLists</anno></c> is picked and the other one deleted.</p> </desc> </func> <func> - <name>umerge(List1, List2) -> List3</name> + <name name="umerge" arity="2"/> <fsummary>Merge two sorted lists, removing duplicates</fsummary> - <type> - <v>List1 = List2 = List3 = [term()]</v> - </type> <desc> - <p>Returns the sorted list formed by merging <c>List1</c> and - <c>List2</c>. Both <c>List1</c> and <c>List2</c> must be + <p>Returns the sorted list formed by merging <c><anno>List1</anno></c> and + <c><anno>List2</anno></c>. Both <c><anno>List1</anno></c> and <c><anno>List2</anno></c> must be sorted and contain no duplicates prior to evaluating this function. When two elements compare equal, the element from - <c>List1</c> is picked and the one from <c>List2</c> + <c><anno>List1</anno></c> is picked and the one from <c><anno>List2</anno></c> deleted.</p> </desc> </func> <func> - <name>umerge(Fun, List1, List2) -> List3</name> + <name name="umerge" arity="3"/> <fsummary>Merge two sorted lists, removing duplicates</fsummary> - <type> - <v>Fun = fun(A, B) -> bool()</v> - <v>List1 = [A]</v> - <v>List2 = [B]</v> - <v>List3 = [A | B]</v> - <v> A = B = term()</v> - </type> <desc> - <p>Returns the sorted list formed by merging <c>List1</c> and - <c>List2</c>. Both <c>List1</c> and <c>List2</c> must be + <p>Returns the sorted list formed by merging <c><anno>List1</anno></c> and + <c><anno>List2</anno></c>. Both <c><anno>List1</anno></c> and <c><anno>List2</anno></c> must be sorted according to the <seealso marker="#ordering_function">ordering function</seealso> <c>Fun</c> and contain no duplicates prior to evaluating - this function. <c>Fun(A, B)</c> should return <c>true</c> if - <c>A</c> compares less than or equal to <c>B</c> in the + this function. <c><anno>Fun</anno>(<anno>A</anno>, <anno>B</anno>)</c> should return <c>true</c> if + <c><anno>A</anno></c> compares less than or equal to <c><anno>B</anno></c> in the ordering, <c>false</c> otherwise. When two elements compare equal, the element from - <c>List1</c> is picked and the one from <c>List2</c> + <c><anno>List1</anno></c> is picked and the one from <c><anno>List2</anno></c> deleted.</p> </desc> </func> <func> - <name>umerge3(List1, List2, List3) -> List4</name> + <name name="umerge3" arity="3"/> <fsummary>Merge three sorted lists, removing duplicates</fsummary> - <type> - <v>List1 = List2 = List3 = List4 = [term()]</v> - </type> <desc> - <p>Returns the sorted list formed by merging <c>List1</c>, - <c>List2</c> and <c>List3</c>. All of <c>List1</c>, - <c>List2</c> and <c>List3</c> must be sorted and contain no + <p>Returns the sorted list formed by merging <c><anno>List1</anno></c>, + <c><anno>List2</anno></c> and <c><anno>List3</anno></c>. All of <c><anno>List1</anno></c>, + <c><anno>List2</anno></c> and <c><anno>List3</anno></c> must be sorted and contain no duplicates prior to evaluating this function. When two - elements compare equal, the element from <c>List1</c> is + elements compare equal, the element from <c><anno>List1</anno></c> is picked if there is such an element, otherwise the element - from <c>List2</c> is picked, and the other one deleted.</p> + from <c><anno>List2</anno></c> is picked, and the other one deleted.</p> </desc> </func> <func> - <name>unzip(List1) -> {List2, List3}</name> + <name name="unzip" arity="1"/> <fsummary>Unzip a list of two-tuples into two lists</fsummary> - <type> - <v>List1 = [{X, Y}]</v> - <v>List2 = [X]</v> - <v>List3 = [Y]</v> - <v> X = Y = term()</v> - </type> <desc> <p>"Unzips" a list of two-tuples into two lists, where the first list contains the first element of each tuple, and the second @@ -1063,15 +818,8 @@ splitwith(Pred, List) -> </desc> </func> <func> - <name>unzip3(List1) -> {List2, List3, List4}</name> + <name name="unzip3" arity="1"/> <fsummary>Unzip a list of three-tuples into three lists</fsummary> - <type> - <v>List1 = [{X, Y, Z}]</v> - <v>List2 = [X]</v> - <v>List3 = [Y]</v> - <v>List4 = [Z]</v> - <v> X = Y = Z = term()</v> - </type> <desc> <p>"Unzips" a list of three-tuples into three lists, where the first list contains the first element of each tuple, @@ -1080,44 +828,30 @@ splitwith(Pred, List) -> </desc> </func> <func> - <name>usort(List1) -> List2</name> + <name name="usort" arity="1"/> <fsummary>Sort a list, removing duplicates</fsummary> - <type> - <v>List1 = List2 = [term()]</v> - </type> <desc> <p>Returns a list containing the sorted elements of - <c>List1</c> where all but the first element of the elements + <c><anno>List1</anno></c> where all but the first element of the elements comparing equal have been deleted.</p> </desc> </func> <func> - <name>usort(Fun, List1) -> List2</name> + <name name="usort" arity="2"/> <fsummary>Sort a list, removing duplicates</fsummary> - <type> - <v>Fun = fun(Elem1, Elem2) -> bool()</v> - <v> Elem1 = Elem2 = term()</v> - <v>List1 = List2 = [term()]</v> - </type> <desc> <p>Returns a list which contains the sorted elements of - <c>List1</c> where all but the first element of the elements + <c><anno>List1</anno></c> where all but the first element of the elements comparing equal according to the <seealso marker="#ordering_function">ordering function</seealso> - <c>Fun</c> have been deleted. <c>Fun(A, B)</c> should return + <c><anno>Fun</anno></c> have been deleted. <c><anno>Fun</anno>(A, B)</c> should return <c>true</c> if <c>A</c> compares less than or equal to <c>B</c> in the ordering, <c>false</c> otherwise.</p> </desc> </func> <func> - <name>zip(List1, List2) -> List3</name> + <name name="zip" arity="2"/> <fsummary>Zip two lists into a list of two-tuples</fsummary> - <type> - <v>List1 = [X]</v> - <v>List2 = [Y]</v> - <v>List3 = [{X, Y}]</v> - <v> X = Y = term()</v> - </type> <desc> <p>"Zips" two lists of equal length into one list of two-tuples, where the first element of each tuple is taken from the first @@ -1126,15 +860,8 @@ splitwith(Pred, List) -> </desc> </func> <func> - <name>zip3(List1, List2, List3) -> List4</name> + <name name="zip3" arity="3"/> <fsummary>Zip three lists into a list of three-tuples</fsummary> - <type> - <v>List1 = [X]</v> - <v>List2 = [Y]</v> - <v>List3 = [Z]</v> - <v>List3 = [{X, Y, Z}]</v> - <v> X = Y = Z = term()</v> - </type> <desc> <p>"Zips" three lists of equal length into one list of three-tuples, where the first element of each tuple is taken @@ -1145,20 +872,13 @@ splitwith(Pred, List) -> </desc> </func> <func> - <name>zipwith(Combine, List1, List2) -> List3</name> + <name name="zipwith" arity="3"/> <fsummary>Zip two lists into one list according to a fun</fsummary> - <type> - <v>Combine = fun(X, Y) -> T</v> - <v>List1 = [X]</v> - <v>List2 = [Y]</v> - <v>List3 = [T]</v> - <v> X = Y = T = term()</v> - </type> <desc> <p>Combine the elements of two lists of equal length into one - list. For each pair <c>X, Y</c> of list elements from the two + list. For each pair <c><anno>X</anno>, <anno>Y</anno></c> of list elements from the two lists, the element in the result list will be - <c>Combine(X, Y)</c>.</p> + <c><anno>Combine</anno>(<anno>X</anno>, <anno>Y</anno>)</c>.</p> <p><c>zipwith(fun(X, Y) -> {X,Y} end, List1, List2)</c> is equivalent to <c>zip(List1, List2)</c>.</p> <p>Example:</p> @@ -1168,21 +888,13 @@ splitwith(Pred, List) -> </desc> </func> <func> - <name>zipwith3(Combine, List1, List2, List3) -> List4</name> + <name name="zipwith3" arity="4"/> <fsummary>Zip three lists into one list according to a fun</fsummary> - <type> - <v>Combine = fun(X, Y, Z) -> T</v> - <v>List1 = [X]</v> - <v>List2 = [Y]</v> - <v>List3 = [Z]</v> - <v>List4 = [T]</v> - <v> X = Y = Z = T = term()</v> - </type> <desc> <p>Combine the elements of three lists of equal length into one - list. For each triple <c>X, Y, Z</c> of list elements from + list. For each triple <c><anno>X</anno>, <anno>Y</anno>, <anno>Z</anno></c> of list elements from the three lists, the element in the result list will be - <c>Combine(X, Y, Z)</c>.</p> + <c><anno>Combine</anno>(<anno>X</anno>, <anno>Y</anno>, <anno>Z</anno>)</c>.</p> <p><c>zipwith3(fun(X, Y, Z) -> {X,Y,Z} end, List1, List2, List3)</c> is equivalent to <c>zip3(List1, List2, List3)</c>.</p> <p>Examples:</p> <pre> diff --git a/lib/stdlib/doc/src/log_mf_h.xml b/lib/stdlib/doc/src/log_mf_h.xml index 198a55a63b..f2b09b58eb 100644 --- a/lib/stdlib/doc/src/log_mf_h.xml +++ b/lib/stdlib/doc/src/log_mf_h.xml @@ -5,7 +5,7 @@ <header> <copyright> <year>1996</year> - <year>2007</year> + <year>2011</year> <holder>Ericsson AB, All Rights Reserved</holder> </copyright> <legalnotice> @@ -43,28 +43,27 @@ report files <c>1, 2, ....</c>. </p> </description> + <datatypes> + <datatype> + <name name="args"/> + <desc><p>Term to be sent to <seealso marker="gen_event#add_handler/3"> + gen_event:add_handler/3</seealso>.</p></desc> + </datatype> + </datatypes> <funcs> <func> - <name>init(Dir, MaxBytes, MaxFiles)</name> - <name>init(Dir, MaxBytes, MaxFiles, Pred) -> Args</name> + <name name="init" arity="3"/> + <name name="init" arity="4"/> <fsummary>Initiate the event handler</fsummary> - <type> - <v>Dir = string()</v> - <v>MaxBytes = integer()</v> - <v>MaxFiles = 0 < integer() < 256</v> - <v>Pred = fun(Event) -> boolean()</v> - <v>Event = term()</v> - <v>Args = args()</v> - </type> <desc> <p>Initiates the event handler. This function returns - <c>Args</c>, which should be used in a call to - <c>gen_event:add_handler(EventMgr, log_mf_h, Args)</c>. + <c><anno>Args</anno></c>, which should be used in a call to + <c>gen_event:add_handler(EventMgr, log_mf_h, <anno>Args</anno>)</c>. </p> - <p><c>Dir</c> specifies which directory to use for the log - files. <c>MaxBytes</c> specifies the size of each individual - file. <c>MaxFiles</c> specifies how many files are - used. <c>Pred</c> is a predicate function used to filter the + <p><c><anno>Dir</anno></c> specifies which directory to use for the log + files. <c><anno>MaxBytes</anno></c> specifies the size of each individual + file. <c><anno>MaxFiles</anno></c> specifies how many files are + used. <c><anno>Pred</anno></c> is a predicate function used to filter the events. If no predicate function is specified, all events are logged.</p> </desc> diff --git a/lib/stdlib/doc/src/math.xml b/lib/stdlib/doc/src/math.xml index 990a6b4024..518457d5d8 100644 --- a/lib/stdlib/doc/src/math.xml +++ b/lib/stdlib/doc/src/math.xml @@ -5,7 +5,7 @@ <header> <copyright> <year>1996</year> - <year>2007</year> + <year>2011</year> <holder>Ericsson AB, All Rights Reserved</holder> </copyright> <legalnotice> @@ -45,7 +45,7 @@ </description> <funcs> <func> - <name>pi() -> float()</name> + <name name="pi" arity="0"/> <fsummary>A useful number</fsummary> <desc> <p>A useful number.</p> diff --git a/lib/stdlib/doc/src/ms_transform.xml b/lib/stdlib/doc/src/ms_transform.xml index 9f178b426c..f81f8bda96 100644 --- a/lib/stdlib/doc/src/ms_transform.xml +++ b/lib/stdlib/doc/src/ms_transform.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>2002</year><year>2009</year> + <year>2002</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>ms_transform</title> @@ -245,7 +245,7 @@ ets:select(emp_tab, ets:fun2ms( fun(#emp{empno = [$0 | Rest] }) -> {[$0|Rest],[$1|Rest]} end)). </code> - <p>As a matter of fact, this query hit's the feature of partially bound + <p>As a matter of fact, this query hits the feature of partially bound keys in the table type <c>ordered_set</c>, so that not the whole table need be searched, only the part of the table containing keys beginning with <c>0</c> is in fact looked into. </p> @@ -599,12 +599,9 @@ ets:select(Table, [{{'$1',test,'$2'},[],['$_']}]).</code> </description> <funcs> <func> - <name>parse_transform(Forms,_Options) -> Forms</name> + <name name="parse_transform" arity="2"/> <fsummary>Transforms Erlang abstract format containing calls to ets/dbg:fun2ms into literal match specifications.</fsummary> - <type> - <v>Forms = Erlang abstract code format, see the erl_parse module description </v> - <v>_Options = Option list, required but not used</v> - </type> + <type_desc variable="Options">Option list, required but not used.</type_desc> <desc> <p>Implements the actual transformation at compile time. This function is called by the compiler to do the source code @@ -617,29 +614,21 @@ ets:select(Table, [{{'$1',test,'$2'},[],['$_']}]).</code> </desc> </func> <func> - <name>transform_from_shell(Dialect,Clauses,BoundEnvironment) -> term()</name> + <name name="transform_from_shell" arity="3"/> <fsummary>Used when transforming fun's created in the shell into match_specifications.</fsummary> - <type> - <v>Dialect = ets | dbg</v> - <v>Clauses = Erlang abstract form for a single fun</v> - <v>BoundEnvironment = [{atom(), term()}, ...], list of variable bindings in the shell environment</v> - </type> + <type_desc variable="BoundEnvironment">List of variable bindings in the shell environment.</type_desc> <desc> <p>Implements the actual transformation when the <c>fun2ms</c> functions are called from the shell. In this case the abstract form is for one single fun (parsed by the Erlang shell), and all imported variables should be in the key-value list passed - as <c>BoundEnvironment</c>. The result is a term, normalized, + as <c><anno>BoundEnvironment</anno></c>. The result is a term, normalized, i.e. not in abstract format.</p> </desc> </func> <func> - <name>format_error(Errcode) -> ErrMessage</name> + <name name="format_error" arity="1"/> <fsummary>Error formatting function as required by the parse_transform interface.</fsummary> - <type> - <v>Errcode = term()</v> - <v>ErrMessage = string()</v> - </type> <desc> <p>Takes an error code returned by one of the other functions in the module and creates a textual description of the diff --git a/lib/stdlib/doc/src/notes.xml b/lib/stdlib/doc/src/notes.xml index c55eafc8b8..d9c220b996 100644 --- a/lib/stdlib/doc/src/notes.xml +++ b/lib/stdlib/doc/src/notes.xml @@ -4,7 +4,7 @@ <chapter> <header> <copyright> - <year>2004</year><year>2010</year> + <year>2004</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -30,6 +30,991 @@ </header> <p>This document describes the changes made to the STDLIB application.</p> +<section><title>STDLIB 1.17.5</title> + + <section><title>Fixed Bugs and Malfunctions</title> + <list> + <item> + <p> + erl_tar:extract failed when executed inside a directory + with some parent directory to which the user has no read + access. This has been corrected.</p> + <p> + Own Id: OTP-9368</p> + </item> + <item> + <p> A bug in <c>erl_scan:set_attribute/3</c> has been + fixed. </p> + <p> + Own Id: OTP-9412</p> + </item> + <item> + <p> The contract of <c>io_lib:fread()</c> has been + corrected. </p> + <p> + Own Id: OTP-9413 Aux Id: seq11873 </p> + </item> + <item> + <p> + A crash in io_lib:fread/2 when end of input data was + encountered while trying to match literal characters, + which should return {more,_,_,_} but instead crashed, has + been corrected. Reported by Klas Johansson.</p> + <p> + A similar peculiarity for io:fread when encountering end + of file before any field data has also been corrected.</p> + <p> + Own Id: OTP-9439</p> + </item> + <item> + <p> The contract of <c>timer:now_diff()</c> has been + corrected. (Thanks to Alex Morarash). </p> + <p> + Own Id: OTP-9450</p> + </item> + <item> + <p> + Fix minor typo in gen_fsm documentation (Thanks to Haitao + Li)</p> + <p> + Own Id: OTP-9456</p> + </item> + <item> + <p>The contracts of <c>zip:zip_list_dir/1</c> and + <c>zip:zip_get/2</c> have been corrected. </p> + <p> + Own Id: OTP-9471 Aux Id: seq11887, OTP-9472 </p> + </item> + <item> + <p> A bug in <c>zip:zip_open()</c> has been fixed. </p> + <p> + Own Id: OTP-9472 Aux Id: seq11887, OTP-9471 </p> + </item> + <item> + <p> + Fix trivial documentation errors(Thanks to Matthias Lang)</p> + <p> + Own Id: OTP-9498</p> + </item> + <item> + <p> + Add a proplist() type</p> + <p> + Recently I was adding specs to an API and found that + there is no canonical proplist() type defined. (Thanks to + Ryan Zezeski)</p> + <p> + Own Id: OTP-9499</p> + </item> + <item> + <p> + fix supervisors restarting temporary children</p> + <p> + In the current implementation of supervisors, temporary + children should never be restarted. However, when a + temporary child is restarted as part of a one_for_all or + rest_for_one strategy where the failing process is not + the temporary child, the supervisor still tries to + restart it.</p> + <p> + Because the supervisor doesn't keep some of the MFA + information of temporary children, this causes the + supervisor to hit its restart limit and crash.</p> + <p> + This patch fixes the behaviour by inserting a clause in + terminate_children/2-3 (private function) that will omit + temporary children when building a list of killed + processes, to avoid having the supervisor trying to + restart them again.</p> + <p> + Only supervisors in need of restarting children used the + list, so the change should be of no impact for the + functions that called terminate_children/2-3 only to kill + all children.</p> + <p> + The documentation has been modified to make this + behaviour more explicit. (Thanks to Fred Hebert)</p> + <p> + Own Id: OTP-9502</p> + </item> + <item> + <p> + fix broken edoc annotations (Thanks to Richard Carlsson)</p> + <p> + Own Id: OTP-9516</p> + </item> + <item> + <p> XML files have been corrected. </p> + <p> + Own Id: OTP-9550 Aux Id: OTP-9541 </p> + </item> + <item> + <p> + Handle rare race in the crypto key server functionality</p> + <p> + Own Id: OTP-9586</p> + </item> + </list> + </section> + + + <section><title>Improvements and New Features</title> + <list> + <item> + <p> Types and specifications have been added. </p> + <p> + Own Id: OTP-9356</p> + </item> + <item> + <p> The contracts of the <c>queue</c> module have been + modified. </p> + <p> + Own Id: OTP-9418</p> + </item> + <item> + <p> Contracts in STDLIB and Kernel have been improved and + type errors have been corrected. </p> + <p> + Own Id: OTP-9485</p> + </item> + <item> + <p> + Types for several BIFs have been extended/corrected. Also + the types for types for <c>lists:keyfind/3</c>, + <c>lists:keysearch/3</c>, and <c>lists:keyemember/3</c> + have been corrected. The incorrect/incomplete types could + cause false dialyzer warnings.</p> + <p> + Own Id: OTP-9496</p> + </item> + </list> + </section> + +</section> + +<section><title>STDLIB 1.17.4</title> + + <section><title>Fixed Bugs and Malfunctions</title> + <list> + <item> + <p> The default value <c>undefined</c> was added to + records field types in such a way that the result was not + always a well-formed type. This bug has been fixed. </p> + <p> + Own Id: OTP-9147</p> + </item> + <item> + <p> + Update index file atomically</p> + <p> + Since the log_mf_h index file might be read by other + processes than the error handler (e.g. by the rb tool), + this file should be updated atomically. This will avoid + hitting the time gap between opening the file in write + mode (and thus emptying the file) and the actual update + with the new contents. To do this, a temporary file is + written, and the file:rename/1 used to replace the real + index file.</p> + <p> + Own Id: OTP-9148</p> + </item> + <item> + <p> + Fixed various typos across the documentation (Thanks to + Tuncer Ayaz)</p> + <p> + Own Id: OTP-9154</p> + </item> + <item> + <p> + Supervisors should not save child-specs for temporary + processes when they terminate as they should not be + restarted. Saving the temporary child spec will result in + that you can not start a new temporary process with the + same child spec as an already terminated temporary + process. Since R14B02 you can not restart a temporary + temporary process as arguments are no longer saved, it + has however always been semantically incorrect to restart + a temporary process. Thanks to Filipe David Manana for + reporting this and suggesting a solution.</p> + <p> + Own Id: OTP-9167 Aux Id: OTP-9064 </p> + </item> + <item> + <p> + Various small documentation fixes (Thanks to Bernard + Duggan)</p> + <p> + Own Id: OTP-9172</p> + </item> + <item> + <p> + Fix format_status bug for unregistered gen_event + processes</p> + <p> + Port the gen_fsm code for format_status to gen_event in + order to prevent a lists:concat([...,pid()]) crash when + calling sys:get_status/1 on an unregistered gen_event + process.</p> + <p> + Refactor format_status header code from gen_* behaviours + to module gen.</p> + <p> + Extend the format_status tests in gen_event_SUITE to + cover format_status bugs with anonymous gen_event + processes. (Thanks To Geoff Cant)</p> + <p> + Own Id: OTP-9218</p> + </item> + <item> + <p> + List of pids changed to 'set' in supervisor for dynamic + temporary children. Accessing the list would not scale + well when adding/deleting many children. (Thanks to + Evgeniy Khramtsov)</p> + <p> + Own Id: OTP-9242</p> + </item> + <item> + <p> + Change pool module to attempt to attach to nodes that are + already running</p> + <p> + The pool module prints out an error message and takes no + further action for nodes that are already running. This + patch changes that behavior so that if the return from + slave:start/3 is {already_running, Node} then an attempt + to attach to the node is still made. This makes sense + because the node has been specified by the user in the + .hosts.erlang file indicating a wish for the node to be + part of the pool and a manual attach can be successfully + made after the pool is started.(Thanks to Kelly + McLaughlin)</p> + <p> + Own Id: OTP-9244</p> + </item> + <item> + <p> + unicode: document 16#FFFE and 16#FFFF (non chars)(Thanks + to Tuncer Ayaz)</p> + <p> + Own Id: OTP-9256</p> + </item> + <item> + <p> + re: remove gratuitous "it " in manpage (Thanks to Tuncer + Ayaz)</p> + <p> + Own Id: OTP-9307</p> + </item> + <item> + <p> A bug in erl_eval(3) has been fixed. </p> + <p> + Own Id: OTP-9322</p> + </item> + </list> + </section> + + + <section><title>Improvements and New Features</title> + <list> + <item> + <p> + Add <c>timer:tc/1</c> and remove the catch in <c>tc/2</c> + and <c>tc/3</c>. The time measuring functions will thus + no longer trap exits, errors or throws caused by the + measured function.</p> + <p> + *** POTENTIAL INCOMPATIBILITY ***</p> + <p> + Own Id: OTP-9169</p> + </item> + <item> + <p> + Allow supervisor:terminate_child(SupRef,Pid) for + simple_one_for_one supervisors</p> + <p> + supervisor:terminate_child/2 was earlier not allowed if + the supervisor used restart strategy simple_one_for_one. + This is now changed so that children of this type of + supervisors can be terminated by specifying the child's + Pid.</p> + <p> + (Thanks to Vance Shipley.)</p> + <p> + Own Id: OTP-9201</p> + </item> + <item> + <p> Types and specifications have been added. </p> + <p> + Own Id: OTP-9267</p> + </item> + <item> + <p> Erlang types and specifications are used for + documentation. </p> + <p> + Own Id: OTP-9271</p> + </item> + <item> + <p>Allow Dets tablenames to be arbitrary terms.</p> + <p> + Own Id: OTP-9282</p> + </item> + <item> + <p> A specification that could cause problems for + Dialyzer has been fixed. An opaque type in erl_eval has + been turned in to a ordinary type. This is a temporary + fix. </p> + <p> + Own Id: OTP-9333</p> + </item> + </list> + </section> + +</section> + +<section><title>STDLIB 1.17.3</title> + + <section><title>Fixed Bugs and Malfunctions</title> + <list> + <item> + <p> + Two bugs in io:format for ~F.~Ps has been corrected. When + length(S) >= abs(F) > P, the precision P was incorrectly + ignored. When F == P > lenght(S) the result was + incorrectly left adjusted. Bug found by Ali Yakout who + also provided a fix.</p> + <p> + Own Id: OTP-8989 Aux Id: seq11741 </p> + </item> + <item> + <p>Fix exception generation in the io module + <p> + Some functions did not generate correct badarg exception + on a badarg exception.</p></p> + <p> + Own Id: OTP-9045</p> + </item> + <item> + <p> + Fixes to the dict and orddict module documentation</p> + <p> + Fixed grammar and one inconsistency (Key - Value instead + of key/value, since everywhere else the former is used). + (thanks to Filipe David Manana)</p> + <p> + Own Id: OTP-9083</p> + </item> + <item> + <p> + Add ISO week number calculation functions to the calendar + module in stdlib</p> + <p> + This new feature adds the missing week number function to + the calendar module of the stdlib application. The + implementation conforms to the ISO 8601 standard. The new + feature has been implemented tested and documented + (thanks to Imre Horvath).</p> + <p> + Own Id: OTP-9087</p> + </item> + </list> + </section> + + + <section><title>Improvements and New Features</title> + <list> + <item> + <p> + Implement the 'MAY' clauses from RFC4648 regarding the + pad character to make mime_decode() and + mime_decode_to_string() functions more tolerant of badly + padded base64. The RFC is quoted below for easy + reference.</p> + <p> + "RFC4648 Section 3.3 with reference to MIME decoding: + Furthermore, such specifications MAY ignore the pad + character, "=", treating it as non-alphabet data, if it + is present before the end of the encoded data. If more + than the allowed number of pad characters is found at the + end of the string (e.g., a base 64 string terminated with + "==="), the excess pad characters MAY also be ignored."</p> + <p> + Own Id: OTP-9020</p> + </item> + <item> + <p> + Supervisors will no longer save start parameters for + temporary processes as they will not be restarted. In the + case of simple_one_for_one workers such as ssl-connection + processes this will substantial reduce the memory + footprint of the supervisor.</p> + <p> + Own Id: OTP-9064</p> + </item> + <item> + <p> + When running escript it is now possible to add the -n + flag and the escript will be compiled using +native.</p> + <p> + Own Id: OTP-9076</p> + </item> + </list> + </section> + +</section> + +<section><title>STDLIB 1.17.2.1</title> + + <section><title>Fixed Bugs and Malfunctions</title> + <list> + <item> + <p> + Several type specifications for standard libraries were + wrong in the R14B01 release. This is now corrected. The + corrections concern types in re,io,filename and the + module erlang itself.</p> + <p> + Own Id: OTP-9008</p> + </item> + </list> + </section> + +</section> + +<section><title>STDLIB 1.17.2</title> + + <section><title>Fixed Bugs and Malfunctions</title> + <list> + <item> + <p> When several clients accessed a Dets table + simultaneously, one of them calling + <c>dets:insert_new/2</c>, the Dets server could crash. + Alternatively, under the same conditions, <c>ok</c> was + sometimes returned instead of <c>true</c>. (Thanks to + John Hughes.) </p> + <p> + Own Id: OTP-8856</p> + </item> + <item> + <p> When several clients accessed a Dets table + simultaneously, inserted or updated objects were + sometimes lost due to the Dets file being truncated. + (Thanks to John Hughes.) </p> + <p> + Own Id: OTP-8898</p> + </item> + <item> + <p> When several clients accessed a Dets table + simultaneously, modifications of the Dets server's + internal state were sometimes thrown away. The symptoms + are diverse: error with reason <c>bad_object</c>; + inserted objects not returned by <c>lookup()</c>; et + cetera. (Thanks to John Hughes.) </p> + <p> + Own Id: OTP-8899</p> + </item> + <item> + <p> If a Dets table was closed after calling + <c>bchunk/2</c>, <c>match/1,3</c>, + <c>match_object/1,3</c>, or <c>select/1,3</c> and then + opened again, a subsequent call using the returned + continuation would normally return a reply. This bug has + fixed; now the call fails with reason <c>badarg</c>. </p> + <p> + Own Id: OTP-8903</p> + </item> + <item> + <p> Cover did not collect coverage data for files such as + Yecc parses containing include directives. The bug has + been fixed by modifying <c>epp</c>, the Erlang Code + Preprocessor. </p> + <p> + Own Id: OTP-8911</p> + </item> + <item> + <p> If a Dets table with fewer slots than keys was opened + and then closed after just a lookup, the contents were no + longer well-formed. This bug has been fixed. (Thanks to + Matthew Evans.) </p> + <p> + Own Id: OTP-8923</p> + </item> + <item> + <p> + In a supervisor, when it terminates a child, if that + child happens to have exited fractionally early, with + normal, the supervisor reports this as an error. This + should not be reported as an error.</p> + <p> + *** POTENTIAL INCOMPATIBILITY ***</p> + <p> + Own Id: OTP-8938 Aux Id: seq11615 </p> + </item> + </list> + </section> + + + <section><title>Improvements and New Features</title> + <list> + <item> + <p> + The documentation filelib:wildcard/1,2 now describes the + character set syntax for wildcards.</p> + <p> + Own Id: OTP-8879 Aux Id: seq11683 </p> + </item> + <item> + <p>Buffer overflows have been prevented in <c>erlc</c>, + <c>dialyzer</c>, <c>typer</c>, <c>run_test</c>, + <c>heart</c>, <c>escript</c>, and <c>erlexec</c>.</p> + (Thanks to Michael Santos.) + <p> + Own Id: OTP-8892</p> + </item> + <item> + <p> + Using a float for the number of copies for + <c>string:copies/2</c> resulted in an infinite loop. Now + it will fail with an exception instead. (Thanks to + Michael Santos.)</p> + <p> + Own Id: OTP-8915</p> + </item> + <item> + <p> + New ETS option <c>compressed</c>, to enable a more + compact storage format at the expence of heavier table + operations. For test and evaluation, <c>erl +ec</c> can + be used to force compression on all ETS tables.</p> + <p> + Own Id: OTP-8922 Aux Id: seq11658 </p> + </item> + <item> + <p> The default maximum number of slots of a Dets table + has been changed as to be equal to the maximum number of + slots. (Thanks to Richard Carlsson.) </p> + <p> + Own Id: OTP-8959</p> + </item> + </list> + </section> + +</section> + +<section><title>STDLIB 1.17.1</title> + + <section><title>Fixed Bugs and Malfunctions</title> + <list> + <item> + <p>reference() has been substituted for ref() in the + documentation.</p> + <p> + Own Id: OTP-8733</p> + </item> + </list> + </section> + + + <section><title>Improvements and New Features</title> + <list> + <item> + <p> + The ms_transform now warns if the fun head shadows + surrounding variables (just like the warnings you would + get for an ordinary fun in the same context).</p> + <p> + Own Id: OTP-6759</p> + </item> + <item> + <p> + ets:select_reverse/{1,2,3} are now documented.</p> + <p> + Own Id: OTP-7863</p> + </item> + <item> + <p> + Large parts of the <c>ethread</c> library have been + rewritten. The <c>ethread</c> library is an Erlang + runtime system internal, portable thread library used by + the runtime system itself.</p> + <p> + Most notable improvement is a reader optimized rwlock + implementation which dramatically improve the performance + of read-lock/read-unlock operations on multi processor + systems by avoiding ping-ponging of the rwlock cache + lines. The reader optimized rwlock implementation is used + by miscellaneous rwlocks in the runtime system that are + known to be read-locked frequently, and can be enabled on + ETS tables by passing the <seealso + marker="stdlib:ets#new_2_read_concurrency">{read_concurrency, + true}</seealso> option upon table creation. See the + documentation of <seealso + marker="stdlib:ets#new/2">ets:new/2</seealso> for more + information. The reader optimized rwlock implementation + can be fine tuned when starting the runtime system. For + more information, see the documentation of the <seealso + marker="erts:erl#+rg">+rg</seealso> command line argument + of <c>erl</c>.</p> + <p> + There is also a new implementation of rwlocks that is not + optimized for readers. Both implementations interleaves + readers and writers during contention as opposed to, + e.g., the NPTL (Linux) pthread rwlock implementation + which use either a reader or writer preferred strategy. + The reader/writer preferred strategy is problematic since + it starves threads doing the non-preferred operation.</p> + <p> + The new rwlock implementations in general performs better + in ERTS than common pthread implementations. However, in + some extremely heavily contended cases this is not the + case. Such heavy contention can more or less only appear + on ETS tables. This when multiple processes do very large + amounts of write locked operations simultaneously on the + same table. Such use of ETS is bad regardless of rwlock + implementation, will never scale, and is something we + strongly advise against.</p> + <p> + The new rwlock implementations depend on atomic + operations. If no native atomic implementation is found, + a fallback solution will be used. Using the fallback + implies a performance degradation. That is, it is more + important now than before to build OTP with a native + atomic implementation.</p> + <p> + The <c>ethread</c> library contains native atomic + implementations for, x86 (32 and 64 bit), powerpc (32 + bit), sparc V9 (32 and 64 bit), and tilera (32 bit). On + other hardware gcc's builtin support for atomic memory + access will be used if such exists. If no such support is + found, <c>configure</c> will warn about no atomic + implementation available.</p> + <p> + The <c>ethread</c> library can now also use the + <c>libatomic_ops</c> library for atomic memory accesses. + This makes it possible for the Erlang runtime system to + utilize optimized native atomic operations on more + platforms than before. If <c>configure</c> warns about no + atomic implementation available, try using the + <c>libatomic_ops</c> library. Use the <seealso + marker="doc/installation_guide:INSTALL#How-to-Build-and-Install-ErlangOTP_A-Closer-Look-at-the-individual-Steps_Configuring">--with-libatomic_ops=PATH</seealso> + <c>configure</c> command line argument when specifying + where the <c>libatomic_ops</c> installation is located. + The <c>libatomic_ops</c> library can be downloaded from: + <url + href="http://www.hpl.hp.com/research/linux/atomic_ops/">http://www.hpl.hp.com/research/linux/atomic_ops/</url></p> + <p> + The changed API of the <c>ethread</c> library has also + caused modifications in the Erlang runtime system. + Preparations for the to come "delayed deallocation" + feature has also been done since it depends on the + <c>ethread</c> library.</p> + <p> + <em>Note</em>: When building for x86, the <c>ethread</c> + library will now use instructions that first appeared on + the pentium 4 processor. If you want the runtime system + to be compatible with older processors (back to 486) you + need to pass the <seealso + marker="doc/installation_guide:INSTALL#How-to-Build-and-Install-ErlangOTP_A-Closer-Look-at-the-individual-Steps_Configuring">--enable-ethread-pre-pentium4-compatibility</seealso> + <c>configure</c> command line argument when configuring + the system.</p> + <p> + Own Id: OTP-8544</p> + </item> + <item> + <p> + Some Built In Functions (BIFs) from the module erlang was + never made autoimported for backward compatibility + reasons. As local functions now override autoimports, new + autoimports is no longer a problem, why the following + BIFs are finally made autoimported: monitor/2, monitor/3, + demonitor/2, demonitor/3, error/1, error/2, + integer_to_list/2, list_to_integer/2.</p> + <p> + Own Id: OTP-8763</p> + </item> + </list> + </section> + +</section> + +<section><title>STDLIB 1.17</title> + + <section><title>Fixed Bugs and Malfunctions</title> + <list> + <item> + <p>The Erlang code preprocessor (<c>epp</c>) sent extra + messages on the form <c>{eof,Location}</c> to the client + when parsing the <c>file</c> attribute. This bug, + introduced in R11B, has been fixed.</p> + <p> + Own Id: OTP-8470</p> + </item> + <item> + <p>The abstract type 'fun' could not be printed by the + Erlang pretty printer (<c>erl_pp</c>). This bug has been + fixed.</p> + <p> + Own Id: OTP-8473</p> + </item> + <item> + <p>The function <c>erl_scan:reserved_word/1</c> no longer + returns <c>true</c> when given the word <c>spec</c>. This + bug was introduced in STDLIB-1.15.3 (R12B-3).</p> + <p> + Own Id: OTP-8567</p> + </item> + <item> + <p>The documentation of <c>lists:keysort/2</c> states + that the sort is stable.</p> + <p> + Own Id: OTP-8628 Aux Id: seq11576 </p> + </item> + <item> + <p> + The shell's line editing has been improved to more + resemble the behaviour of readline and other shells. + (Thanks to Dave Peticolas)</p> + <p> + Own Id: OTP-8635</p> + </item> + <item> + <p>The Erlang code preprocessor (<c>epp</c>) did not + correctly handle premature end-of-input when defining + macros. This bug, introduced in STDLIB 1.16, has been + fixed.</p> + <p> + Own Id: OTP-8665 Aux Id: OTP-7810 </p> + </item> + </list> + </section> + + + <section><title>Improvements and New Features</title> + <list> + <item> + <p> + The module binary from EEP31 (and EEP9) is implemented.</p> + <p> + Own Id: OTP-8217</p> + </item> + <item> + <p>The erlang pretty printer (<c>erl_pp</c>) no longer + quotes atoms in types.</p> + <p> + Own Id: OTP-8501</p> + </item> + <item> + <p>The Erlang code preprocessor (<c>epp</c>) now + considers records with no fields as typed.</p> + <p> + Own Id: OTP-8503</p> + </item> + <item> + <p> + Added function <c>zip:foldl/3</c> to iterate over zip + archives.</p> + <p> + Added functions to create and extract escripts. See + <c>escript:create/2</c> and <c>escript:extract/2</c>.</p> + <p> + The undocumented function <c>escript:foldl/3</c> has been + removed. The same functionality can be achieved with the + more flexible functions <c>escript:extract/2</c> and + <c>zip:foldl/3</c>.</p> + <p> + Record fields has been annotated with type info. Source + files as been adapted to fit within 80 chars and trailing + whitespace has been removed.</p> + <p> + Own Id: OTP-8521</p> + </item> + <item> + <p>The Erlang parser no longer duplicates the singleton + type <c>undefined</c> in the type of record fields + without initial value.</p> + <p> + Own Id: OTP-8522</p> + </item> + <item> + <p>A regular expression with many levels of parenthesis + could cause a buffer overflow. That has been corrected. + (Thanks to Michael Santos.)</p> + <p> + Own Id: OTP-8539</p> + </item> + <item> + <p>When defining macros the closing right parenthesis + before the dot is now mandatory.</p> + <p> + *** POTENTIAL INCOMPATIBILITY ***</p> + <p> + Own Id: OTP-8562</p> + </item> + <item> + <p> + Some properties of a compiled re pattern are defined to + allow for guard tests.</p> + <p> + Own Id: OTP-8577</p> + </item> + <item> + <p>Local and imported functions now override the + auto-imported BIFs when the names clash. The pre R14 + behaviour was that auto-imported BIFs would override + local functions. To avoid that old programs change + behaviour, the following will generate an error:</p> + <list><item><p>Doing a call without explicit module name + to a local function having a name clashing with the name + of an auto-imported BIF that was present (and + auto-imported) before OTP R14A</p></item> + <item><p>Explicitly importing a function having a name + clashing with the name of an autoimported BIF that was + present (and autoimported) before OTP R14A</p></item> + <item><p>Using any form of the old compiler directive + <c>nowarn_bif_clash</c></p></item> </list> <p>If the BIF + was added or auto-imported in OTP R14A or later, + overriding it with an import or a local function will + only result in a warning,</p> <p>To resolve clashes, you + can either use the explicit module name <c>erlang</c> to + call the BIF, or you can remove the auto-import of that + specific BIF by using the new compiler directive + <c>-compile({no_auto_import,[F/A]}).</c>, which makes all + calls to the local or imported function without explicit + module name pass without warnings or errors.</p> <p>The + change makes it possible to add auto-imported BIFs + without breaking or silently changing old code in the + future. However some current code ingeniously utilizing + the old behaviour or the <c>nowarn_bif_clash</c> compiler + directive, might need changing to be accepted by the + compiler.</p> + <p> + *** POTENTIAL INCOMPATIBILITY ***</p> + <p> + Own Id: OTP-8579</p> + </item> + <item> + <p>The undocumented, unsupport, and deprecated function + <c>lists:flat_length/1</c> has been removed.</p> + <p> + Own Id: OTP-8584</p> + </item> + <item> + <p> + A bug in re that could cause certain regular expression + matches never to terminate is corrected. (Thanks to + Michael Santos and Gordon Guthrie.)</p> + <p> + Own Id: OTP-8589</p> + </item> + <item> + <p>Nested records can now be accessed without + parenthesis. See the Reference Manual for examples. + (Thanks to YAMASHINA Hio and Tuncer Ayaz.)</p> + <p> + Own Id: OTP-8597</p> + </item> + <item> + <p><c>receive</c> statements that can only read out a + newly created reference are now specially optimized so + that it will execute in constant time regardless of the + number of messages in the receive queue for the process. + That optimization will benefit calls to + <c>gen_server:call()</c>. (See <c>gen:do_call/4</c> for + an example of a receive statement that will be + optimized.)</p> + <p> + Own Id: OTP-8623</p> + </item> + <item> + <p>The beam_lib:cmp/2 function now compares BEAM files in + stricter way. The BEAM files will be considered different + if there are any changes except in the compilation + information ("CInf") chunk. beam_lib:cmp/2 used to ignore + differences in the debug information (significant for + Dialyzer) and other chunks that did not directly change + the run-time behavior.</p> + <p> + Own Id: OTP-8625</p> + </item> + <item> + <p> + When a gen_server, gen_fsm process, or gen_event + terminates abnormally, sometimes the text representation + of the process state can occupy many lines of the error + log, depending on the definition of the state term. A + mechanism to trim out parts of the state from the log has + been added (using a format_status/2 callback). See the + documentation.</p> + <p> + Own Id: OTP-8630</p> + </item> + <item> + <p> + Calling <c>sys:get_status()</c> for processes that have + globally registered names that were not atoms would cause + a crash. Corrected. (Thanks to Steve Vinoski.)</p> + <p> + Own Id: OTP-8656</p> + </item> + <item> + <p>The Erlang scanner has been augmented with two new + tokens: <c>..</c> and <c>...</c>.</p> + <p> + Own Id: OTP-8657</p> + </item> + <item> + <p>Expressions evaluating to integers can now be used in + types and function specifications where hitherto only + integers were allowed ("Erlang_Integer").</p> + <p> + Own Id: OTP-8664</p> + </item> + <item> + <p>The compiler optimizes record operations better.</p> + <p> + Own Id: OTP-8668</p> + </item> + <item> + <p> + The recently added BIFs erlang:min/2, erlang:max/2 and + erlang:port_command/3 are now auto-imported (as they were + originally intended to be). Due to the recent compiler + change (OTP-8579), the only impact on old code defining + it's own min/2, max/2 or port_command/3 functions will be + a warning, the local functions will still be used. The + warning can be removed by using + -compile({no_auto_import,[min/2,max/2,port_command/3]}). + in the source file.</p> + <p> + *** POTENTIAL INCOMPATIBILITY ***</p> + <p> + Own Id: OTP-8669 Aux Id: OTP-8579 </p> + </item> + <item> + <p> + Now, binary_to_term/2 is auto-imported. This will cause a + compile warning if and only if a module has got a local + function with that name.</p> + <p> + *** POTENTIAL INCOMPATIBILITY ***</p> + <p> + Own Id: OTP-8671</p> + </item> + <item> + <p> + The predefined builtin type tid() has been removed. + Instead, ets:tid() should be used.</p> + <p> + *** POTENTIAL INCOMPATIBILITY ***</p> + <p> + Own Id: OTP-8687</p> + </item> + </list> + </section> + +</section> + <section><title>STDLIB 1.16.5</title> <section><title>Fixed Bugs and Malfunctions</title> @@ -50,7 +1035,7 @@ <item> <p>A number of bugs concerning re and unicode are corrected:</p> - <p>re:compile no longer looses unicode option, which also + <p>re:compile no longer loses unicode option, which also fixes bug in re:split.</p> <p>re:replace now handles unicode charlist replacement argument</p> @@ -1809,7 +2794,7 @@ that is, also when starting a gen_server, gen_fsm etc. </p> <p>This limitation has now been properly documented and the behavior of the <c>gen_fsm</c>, <c>gen_server</c>, and - <c>proc_lib</c><c>start</c> and <c>start_link</c> + <c>proc_lib</c> <c>start</c> and <c>start_link</c> functions when providing this option has been changed from hanging indefinitely to failing with reason <c>badarg</c>.</p> @@ -1926,7 +2911,6 @@ <c>join</c> option that can be used to force QLC to use a particular kind of join in some QLC expression.</p> <p>Several other changes have also been included:</p> - <p></p> <list type="bulleted"> <item> <p>The new <c>tmpdir</c> option of <c>cursor/2</c>, diff --git a/lib/stdlib/doc/src/orddict.xml b/lib/stdlib/doc/src/orddict.xml index 08c808f822..319083d35b 100644 --- a/lib/stdlib/doc/src/orddict.xml +++ b/lib/stdlib/doc/src/orddict.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>2000</year><year>2009</year> + <year>2000</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -46,176 +46,123 @@ (<c>==</c>).</p> </description> - <section> - <title>DATA TYPES</title> - <code type="none"> -ordered_dictionary() - as returned by new/0</code> - </section> + <datatypes> + <datatype> + <name name="orddict"/> + <desc><p>As returned by new/0.</p></desc> + </datatype> + </datatypes> + <funcs> <func> - <name>append(Key, Value, Orddict1) -> Orddict2</name> + <name name="append" arity="3"/> <fsummary>Append a value to keys in a dictionary</fsummary> - <type> - <v>Key = Value = term()</v> - <v>Orddict1 = Orddict2 = ordered_dictionary()</v> - </type> <desc> - <p>This function appends a new <c>Value</c> to the current list - of values associated with <c>Key</c>. An exception is - generated if the initial value associated with <c>Key</c> is + <p>This function appends a new <c><anno>Value</anno></c> to the current list + of values associated with <c><anno>Key</anno></c>. An exception is + generated if the initial value associated with <c><anno>Key</anno></c> is not a list of values.</p> </desc> </func> <func> - <name>append_list(Key, ValList, Orddict1) -> Orddict2</name> + <name name="append_list" arity="3"/> <fsummary>Append new values to keys in a dictionary</fsummary> - <type> - <v>ValList = [Value]</v> - <v>Key = Value = term()</v> - <v>Orddict1 = Orddict2 = ordered_dictionary()</v> - </type> <desc> - <p>This function appends a list of values <c>ValList</c> to - the current list of values associated with <c>Key</c>. An + <p>This function appends a list of values <c><anno>ValList</anno></c> to + the current list of values associated with <c><anno>Key</anno></c>. An exception is generated if the initial value associated with - <c>Key</c> is not a list of values.</p> + <c><anno>Key</anno></c> is not a list of values.</p> </desc> </func> <func> - <name>erase(Key, Orddict1) -> Orddict2</name> + <name name="erase" arity="2"/> <fsummary>Erase a key from a dictionary</fsummary> - <type> - <v>Key = term()</v> - <v>Orddict1 = Orddict2 = ordered_dictionary()</v> - </type> <desc> <p>This function erases all items with a given key from a dictionary.</p> </desc> </func> <func> - <name>fetch(Key, Orddict) -> Value</name> + <name name="fetch" arity="2"/> <fsummary>Look-up values in a dictionary</fsummary> - <type> - <v>Key = Value = term()</v> - <v>Orddict = ordered_dictionary()</v> - </type> <desc> - <p>This function returns the value associated with <c>Key</c> - in the dictionary <c>Orddict</c>. <c>fetch</c> assumes that - the <c>Key</c> is present in the dictionary and an exception - is generated if <c>Key</c> is not in the dictionary.</p> + <p>This function returns the value associated with <c><anno>Key</anno></c> + in the dictionary <c><anno>Orddict</anno></c>. <c>fetch</c> assumes that + the <c><anno>Key</anno></c> is present in the dictionary and an exception + is generated if <c><anno>Key</anno></c> is not in the dictionary.</p> </desc> </func> <func> - <name>fetch_keys(Orddict) -> Keys</name> + <name name="fetch_keys" arity="1"/> <fsummary>Return all keys in a dictionary</fsummary> - <type> - <v>Orddict = ordered_dictionary()</v> - <v>Keys = [term()]</v> - </type> <desc> <p>This function returns a list of all keys in the dictionary.</p> </desc> </func> <func> - <name>filter(Pred, Orddict1) -> Orddict2</name> + <name name="filter" arity="2"/> <fsummary>Choose elements which satisfy a predicate</fsummary> - <type> - <v>Pred = fun(Key, Value) -> bool()</v> - <v> Key = Value = term()</v> - <v>Orddict1 = Orddict2 = ordered_dictionary()</v> - </type> <desc> - <p><c>Orddict2</c> is a dictionary of all keys and values in - <c>Orddict1</c> for which <c>Pred(Key, Value)</c> is <c>true</c>.</p> + <p><c><anno>Orddict2</anno></c> is a dictionary of all keys and values in + <c><anno>Orddict1</anno></c> for which <c><anno>Pred</anno>(<anno>Key</anno>, <anno>Value</anno>)</c> is <c>true</c>.</p> </desc> </func> <func> - <name>find(Key, Orddict) -> {ok, Value} | error</name> + <name name="find" arity="2"/> <fsummary>Search for a key in a dictionary</fsummary> - <type> - <v>Key = Value = term()</v> - <v>Orddict = ordered_dictionary()</v> - </type> <desc> <p>This function searches for a key in a dictionary. Returns - <c>{ok, Value}</c> where <c>Value</c> is the value associated - with <c>Key</c>, or <c>error</c> if the key is not present in + <c>{ok, <anno>Value</anno>}</c> where <c><anno>Value</anno></c> is the value associated + with <c><anno>Key</anno></c>, or <c>error</c> if the key is not present in the dictionary.</p> </desc> </func> <func> - <name>fold(Fun, Acc0, Orddict) -> Acc1</name> + <name name="fold" arity="3"/> <fsummary>Fold a function over a dictionary</fsummary> - <type> - <v>Fun = fun(Key, Value, AccIn) -> AccOut</v> - <v>Key = Value = term()</v> - <v>Acc0 = Acc1 = AccIn = AccOut = term()</v> - <v>Orddict = ordered_dictionary()</v> - </type> <desc> - <p>Calls <c>Fun</c> on successive keys and values of - <c>Orddict</c> together with an extra argument <c>Acc</c> - (short for accumulator). <c>Fun</c> must return a new - accumulator which is passed to the next call. <c>Acc0</c> is + <p>Calls <c><anno>Fun</anno></c> on successive keys and values of + <c><anno>Orddict</anno></c> together with an extra argument <c>Acc</c> + (short for accumulator). <c><anno>Fun</anno></c> must return a new + accumulator which is passed to the next call. <c><anno>Acc0</anno></c> is returned if the list is empty. The evaluation order is undefined.</p> </desc> </func> <func> - <name>from_list(List) -> Orddict</name> + <name name="from_list" arity="1"/> <fsummary>Convert a list of pairs to a dictionary</fsummary> - <type> - <v>List = [{Key, Value}]</v> - <v>Orddict = ordered_dictionary()</v> - </type> <desc> - <p>This function converts the key/value list <c>List</c> to a - dictionary.</p> + <p>This function converts the <c><anno>Key</anno></c> - <c><anno>Value</anno></c> list + <c><anno>List</anno></c> to a dictionary.</p> </desc> </func> <func> - <name>is_key(Key, Orddict) -> bool()</name> + <name name="is_key" arity="2"/> <fsummary>Test if a key is in a dictionary</fsummary> - <type> - <v>Key = term()</v> - <v>Orddict = ordered_dictionary()</v> - </type> <desc> - <p>This function tests if <c>Key</c> is contained in - the dictionary <c>Orddict</c>.</p> + <p>This function tests if <c><anno>Key</anno></c> is contained in + the dictionary <c><anno>Orddict</anno></c>.</p> </desc> </func> <func> - <name>map(Fun, Orddict1) -> Orddict2</name> + <name name="map" arity="2"/> <fsummary>Map a function over a dictionary</fsummary> - <type> - <v>Fun = fun(Key, Value1) -> Value2</v> - <v> Key = Value1 = Value2 = term()</v> - <v>Orddict1 = Orddict2 = ordered_dictionary()</v> - </type> <desc> - <p><c>map</c> calls <c>Func</c> on successive keys and values - of <c>Orddict</c> to return a new value for each key. + <p><c>map</c> calls <c><anno>Fun</anno></c> on successive keys and values + of <c><anno>Orddict1</anno></c> to return a new value for each key. The evaluation order is undefined.</p> </desc> </func> <func> - <name>merge(Fun, Orddict1, Orddict2) -> Orddict3</name> + <name name="merge" arity="3"/> <fsummary>Merge two dictionaries</fsummary> - <type> - <v>Fun = fun(Key, Value1, Value2) -> Value</v> - <v> Key = Value1 = Value2 = Value3 = term()</v> - <v>Orddict1 = Orddict2 = Orddict3 = ordered_dictionary()</v> - </type> <desc> - <p><c>merge</c> merges two dictionaries, <c>Orddict1</c> and - <c>Orddict2</c>, to create a new dictionary. All the <c>Key</c> - - <c>Value</c> pairs from both dictionaries are included in + <p><c>merge</c> merges two dictionaries, <c><anno>Orddict1</anno></c> and + <c><anno>Orddict2</anno></c>, to create a new dictionary. All the <c><anno>Key</anno></c> + - <c><anno>Value</anno></c> pairs from both dictionaries are included in the new dictionary. If a key occurs in both dictionaries then - <c>Fun</c> is called with the key and both values to return a + <c><anno>Fun</anno></c> is called with the key and both values to return a new value. <c>merge</c> could be defined as:</p> <code type="none"> merge(Fun, D1, D2) -> @@ -226,75 +173,52 @@ merge(Fun, D1, D2) -> </desc> </func> <func> - <name>new() -> ordered_dictionary()</name> + <name name="new" arity="0"/> <fsummary>Create a dictionary</fsummary> <desc> <p>This function creates a new dictionary.</p> </desc> </func> <func> - <name>size(Orddict) -> int()</name> + <name name="size" arity="1"/> <fsummary>Return the number of elements in an ordered dictionary</fsummary> - <type> - <v>Orddict = ordered_dictionary()</v> - </type> <desc> - <p>Returns the number of elements in an <c>Orddict</c>.</p> + <p>Returns the number of elements in an <c><anno>Orddict</anno></c>.</p> </desc> </func> <func> - <name>store(Key, Value, Orddict1) -> Orddict2</name> + <name name="store" arity="3"/> <fsummary>Store a value in a dictionary</fsummary> - <type> - <v>Key = Value = term()</v> - <v>Orddict1 = Orddict2 = ordered_dictionary()</v> - </type> <desc> - <p>This function stores a <c>Key</c> - <c>Value</c> pair in a - dictionary. If the <c>Key</c> already exists in <c>Orddict1</c>, - the associated value is replaced by <c>Value</c>.</p> + <p>This function stores a <c><anno>Key</anno></c> - <c><anno>Value</anno></c> pair in a + dictionary. If the <c><anno>Key</anno></c> already exists in <c><anno>Orddict1</anno></c>, + the associated value is replaced by <c><anno>Value</anno></c>.</p> </desc> </func> <func> - <name>to_list(Orddict) -> List</name> + <name name="to_list" arity="1"/> <fsummary>Convert a dictionary to a list of pairs</fsummary> - <type> - <v>Orddict = ordered_dictionary()</v> - <v>List = [{Key, Value}]</v> - </type> <desc> <p>This function converts the dictionary to a list representation.</p> </desc> </func> <func> - <name>update(Key, Fun, Orddict1) -> Orddict2</name> + <name name="update" arity="3"/> <fsummary>Update a value in a dictionary</fsummary> - <type> - <v>Key = term()</v> - <v>Fun = fun(Value1) -> Value2</v> - <v> Value1 = Value2 = term()</v> - <v>Orddict1 = Orddict2 = ordered_dictionary()</v> - </type> <desc> - <p>Update the a value in a dictionary by calling <c>Fun</c> on + <p>Update a value in a dictionary by calling <c><anno>Fun</anno></c> on the value to get a new value. An exception is generated if - <c>Key</c> is not present in the dictionary.</p> + <c><anno>Key</anno></c> is not present in the dictionary.</p> </desc> </func> <func> - <name>update(Key, Fun, Initial, Orddict1) -> Orddict2</name> + <name name="update" arity="4"/> <fsummary>Update a value in a dictionary</fsummary> - <type> - <v>Key = Initial = term()</v> - <v>Fun = fun(Value1) -> Value2</v> - <v> Value1 = Value2 = term()</v> - <v>Orddict1 = Orddict2 = ordered_dictionary()</v> - </type> <desc> - <p>Update the a value in a dictionary by calling <c>Fun</c> on - the value to get a new value. If <c>Key</c> is not present - in the dictionary then <c>Initial</c> will be stored as + <p>Update a value in a dictionary by calling <c><anno>Fun</anno></c> on + the value to get a new value. If <c><anno>Key</anno></c> is not present + in the dictionary then <c><anno>Initial</anno></c> will be stored as the first value. For example <c>append/3</c> could be defined as:</p> <code type="none"> @@ -303,17 +227,12 @@ append(Key, Val, D) -> </desc> </func> <func> - <name>update_counter(Key, Increment, Orddict1) -> Orddict2</name> + <name name="update_counter" arity="3"/> <fsummary>Increment a value in a dictionary</fsummary> - <type> - <v>Key = term()</v> - <v>Increment = number()</v> - <v>Orddict1 = Orddict2 = ordered_dictionary()</v> - </type> <desc> - <p>Add <c>Increment</c> to the value associated with <c>Key</c> - and store this value. If <c>Key</c> is not present in - the dictionary then <c>Increment</c> will be stored as + <p>Add <c><anno>Increment</anno></c> to the value associated with <c><anno>Key</anno></c> + and store this value. If <c><anno>Key</anno></c> is not present in + the dictionary then <c><anno>Increment</anno></c> will be stored as the first value.</p> <p>This could be defined as:</p> <code type="none"> diff --git a/lib/stdlib/doc/src/ordsets.xml b/lib/stdlib/doc/src/ordsets.xml index a20ab2d879..1e26fc2022 100644 --- a/lib/stdlib/doc/src/ordsets.xml +++ b/lib/stdlib/doc/src/ordsets.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2009</year> + <year>1996</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -45,202 +45,141 @@ different if and only if they do not compare equal (<c>==</c>).</p> </description> - <section> - <title>DATA TYPES</title> - <code type="none"> -ordered_set() - as returned by new/0</code> - </section> + <datatypes> + <datatype> + <name name="ordset" n_vars="1"/> + <desc><p>As returned by new/0.</p></desc> + </datatype> + </datatypes> <funcs> <func> - <name>new() -> Ordset</name> + <name name="new" arity="0"/> <fsummary>Return an empty set</fsummary> - <type> - <v>Ordset = ordered_set()</v> - </type> <desc> <p>Returns a new empty ordered set.</p> </desc> </func> <func> - <name>is_set(Ordset) -> bool()</name> + <name name="is_set" arity="1"/> <fsummary>Test for an <c>Ordset</c></fsummary> - <type> - <v>Ordset = term()</v> - </type> <desc> - <p>Returns <c>true</c> if <c>Ordset</c> is an ordered set of + <p>Returns <c>true</c> if <c><anno>Ordset</anno></c> is an ordered set of elements, otherwise <c>false</c>.</p> </desc> </func> <func> - <name>size(Ordset) -> int()</name> + <name name="size" arity="1"/> <fsummary>Return the number of elements in a set</fsummary> - <type> - <v>Ordset = term()</v> - </type> <desc> - <p>Returns the number of elements in <c>Ordset</c>.</p> + <p>Returns the number of elements in <c><anno>Ordset</anno></c>.</p> </desc> </func> <func> - <name>to_list(Ordset) -> List</name> + <name name="to_list" arity="1"/> <fsummary>Convert an <c>Ordset</c>into a list</fsummary> - <type> - <v>Ordset = ordered_set()</v> - <v>List = [term()]</v> - </type> <desc> - <p>Returns the elements of <c>Ordset</c> as a list.</p> + <p>Returns the elements of <c><anno>Ordset</anno></c> as a list.</p> </desc> </func> <func> - <name>from_list(List) -> Ordset</name> + <name name="from_list" arity="1"/> <fsummary>Convert a list into an <c>Ordset</c></fsummary> - <type> - <v>List = [term()]</v> - <v>Ordset = ordered_set()</v> - </type> <desc> - <p>Returns an ordered set of the elements in <c>List</c>.</p> + <p>Returns an ordered set of the elements in <c><anno>List</anno></c>.</p> </desc> </func> <func> - <name>is_element(Element, Ordset) -> bool()</name> + <name name="is_element" arity="2"/> <fsummary>Test for membership of an <c>Ordset</c></fsummary> - <type> - <v>Element = term()</v> - <v>Ordset = ordered_set()</v> - </type> <desc> - <p>Returns <c>true</c> if <c>Element</c> is an element of - <c>Ordset</c>, otherwise <c>false</c>.</p> + <p>Returns <c>true</c> if <c><anno>Element</anno></c> is an element of + <c><anno>Ordset</anno></c>, otherwise <c>false</c>.</p> </desc> </func> <func> - <name>add_element(Element, Ordset1) -> Ordset2</name> + <name name="add_element" arity="2"/> <fsummary>Add an element to an <c>Ordset</c></fsummary> - <type> - <v>Element = term()</v> - <v>Ordset1 = Ordset2 = ordered_set()</v> - </type> <desc> - <p>Returns a new ordered set formed from <c>Ordset1</c> with - <c>Element</c> inserted.</p> + <p>Returns a new ordered set formed from <c><anno>Ordset1</anno></c> with + <c><anno>Element</anno></c> inserted.</p> </desc> </func> <func> - <name>del_element(Element, Ordset1) -> Ordset2</name> + <name name="del_element" arity="2"/> <fsummary>Remove an element from an <c>Ordset</c></fsummary> - <type> - <v>Element = term()</v> - <v>Ordset1 = Ordset2 = ordered_set()</v> - </type> <desc> - <p>Returns <c>Ordset1</c>, but with <c>Element</c> removed.</p> + <p>Returns <c><anno>Ordset1</anno></c>, but with <c><anno>Element</anno></c> removed.</p> </desc> </func> <func> - <name>union(Ordset1, Ordset2) -> Ordset3</name> + <name name="union" arity="2"/> <fsummary>Return the union of two <c>Ordsets</c></fsummary> - <type> - <v>Ordset1 = Ordset2 = Ordset3 = ordered_set()</v> - </type> <desc> - <p>Returns the merged (union) set of <c>Ordset1</c> and - <c>Ordset2</c>.</p> + <p>Returns the merged (union) set of <c><anno>Ordset1</anno></c> and + <c><anno>Ordset2</anno></c>.</p> </desc> </func> <func> - <name>union(OrdsetList) -> Ordset</name> + <name name="union" arity="1"/> <fsummary>Return the union of a list of <c>Ordsets</c></fsummary> - <type> - <v>OrdsetList = [ordered_set()]</v> - <v>Ordset = ordered_set()</v> - </type> <desc> <p>Returns the merged (union) set of the list of sets.</p> </desc> </func> <func> - <name>intersection(Ordset1, Ordset2) -> Ordset3</name> + <name name="intersection" arity="2"/> <fsummary>Return the intersection of two <c>Ordsets</c></fsummary> - <type> - <v>Ordset1 = Ordset2 = Ordset3 = ordered_set()</v> - </type> <desc> - <p>Returns the intersection of <c>Ordset1</c> and - <c>Ordset2</c>.</p> + <p>Returns the intersection of <c><anno>Ordset1</anno></c> and + <c><anno>Ordset2</anno></c>.</p> </desc> </func> <func> - <name>intersection(OrdsetList) -> Ordset</name> + <name name="intersection" arity="1"/> <fsummary>Return the intersection of a list of <c>Ordsets</c></fsummary> - <type> - <v>OrdsetList = [ordered_set()]</v> - <v>Ordset = ordered_set()</v> - </type> <desc> <p>Returns the intersection of the non-empty list of sets.</p> </desc> </func> <func> - <name>is_disjoint(Ordset1, Ordset2) -> bool()</name> + <name name="is_disjoint" arity="2"/> <fsummary>Check whether two <c>Ordsets</c> are disjoint</fsummary> - <type> - <v>Ordset1 = Ordset2 = ordered_set()</v> - </type> <desc> - <p>Returns <c>true</c> if <c>Ordset1</c> and - <c>Ordset2</c> are disjoint (have no elements in common), + <p>Returns <c>true</c> if <c><anno>Ordset1</anno></c> and + <c><anno>Ordset2</anno></c> are disjoint (have no elements in common), and <c>false</c> otherwise.</p> </desc> </func> <func> - <name>subtract(Ordset1, Ordset2) -> Ordset3</name> + <name name="subtract" arity="2"/> <fsummary>Return the difference of two <c>Ordsets</c></fsummary> - <type> - <v>Ordset1 = Ordset2 = Ordset3 = ordered_set()</v> - </type> <desc> - <p>Returns only the elements of <c>Ordset1</c> which are not - also elements of <c>Ordset2</c>.</p> + <p>Returns only the elements of <c><anno>Ordset1</anno></c> which are not + also elements of <c><anno>Ordset2</anno></c>.</p> </desc> </func> <func> - <name>is_subset(Ordset1, Ordset2) -> bool()</name> + <name name="is_subset" arity="2"/> <fsummary>Test for subset</fsummary> - <type> - <v>Ordset1 = Ordset2 = ordered_set()</v> - </type> <desc> - <p>Returns <c>true</c> when every element of <c>Ordset</c>1 is - also a member of <c>Ordset2</c>, otherwise <c>false</c>.</p> + <p>Returns <c>true</c> when every element of <c><anno>Ordset1</anno></c> is + also a member of <c><anno>Ordset2</anno></c>, otherwise <c>false</c>.</p> </desc> </func> <func> - <name>fold(Function, Acc0, Ordset) -> Acc1</name> + <name name="fold" arity="3"/> <fsummary>Fold over set elements</fsummary> - <type> - <v>Function = fun (E, AccIn) -> AccOut</v> - <v>Acc0 = Acc1 = AccIn = AccOut = term()</v> - <v>Ordset = ordered_set()</v> - </type> <desc> - <p>Fold <c>Function</c> over every element in <c>Ordset</c> + <p>Fold <c><anno>Function</anno></c> over every element in <c><anno>Ordset</anno></c> returning the final value of the accumulator.</p> </desc> </func> <func> - <name>filter(Pred, Ordset1) -> Set2</name> + <name name="filter" arity="2"/> <fsummary>Filter set elements</fsummary> - <type> - <v>Pred = fun (E) -> bool()</v> - <v>Set1 = Set2 = ordered_set()</v> - </type> <desc> - <p>Filter elements in <c>Set1</c> with boolean function - <c>Fun</c>.</p> + <p>Filter elements in <c><anno>Ordset1</anno></c> with boolean function + <c><anno>Pred</anno></c>.</p> </desc> </func> </funcs> diff --git a/lib/stdlib/doc/src/part_notes_history.xml b/lib/stdlib/doc/src/part_notes_history.xml index 744b009583..5e055ee606 100644 --- a/lib/stdlib/doc/src/part_notes_history.xml +++ b/lib/stdlib/doc/src/part_notes_history.xml @@ -5,7 +5,7 @@ <header> <copyright> <year>2006</year> - <year>2007</year> + <year>2011</year> <holder>Ericsson AB, All Rights Reserved</holder> </copyright> <legalnotice> diff --git a/lib/stdlib/doc/src/pg.xml b/lib/stdlib/doc/src/pg.xml index 66b9702ae0..c56db8c6e6 100644 --- a/lib/stdlib/doc/src/pg.xml +++ b/lib/stdlib/doc/src/pg.xml @@ -5,7 +5,7 @@ <header> <copyright> <year>1996</year> - <year>2007</year> + <year>2011</year> <holder>Ericsson AB, All Rights Reserved</holder> </copyright> <legalnotice> @@ -51,77 +51,56 @@ </description> <funcs> <func> - <name>create(PgName) -> ok | {error, Reason}</name> + <name name="create" arity="1"/> <fsummary>Create an empty group</fsummary> - <type> - <v>PgName = term()</v> - <v>Reason = already_created | term()</v> - </type> <desc> - <p>Creates an empty group named <c>PgName</c> on the current + <p>Creates an empty group named <c><anno>PgName</anno></c> on the current node.</p> </desc> </func> <func> - <name>create(PgName, Node) -> ok | {error, Reason}</name> + <name name="create" arity="2"/> <fsummary>Create an empty group on another node</fsummary> - <type> - <v>PgName = term()</v> - <v>Node = node()</v> - <v>Reason = already_created | term()</v> - </type> <desc> - <p>Creates an empty group named <c>PgName</c> on the node - <c>Node</c>.</p> + <p>Creates an empty group named <c><anno>PgName</anno></c> on the node + <c><anno>Node</anno></c>.</p> </desc> </func> <func> - <name>join(PgName, Pid) -> Members</name> + <name name="join" arity="2"/> <fsummary>Join a pid to a process group</fsummary> - <type> - <v>PgName = term()</v> - <v>Pid = pid()</v> - <v>Members = [pid()]</v> - </type> <desc> - <p>Joins the pid <c>Pid</c> to the process group <c>PgName</c>. + <p>Joins the pid <c><anno>Pid</anno></c> to the process group + <c><anno>PgName</anno></c>. Returns a list of all old members of the group.</p> </desc> </func> <func> - <name>send(PgName, Msg) -> void()</name> + <name name="send" arity="2"/> <fsummary>Send a message to all members of a process group</fsummary> - <type> - <v>PgName = Msg = term()</v> - </type> <desc> <p>Sends the tuple <c>{pg_message, From, PgName, Msg}</c> to - all members of the process group <c>PgName</c>.</p> - <p>Failure: <c>{badarg, {PgName, Msg}}</c> if <c>PgName</c> is + all members of the process group <c><anno>PgName</anno></c>.</p> + <p>Failure: <c>{badarg, {<anno>PgName</anno>, <anno>Msg</anno>}}</c> + if <c><anno>PgName</anno></c> is not a process group (a globally registered name).</p> </desc> </func> <func> - <name>esend(PgName, Msg) -> void()</name> + <name name="esend" arity="2"/> <fsummary>Send a message to all members of a process group, except ourselves</fsummary> - <type> - <v>PgName = Msg = term()</v> - </type> <desc> <p>Sends the tuple <c>{pg_message, From, PgName, Msg}</c> to - all members of the process group <c>PgName</c>, except + all members of the process group <c><anno>PgName</anno></c>, except ourselves.</p> - <p>Failure: <c>{badarg, {PgName, Msg}}</c> if <c>PgName</c> is + <p>Failure: <c>{badarg, {<anno>PgName</anno>, <anno>Msg</anno>}}</c> + if <c><anno>PgName</anno></c> is not a process group (a globally registered name).</p> </desc> </func> <func> - <name>members(PgName) -> Members</name> + <name name="members" arity="1"/> <fsummary>Return a list of all members of a process group</fsummary> - <type> - <v>PgName = term()</v> - <v>Members = [pid()]</v> - </type> <desc> <p>Returns a list of all members of the process group <c>PgName</c>.</p> diff --git a/lib/stdlib/doc/src/pool.xml b/lib/stdlib/doc/src/pool.xml index 2b890352eb..39a79e5dc5 100644 --- a/lib/stdlib/doc/src/pool.xml +++ b/lib/stdlib/doc/src/pool.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2009</year> + <year>1996</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -48,23 +48,19 @@ </description> <funcs> <func> - <name>start(Name) -></name> - <name>start(Name, Args) -> Nodes</name> + <name name="start" arity="1"/> + <name name="start" arity="2"/> <fsummary>>Start a new pool</fsummary> - <type> - <v>Name = atom()</v> - <v>Args = string()</v> - <v>Nodes = [node()]</v> - </type> <desc> <p>Starts a new pool. The file <c>.hosts.erlang</c> is read to find host names where the pool nodes can be started. See section <seealso marker="#files">Files</seealso> below. The start-up procedure fails if the file is not found.</p> <p>The slave nodes are started with <c>slave:start/2,3</c>, - passing along <c>Name</c> and, if provided, <c>Args</c>. - <c>Name</c> is used as the first part of the node names, - <c>Args</c> is used to specify command line arguments. See + passing along <c><anno>Name</anno></c> and, if provided, + <c><anno>Args</anno></c>. + <c><anno>Name</anno></c> is used as the first part of the node names, + <c><anno>Args</anno></c> is used to specify command line arguments. See <seealso marker="slave#start/2">slave(3)</seealso>.</p> <p>Access rights must be set so that all nodes in the pool have the authority to access each other.</p> @@ -73,59 +69,45 @@ </desc> </func> <func> - <name>attach(Node) -> already_attached | attached</name> + <name name="attach" arity="1"/> <fsummary>Ensure that a pool master is running</fsummary> - <type> - <v>Node = node()</v> - </type> <desc> <p>This function ensures that a pool master is running and - includes <c>Node</c> in the pool master's pool of nodes.</p> + includes <c><anno>Node</anno></c> in the pool master's pool of nodes.</p> </desc> </func> <func> - <name>stop() -> stopped</name> + <name name="stop" arity="0"/> <fsummary>Stop the pool and kill all the slave nodes</fsummary> <desc> <p>Stops the pool and kills all the slave nodes.</p> </desc> </func> <func> - <name>get_nodes() -> Nodes</name> + <name name="get_nodes" arity="0"/> <fsummary>Return a list of the current member nodes of the pool</fsummary> - <type> - <v>Nodes = [node()]</v> - </type> <desc> <p>Returns a list of the current member nodes of the pool.</p> </desc> </func> <func> - <name>pspawn(Mod, Fun, Args) -> pid()</name> + <name name="pspawn" arity="3"/> <fsummary>Spawn a process on the pool node with expected lowest future load</fsummary> - <type> - <v>Mod = Fun = atom()</v> - <v>Args = [term()]</v> - </type> <desc> <p>Spawns a process on the pool node which is expected to have the lowest future load.</p> </desc> </func> <func> - <name>pspawn_link(Mod, Fun, Args) -> pid()</name> + <name name="pspawn_link" arity="3"/> <fsummary>Spawn and link to a process on the pool node with expected lowest future load</fsummary> - <type> - <v>Mod = Fun = atom()</v> - <v>Args = [term()]</v> - </type> <desc> <p>Spawn links a process on the pool node which is expected to have the lowest future load.</p> </desc> </func> <func> - <name>get_node() -> node()</name> + <name name="get_node" arity="0"/> <fsummary>Return the node with the expected lowest future load</fsummary> <desc> <p>Returns the node with the expected lowest future load.</p> diff --git a/lib/stdlib/doc/src/proc_lib.xml b/lib/stdlib/doc/src/proc_lib.xml index 791001cb52..abc17c4a91 100644 --- a/lib/stdlib/doc/src/proc_lib.xml +++ b/lib/stdlib/doc/src/proc_lib.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2009</year> + <year>1996</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -60,19 +60,33 @@ information regarding other processes which terminate as a result of this process terminating.</p> </description> + <datatypes> + <datatype> + <name name="spawn_option"/> + <desc> + <p>See <seealso marker="erts:erlang#spawn_opt/4"> + erlang:spawn_opt/2,3,4,5</seealso>.</p> + </desc> + </datatype> + <datatype> + <name name="priority_level"/> + </datatype> + <datatype> + <name name="dict_or_pid"/> + </datatype> + </datatypes> <funcs> <func> - <name>spawn(Fun) -> pid()</name> - <name>spawn(Node, Fun) -> pid()</name> - <name>spawn(Module, Function, Args) -> pid()</name> - <name>spawn(Node, Module, Function, Args) -> pid()</name> + <name name="spawn" arity="1"/> + <name name="spawn" arity="2"/> + <name name="spawn" arity="3"/> + <name name="spawn" arity="4"/> <fsummary>Spawn a new process.</fsummary> - <type> - <v>Node = node()</v> - <v>Fun = fun() -> void()</v> - <v>Module = Function = atom()</v> - <v>Args = [term()]</v> - </type> + <type variable="Node"/> + <type variable="Fun" name_i="1"/> + <type variable="Module"/> + <type variable="Function"/> + <type variable="Args"/> <desc> <p>Spawns a new process and initializes it as described above. The process is spawned using the @@ -80,17 +94,16 @@ </desc> </func> <func> - <name>spawn_link(Fun) -> pid()</name> - <name>spawn_link(Node, Fun) -> pid()</name> - <name>spawn_link(Module, Function, Args) -> pid()</name> - <name>spawn_link(Node, Module, Function, Args) -> pid()</name> + <name name="spawn_link" arity="1"/> + <name name="spawn_link" arity="2"/> + <name name="spawn_link" arity="3"/> + <name name="spawn_link" arity="4"/> <fsummary>Spawn and link to a new process.</fsummary> - <type> - <v>Node = node()</v> - <v>Fun = fun() -> void()</v> - <v>Module = Function = atom()</v> - <v>Args = [term()]</v> - </type> + <type variable="Node"/> + <type variable="Fun" name_i="1"/> + <type variable="Module"/> + <type variable="Function"/> + <type variable="Args"/> <desc> <p>Spawns a new process and initializes it as described above. The process is spawned using the @@ -99,18 +112,17 @@ </desc> </func> <func> - <name>spawn_opt(Fun, SpawnOpts) -> pid()</name> - <name>spawn_opt(Node, Fun, SpawnOpts) -> pid()</name> - <name>spawn_opt(Module, Function, Args, SpawnOpts) -> pid()</name> - <name>spawn_opt(Node, Module, Func, Args, SpawnOpts) -> pid()</name> + <name name="spawn_opt" arity="2"/> + <name name="spawn_opt" arity="3"/> + <name name="spawn_opt" arity="4"/> + <name name="spawn_opt" arity="5"/> <fsummary>Spawn a new process with given options.</fsummary> - <type> - <v>Node = node()</v> - <v>Fun = fun() -> void()</v> - <v>Module = Function = atom()</v> - <v>Args = [term()]</v> - <v>SpawnOpts -- see erlang:spawn_opt/2,3,4,5</v> - </type> + <type variable="Node"/> + <type variable="Fun" name_i="1"/> + <type variable="Module"/> + <type variable="Function"/> + <type variable="Args"/> + <type variable="SpawnOpts"/> <desc> <p>Spawns a new process and initializes it as described above. The process is spawned using the @@ -124,20 +136,13 @@ </desc> </func> <func> - <name>start(Module, Function, Args) -> Ret</name> - <name>start(Module, Function, Args, Time) -> Ret</name> - <name>start(Module, Function, Args, Time, SpawnOpts) -> Ret</name> - <name>start_link(Module, Function, Args) -> Ret</name> - <name>start_link(Module, Function, Args, Time) -> Ret</name> - <name>start_link(Module, Function, Args, Time, SpawnOpts) -> Ret</name> + <name name="start" arity="3"/> + <name name="start" arity="4"/> + <name name="start" arity="5"/> + <name name="start_link" arity="3"/> + <name name="start_link" arity="4"/> + <name name="start_link" arity="5"/> <fsummary>Start a new process synchronously.</fsummary> - <type> - <v>Module = Function = atom()</v> - <v>Args = [term()]</v> - <v>Time = int() >= 0 | infinity</v> - <v>SpawnOpts -- see erlang:spawn_opt/2,3,4,5</v> - <v>Ret = term() | {error, Reason}</v> - </type> <desc> <p>Starts a new process synchronously. Spawns the process and waits for it to start. When the process has started, it @@ -148,13 +153,13 @@ function. At this time, <c>Ret</c> is returned.</p> <p>If the <c>start_link/3,4,5</c> function is used and the process crashes before it has called <c>init_ack/1,2</c>, - <c>{error, Reason}</c> is returned if the calling process + <c>{error, <anno>Reason</anno>}</c> is returned if the calling process traps exits.</p> - <p>If <c>Time</c> is specified as an integer, this function - waits for <c>Time</c> milliseconds for the new process to call + <p>If <c><anno>Time</anno></c> is specified as an integer, this function + waits for <c><anno>Time</anno></c> milliseconds for the new process to call <c>init_ack</c>, or <c>{error, timeout}</c> is returned, and the process is killed.</p> - <p>The <c>SpawnOpts</c> argument, if given, will be passed + <p>The <c><anno>SpawnOpts</anno></c> argument, if given, will be passed as the last argument to the <c>spawn_opt/2,3,4,5</c> BIF.</p> <note> <p>Using the spawn option <c>monitor</c> is currently not @@ -164,17 +169,13 @@ </desc> </func> <func> - <name>init_ack(Parent, Ret) -> void()</name> - <name>init_ack(Ret) -> void()</name> + <name name="init_ack" arity="1"/> + <name name="init_ack" arity="2"/> <fsummary>Used by a process when it has started.</fsummary> - <type> - <v>Parent = pid()</v> - <v>Ret = term()</v> - </type> <desc> <p>This function must used by a process that has been started by a <seealso marker="#start/3">start[_link]/3,4,5</seealso> - function. It tells <c>Parent</c> that the process has + function. It tells <c><anno>Parent</anno></c> that the process has initialized itself, has started, or has failed to initialize itself.</p> <p>The <c>init_ack/1</c> function uses the parent value @@ -205,40 +206,30 @@ init(Parent) -> </desc> </func> <func> - <name>format(CrashReport) -> string()</name> + <name name="format" arity="1"/> <fsummary>Format a crash report.</fsummary> - <type> - <v>CrashReport = term()</v> - </type> <desc> <p>This function can be used by a user defined event handler to format a crash report. The crash report is sent using - <c>error_logger:error_report(crash_report, CrashReport)</c>. + <c>error_logger:error_report(crash_report, <anno>CrashReport</anno>)</c>. That is, the event to be handled is of the format - <c>{error_report, GL, {Pid, crash_report, CrashReport}}</c> + <c>{error_report, GL, {Pid, crash_report, <anno>CrashReport</anno>}}</c> where <c>GL</c> is the group leader pid of the process <c>Pid</c> which sent the crash report.</p> </desc> </func> <func> - <name>initial_call(Process) -> {Module,Function,Args} | false</name> + <name name="initial_call" arity="1"/> <fsummary>Extract the initial call of a <c>proc_lib</c>spawned process.</fsummary> - <type> - <v>Process = pid() | {X,Y,Z} | ProcInfo</v> - <v> X = Y = Z = int()</v> - <v> ProcInfo = term()</v> - <v>Module = Function = atom()</v> - <v>Args = [atom()]</v> - </type> <desc> <p>Extracts the initial call of a process that was started using one of the spawn or start functions described above. - <c>Process</c> can either be a pid, an integer tuple (from + <c><anno>Process</anno></c> can either be a pid, an integer tuple (from which a pid can be created), or the process information of a process <c>Pid</c> fetched through an <c>erlang:process_info(Pid)</c> function call.</p> - <note><p>The list <c>Args</c> no longer contains the actual arguments, + <note><p>The list <c><anno>Args</anno></c> no longer contains the actual arguments, but the same number of atoms as the number of arguments; the first atom is always <c>'Argument__1'</c>, the second <c>'Argument__2'</c>, and so on. The reason is that the argument list could waste a significant @@ -256,23 +247,15 @@ init(Parent) -> </desc> </func> <func> - <name>translate_initial_call(Process) -> {Module,Function,Arity} | Fun</name> + <name name="translate_initial_call" arity="1"/> <fsummary>Extract and translate the initial call of a <c>proc_lib</c>spawned process.</fsummary> - <type> - <v>Process = pid() | {X,Y,Z} | ProcInfo</v> - <v> X = Y = Z = int()</v> - <v> ProcInfo = term()</v> - <v>Module = Function = atom()</v> - <v>Arity = int()</v> - <v>Fun = fun() -> void()</v> - </type> <desc> <p>This function is used by the <c>c:i/0</c> and <c>c:regs/0</c> functions in order to present process information.</p> <p>Extracts the initial call of a process that was started using one of the spawn or start functions described above, - and translates it to more useful information. <c>Process</c> + and translates it to more useful information. <c><anno>Process</anno></c> can either be a pid, an integer tuple (from which a pid can be created), or the process information of a process <c>Pid</c> fetched through an <c>erlang:process_info(Pid)</c> @@ -280,15 +263,15 @@ init(Parent) -> <p>If the initial call is to one of the system defined behaviors such as <c>gen_server</c> or <c>gen_event</c>, it is translated to more useful information. If a <c>gen_server</c> - is spawned, the returned <c>Module</c> is the name of - the callback module and <c>Function</c> is <c>init</c> + is spawned, the returned <c><anno>Module</anno></c> is the name of + the callback module and <c><anno>Function</anno></c> is <c>init</c> (the function that initiates the new server).</p> <p>A <c>supervisor</c> and a <c>supervisor_bridge</c> are also <c>gen_server</c> processes. In order to return information that this process is a supervisor and the name of the - call-back module, <c>Module</c> is <c>supervisor</c> and - <c>Function</c> is the name of the supervisor callback - module. <c>Arity</c> is <c>1</c> since the <c>init/1</c> + call-back module, <c><anno>Module</anno></c> is <c>supervisor</c> and + <c><anno>Function</anno></c> is the name of the supervisor callback + module. <c><anno>Arity</anno></c> is <c>1</c> since the <c>init/1</c> function is called initially in the callback module.</p> <p>By default, <c>{proc_lib,init_p,5}</c> is returned if no information about the initial call can be found. It is @@ -297,12 +280,8 @@ init(Parent) -> </desc> </func> <func> - <name>hibernate(Module, Function, Args)</name> + <name name="hibernate" arity="3"/> <fsummary>Hibernate a process until a message is sent to it</fsummary> - <type> - <v>Module = Function = atom()</v> - <v>Args = [term()]</v> - </type> <desc> <p>This function does the same as (and does call) the BIF <seealso marker="erts:erlang#erlang:hibernate/3">hibernate/3</seealso>, diff --git a/lib/stdlib/doc/src/proplists.xml b/lib/stdlib/doc/src/proplists.xml index 9f1c5b24ad..225c5e97eb 100644 --- a/lib/stdlib/doc/src/proplists.xml +++ b/lib/stdlib/doc/src/proplists.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>2002</year><year>2010</year> + <year>2002</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -48,14 +48,15 @@ words, numbers are compared literally rather than by value, so that, for instance, <c>1</c> and <c>1.0</c> are different keys.</p> </description> + <datatypes> + <datatype> + <name name="property"/> + </datatype> + </datatypes> <funcs> <func> - <name>append_values(Key, List) -> List</name> + <name name="append_values" arity="2"/> <fsummary></fsummary> - <type> - <v>Key = term()</v> - <v>List = [term()]</v> - </type> <desc> <p>Similar to <c>get_all_values/2</c>, but each value is wrapped in a list unless it is already itself a list, and the @@ -65,11 +66,8 @@ </desc> </func> <func> - <name>compact(List) -> List</name> + <name name="compact" arity="1"/> <fsummary></fsummary> - <type> - <v>List = [term()]</v> - </type> <desc> <p>Minimizes the representation of all entries in the list. This is equivalent to <c><![CDATA[[property(P) || P <- List]]]></c>.</p> @@ -77,33 +75,24 @@ </desc> </func> <func> - <name>delete(Key, List) -> List</name> + <name name="delete" arity="2"/> <fsummary></fsummary> - <type> - <v>Key = term()</v> - <v>List = [term()]</v> - </type> <desc> - <p>Deletes all entries associated with <c>Key</c> from - <c>List</c>.</p> + <p>Deletes all entries associated with <c><anno>Key</anno></c> from + <c><anno>List</anno></c>.</p> </desc> </func> <func> - <name>expand(Expansions, List) -> List</name> + <name name="expand" arity="2"/> <fsummary></fsummary> - <type> - <v>Key = term()</v> - <v>Expansions = [{Property,[term()]}]</v> - <v>Property = atom() | tuple()</v> - </type> <desc> <p>Expands particular properties to corresponding sets of - properties (or other terms). For each pair <c>{Property, Expansion}</c> in <c>Expansions</c>, if <c>E</c> is - the first entry in <c>List</c> with the same key as - <c>Property</c>, and <c>E</c> and <c>Property</c> + properties (or other terms). For each pair <c>{<anno>Property</anno>, <anno>Expansion</anno>}</c> in <c><anno>Expansions</anno></c>, if <c>E</c> is + the first entry in <c><anno>List</anno></c> with the same key as + <c><anno>Property</anno></c>, and <c>E</c> and <c><anno>Property</anno></c> have equivalent normal forms, then <c>E</c> is replaced with - the terms in <c>Expansion</c>, and any following entries with - the same key are deleted from <c>List</c>.</p> + the terms in <c><anno>Expansion</anno></c>, and any following entries with + the same key are deleted from <c><anno>List</anno></c>.</p> <p>For example, the following expressions all return <c>[fie, bar, baz, fum]</c>:</p> <code type="none"> expand([{foo, [bar, baz]}], @@ -120,103 +109,75 @@ <p>Note that if the original property term is to be preserved in the result when expanded, it must be included in the expansion list. The inserted terms are not expanded recursively. If - <c>Expansions</c> contains more than one property with the same + <c><anno>Expansions</anno></c> contains more than one property with the same key, only the first occurrence is used.</p> <p>See also: <c>normalize/2</c>.</p> </desc> </func> <func> - <name>get_all_values(Key, List) -> [term()]</name> + <name name="get_all_values" arity="2"/> <fsummary></fsummary> - <type> - <v>Key = term()</v> - <v>List = [term()]</v> - </type> <desc> <p>Similar to <c>get_value/2</c>, but returns the list of values for <em>all</em> entries <c>{Key, Value}</c> in - <c>List</c>. If no such entry exists, the result is the empty + <c><anno>List</anno></c>. If no such entry exists, the result is the empty list.</p> <p>See also: <c>get_value/2</c>.</p> </desc> </func> <func> - <name>get_bool(Key, List) -> bool()</name> + <name name="get_bool" arity="2"/> <fsummary></fsummary> - <type> - <v>Key = term()</v> - <v>List = [term()]</v> - </type> <desc> <p>Returns the value of a boolean key/value option. If - <c>lookup(Key, List)</c> would yield <c>{Key, true}</c>, + <c>lookup(<anno>Key</anno>, <anno>List</anno>)</c> would yield <c>{<anno>Key</anno>, true}</c>, this function returns <c>true</c>; otherwise <c>false</c> is returned.</p> <p>See also: <c>get_value/2</c>, <c>lookup/2</c>.</p> </desc> </func> <func> - <name>get_keys(List) -> [term()]</name> + <name name="get_keys" arity="1"/> <fsummary></fsummary> - <type> - <v>List = [term()]</v> - </type> <desc> - <p>Returns an unordered list of the keys used in <c>List</c>, + <p>Returns an unordered list of the keys used in <c><anno>List</anno></c>, not containing duplicates.</p> </desc> </func> <func> - <name>get_value(Key, List) -> term()</name> + <name name="get_value" arity="2"/> <fsummary></fsummary> - <type> - <v>Key = term()</v> - <v>List = [term()]</v> - </type> <desc> - <p>Equivalent to <c>get_value(Key, List, undefined)</c>.</p> + <p>Equivalent to <c>get_value(<anno>Key</anno>, <anno>List</anno>, undefined)</c>.</p> </desc> </func> <func> - <name>get_value(Key, List, Default) -> term()</name> + <name name="get_value" arity="3"/> <fsummary></fsummary> - <type> - <v>Key = term()</v> - <v>Default = term()</v> - <v>List = [term()]</v> - </type> <desc> <p>Returns the value of a simple key/value property in - <c>List</c>. If <c>lookup(Key, List)</c> would yield - <c>{Key, Value}</c>, this function returns the corresponding - <c>Value</c>, otherwise <c>Default</c> is returned.</p> + <c><anno>List</anno></c>. If <c>lookup(<anno>Key</anno>, <anno>List</anno>)</c> would yield + <c>{<anno>Key</anno>, Value}</c>, this function returns the corresponding + <c>Value</c>, otherwise <c><anno>Default</anno></c> is returned.</p> <p>See also: <c>get_all_values/2</c>, <c>get_bool/2</c>, <c>get_value/2</c>, <c>lookup/2</c>.</p> </desc> </func> <func> - <name>is_defined(Key, List) -> bool()</name> + <name name="is_defined" arity="2"/> <fsummary></fsummary> - <type> - <v>Key = term()</v> - <v>List = [term()]</v> - </type> <desc> - <p>Returns <c>true</c> if <c>List</c> contains at least - one entry associated with <c>Key</c>, otherwise + <p>Returns <c>true</c> if <c><anno>List</anno></c> contains at least + one entry associated with <c><anno>Key</anno></c>, otherwise <c>false</c> is returned.</p> </desc> </func> <func> - <name>lookup(Key, List) -> none | tuple()</name> + <name name="lookup" arity="2"/> <fsummary></fsummary> - <type> - <v>Key = term()</v> - <v>List = [term()]</v> - </type> <desc> - <p>Returns the first entry associated with <c>Key</c> in - <c>List</c>, if one exists, otherwise returns + <p>Returns the first entry associated with <c><anno>Key</anno></c> in + <c><anno>List</anno></c>, if one exists, otherwise returns <c>none</c>. For an atom <c>A</c> in the list, the tuple <c>{A, true}</c> is the entry associated with <c>A</c>.</p> <p>See also: <c>get_bool/2</c>, <c>get_value/2</c>, @@ -224,34 +185,20 @@ </desc> </func> <func> - <name>lookup_all(Key, List) -> [tuple()]</name> + <name name="lookup_all" arity="2"/> <fsummary></fsummary> - <type> - <v>Key = term()</v> - <v>List = [term()]</v> - </type> <desc> - <p>Returns the list of all entries associated with <c>Key</c> - in <c>List</c>. If no such entry exists, the result is the + <p>Returns the list of all entries associated with <c><anno>Key</anno></c> + in <c><anno>List</anno></c>. If no such entry exists, the result is the empty list.</p> <p>See also: <c>lookup/2</c>.</p> </desc> </func> <func> - <name>normalize(List, Stages) -> List</name> + <name name="normalize" arity="2"/> <fsummary></fsummary> - <type> - <v>List = [term()]</v> - <v>Stages = [Operation]</v> - <v>Operation = {aliases, Aliases} | {negations, Negations} | {expand, Expansions}</v> - <v>Aliases = [{Key, Key}]</v> - <v>Negations = [{Key, Key}]</v> - <v>Key = term()</v> - <v>Expansions = [{Property, [term()]}]</v> - <v>Property = atom() | tuple()</v> - </type> <desc> - <p>Passes <c>List</c> through a sequence of + <p>Passes <c><anno>List</anno></c> through a sequence of substitution/expansion stages. For an <c>aliases</c> operation, the function <c>substitute_aliases/2</c> is applied using the given list of aliases; for a <c>negations</c> operation, @@ -270,51 +217,37 @@ </desc> </func> <func> - <name>property(Property) -> Property</name> + <name name="property" arity="1"/> <fsummary></fsummary> - <type> - <v>Property = atom() | tuple()</v> - </type> <desc> <p>Creates a normal form (minimal) representation of a property. If - <c>Property</c> is <c>{Key, true}</c> where <c>Key</c> is + <c><anno>Property</anno></c> is <c>{Key, true}</c> where <c>Key</c> is an atom, this returns <c>Key</c>, otherwise the whole term - <c>Property</c> is returned.</p> + <c><anno>Property</anno></c> is returned.</p> <p>See also: <c>property/2</c>.</p> </desc> </func> <func> - <name>property(Key, Value) -> Property</name> + <name name="property" arity="2"/> <fsummary></fsummary> - <type> - <v>Key = term()</v> - <v>Value = term()</v> - <v>Property = atom() | tuple()</v> - </type> <desc> <p>Creates a normal form (minimal) representation of a simple - key/value property. Returns <c>Key</c> if <c>Value</c> is - <c>true</c> and <c>Key</c> is an atom, otherwise a tuple - <c>{Key, Value}</c> is returned.</p> + key/value property. Returns <c><anno>Key</anno></c> if <c><anno>Value</anno></c> is + <c>true</c> and <c><anno>Key</anno></c> is an atom, otherwise a tuple + <c>{<anno>Key</anno>, <anno>Value</anno>}</c> is returned.</p> <p>See also: <c>property/1</c>.</p> </desc> </func> <func> - <name>split(List, Keys) -> {Lists, Rest}</name> + <name name="split" arity="2"/> <fsummary></fsummary> - <type> - <v>List = [term()]</v> - <v>Keys = [term()]</v> - <v>Lists = [[term()]]</v> - <v>Rest = [term()]</v> - </type> <desc> - <p>Partitions <c>List</c> into a list of sublists and a - remainder. <c>Lists</c> contains one sublist for each key in - <c>Keys</c>, in the corresponding order. The relative order of + <p>Partitions <c><anno>List</anno></c> into a list of sublists and a + remainder. <c><anno>Lists</anno></c> contains one sublist for each key in + <c><anno>Keys</anno></c>, in the corresponding order. The relative order of the elements in each sublist is preserved from the original - <c>List</c>. <c>Rest</c> contains the elements in - <c>List</c> that are not associated with any of the given keys, + <c><anno>List</anno></c>. <c><anno>Rest</anno></c> contains the elements in + <c><anno>List</anno></c> that are not associated with any of the given keys, also with their original relative order preserved.</p> <p>Example: split([{c, 2}, {e, 1}, a, {c, 3, 4}, d, {b, 5}, b], [a, b, c])</p> @@ -323,19 +256,14 @@ </desc> </func> <func> - <name>substitute_aliases(Aliases, List) -> List</name> + <name name="substitute_aliases" arity="2"/> <fsummary></fsummary> - <type> - <v>Aliases = [{Key, Key}]</v> - <v>Key = term()</v> - <v>List = [term()]</v> - </type> <desc> <p>Substitutes keys of properties. For each entry in - <c>List</c>, if it is associated with some key <c>K1</c> - such that <c>{K1, K2}</c> occurs in <c>Aliases</c>, the - key of the entry is changed to <c>Key2</c>. If the same - <c>K1</c> occurs more than once in <c>Aliases</c>, only + <c><anno>List</anno></c>, if it is associated with some key <c>K1</c> + such that <c>{K1, K2}</c> occurs in <c><anno>Aliases</anno></c>, the + key of the entry is changed to <c>K2</c>. If the same + <c>K1</c> occurs more than once in <c><anno>Aliases</anno></c>, only the first occurrence is used.</p> <p>Example: <c>substitute_aliases([{color, colour}], L)</c> will replace all tuples <c>{color, ...}</c> in <c>L</c> @@ -345,24 +273,19 @@ </desc> </func> <func> - <name>substitute_negations(Negations, List) -> List</name> + <name name="substitute_negations" arity="2"/> <fsummary></fsummary> - <type> - <v>Negations = [{Key, Key}]</v> - <v>Key = term()</v> - <v>List = [term()]</v> - </type> <desc> <p>Substitutes keys of boolean-valued properties and simultaneously negates their values. For each entry in - <c>List</c>, if it is associated with some key <c>K1</c> - such that <c>{K1, K2}</c> occurs in <c>Negations</c>, then + <c><anno>List</anno></c>, if it is associated with some key <c>K1</c> + such that <c>{K1, K2}</c> occurs in <c><anno>Negations</anno></c>, then if the entry was <c>{K1, true}</c> it will be replaced with <c>{K2, false}</c>, otherwise it will be replaced with <c>{K2, true}</c>, thus changing the name of the option and simultaneously negating the value given by <c>get_bool(List)</c>. If the same <c>K1</c> occurs more - than once in <c>Negations</c>, only the first occurrence is + than once in <c><anno>Negations</anno></c>, only the first occurrence is used.</p> <p>Example: <c>substitute_negations([{no_foo, foo}], L)</c> will replace any atom <c>no_foo</c> or tuple @@ -374,13 +297,10 @@ </desc> </func> <func> - <name>unfold(List) -> List</name> + <name name="unfold" arity="1"/> <fsummary></fsummary> - <type> - <v>List = [term()]</v> - </type> <desc> - <p>Unfolds all occurrences of atoms in <c>List</c> to tuples + <p>Unfolds all occurrences of atoms in <c><anno>List</anno></c> to tuples <c>{Atom, true}</c>.</p> </desc> </func> diff --git a/lib/stdlib/doc/src/qlc.xml b/lib/stdlib/doc/src/qlc.xml index da24ee9914..ce50631ca9 100644 --- a/lib/stdlib/doc/src/qlc.xml +++ b/lib/stdlib/doc/src/qlc.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>2004</year><year>2009</year> + <year>2004</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -45,7 +45,9 @@ tables</em>. Typical QLC tables are ETS, Dets, and Mnesia tables. There is also support for user defined tables, see the <seealso marker="#implementing_a_qlc_table">Implementing a QLC - table</seealso> section. A <em>query</em> is stated using + table</seealso> section. <marker + id="query_list_comprehension"></marker> + A <em>query</em> is stated using <em>Query List Comprehensions</em> (QLCs). The answers to a query are determined by data in QLC tables that fulfill the constraints expressed by the QLCs of the query. QLCs are similar @@ -55,10 +57,11 @@ fact, in the absence of optimizations and options such as <c>cache</c> and <c>unique</c> (see below), every QLC free of QLC tables evaluates to the same list of answers as the - identical ordinary list comprehension. </p> + identical ordinary list comprehension.</p> <p>While ordinary list comprehensions evaluate to lists, calling - <seealso marker="#q">qlc:q/1,2</seealso> returns a <em>Query + <seealso marker="#q">qlc:q/1,2</seealso> returns a <marker + id="query_handle"></marker><em> Query Handle</em>. To obtain all the answers to a query, <seealso marker="#eval">qlc:eval/1,2</seealso> should be called with the query handle as first argument. Query handles are essentially @@ -69,7 +72,8 @@ Code replacement is described in the <seealso marker="doc/reference_manual:code_loading">Erlang Reference Manual</seealso>. The list of answers can also be traversed in - chunks by use of a <em>Query Cursor</em>. Query cursors are + chunks by use of a <marker + id="query_cursor"></marker><em>Query Cursor</em>. Query cursors are created by calling <seealso marker="#cursor">qlc:cursor/1,2</seealso> with a query handle as first argument. Query cursors are essentially Erlang processes. @@ -226,75 +230,6 @@ </section> - <section><title>Common data types</title> - - <list type="bulleted"> - <item><p><c>QueryCursor = {qlc_cursor, term()}</c></p> - </item> - <item><p><c>QueryHandle = {qlc_handle, term()}</c></p> - </item> - <item><p><c>QueryHandleOrList = QueryHandle | list()</c></p> - </item> - <item><p><c>Answers = [Answer]</c></p> - </item> - <item><p><c>Answer = term()</c></p> - </item> - <item><p><c>AbstractExpression = </c> - parse trees - for Erlang expressions, see the <seealso - marker="erts:absform">abstract format</seealso> - documentation in the ERTS User's Guide -</p> - </item> - <item><p><c>MatchExpression = </c> - - match specifications, see the <seealso - marker="erts:match_spec">match specification</seealso> - documentation in the ERTS User's Guide and <seealso - marker="ms_transform">ms_transform(3)</seealso> -</p> - </item> - <item><p><c>SpawnOptions = default | spawn_options()</c></p> - </item> - <item><p><c>SortOptions = [SortOption] | SortOption</c></p> - </item> - <item><p><c>SortOption = {compressed, bool()} - | {no_files, NoFiles} - | {order, Order} - | {size, Size} - | {tmpdir, TempDirectory} - | {unique, bool()} </c> - - see <seealso - marker="file_sorter">file_sorter(3)</seealso> -</p> - </item> - <item><p><c>Order = ascending | descending | OrderFun</c></p> - </item> - <item><p><c>OrderFun = fun(term(), term()) -> bool()</c></p> - </item> - <item><p><c>TempDirectory = "" | filename()</c></p> - </item> - <item><p><c>Size = int() > 0</c></p> - </item> - <item><p><c>NoFiles = int() > 1</c></p> - </item> - <item><p><c>KeyPos = int() > 0 | [int() > 0]</c></p> - </item> - <item><p><c>MaxListSize = int() >= 0</c></p> - </item> - <item><p><c>bool() = true | false</c></p> - </item> - <item><p><c>Cache = ets | list | no</c></p> - </item> - <item><p><c>TmpFileUsage = allowed | not_allowed | info_msg - | warning_msg | error_msg</c></p> - </item> - <item><p><c>filename() = </c> - see <seealso - marker="filename">filename(3)</seealso> -</p> - </item> - <item><p><c>spawn_options() = </c> - see <seealso - marker="erts:erlang">erlang(3)</seealso> -</p> - </item> - - </list> - - </section> - <section><title>Getting started</title> <p><marker id="getting_started"></marker> As already mentioned @@ -679,34 +614,104 @@ ets:match_spec_run(ets:lookup(86033, {2,2}), </section> + <datatypes> + <datatype> + <name name="abstract_expr"></name> + <desc><p>Parse trees for Erlang expression, see the <seealso + marker="erts:absform">abstract format</seealso> + documentation in the ERTS User's Guide.</p></desc> + </datatype> + <datatype> + <name name="answer"></name> + </datatype> + <datatype> + <name name="answers"></name> + </datatype> + <datatype> + <name name="cache"></name> + </datatype> + <datatype> + <name name="match_expression"></name> + <desc><p>Match specification, see the <seealso + marker="erts:match_spec">match specification</seealso> + documentation in the ERTS User's Guide and <seealso + marker="ms_transform">ms_transform(3).</seealso></p></desc> + </datatype> + <datatype> + <name name="no_files"></name> + <desc><p>Actually an integer > 1.</p></desc> + </datatype> + <datatype> + <name name="key_pos"></name> + </datatype> + <datatype> + <name name="max_list_size"></name> + </datatype> + <datatype> + <name name="order"></name> + </datatype> + <datatype> + <name name="order_fun"></name> + </datatype> + <datatype> + <name name="query_cursor"></name> + <desc><p>A <seealso marker="#query_cursor">query cursor</seealso>.</p> + </desc> + </datatype> + <datatype> + <name name="query_handle"></name> + <desc><p>A <seealso marker="#query_handle">query handle</seealso>.</p> + </desc> + </datatype> + <datatype> + <name name="query_handle_or_list"></name> + </datatype> + <datatype> + <name name="query_list_comprehension"></name> + <desc><p>A literal + <seealso marker="#query_list_comprehension">query + list comprehension</seealso>.</p></desc> + </datatype> + <datatype> + <name name="spawn_options"></name> + </datatype> + <datatype> + <name name="sort_options"></name> + </datatype> + <datatype> + <name name="sort_option"></name> + <desc><p>See <seealso + marker="file_sorter">file_sorter(3)</seealso>.</p></desc> + </datatype> + <datatype> + <name name="tmp_directory"></name> + </datatype> + <datatype> + <name name="tmp_file_usage"></name> + </datatype> + </datatypes> + <funcs> <func> - <name>append(QHL) -> QH</name> + <name name="append" arity="1"/> <fsummary>Return a query handle.</fsummary> - <type> - <v>QHL = [QueryHandleOrList]</v> - <v>QH = QueryHandle</v> - </type> <desc> <p>Returns a query handle. When evaluating the query handle - <c>QH</c> all answers to the first query handle in - <c>QHL</c> is returned followed by all answers to the rest - of the query handles in <c>QHL</c>.</p> + <c><anno>QH</anno></c> all answers to the first query handle in + <c><anno>QHL</anno></c> are returned followed by all answers + to the rest of the query handles in <c><anno>QHL</anno></c>.</p> </desc> </func> <func> - <name>append(QH1, QH2) -> QH3</name> + <name name="append" arity="2"/> <fsummary>Return a query handle.</fsummary> - <type> - <v>QH1 = QH2 = QueryHandleOrList</v> - <v>QH3 = QueryHandle</v> - </type> <desc> <p>Returns a query handle. When evaluating the query handle - <c>QH3</c> all answers to <c>QH1</c> are returned followed - by all answers to <c>QH2</c>.</p> + <c><anno>QH3</anno></c> all answers to + <c><anno>QH1</anno></c> are returned followed by all answers + to <c><anno>QH2</anno></c>.</p> <p><c>append(QH1, QH2)</c> is equivalent to <c>append([QH1, QH2])</c>.</p> @@ -714,17 +719,9 @@ ets:match_spec_run(ets:lookup(86033, {2,2}), </func> <func> - <name>cursor(QueryHandleOrList [, Options]) -> QueryCursor</name> + <name name="cursor" arity="1"/> + <name name="cursor" arity="2"/> <fsummary>Create a query cursor.</fsummary> - <type> - <v>Options = [Option] | Option</v> - <v>Option = {cache_all, Cache} | cache_all - | {max_list_size, MaxListSize} - | {spawn_options, SpawnOptions} - | {tmpdir_usage, TmpFileUsage} - | {tmpdir, TempDirectory} - | {unique_all, bool()} | unique_all</v> - </type> <desc> <p><marker id="cursor"></marker>Creates a query cursor and makes the calling process the owner of the cursor. The @@ -746,11 +743,13 @@ ets:match_spec_run(ets:lookup(86033, {2,2}), [{b,1},{b,2}] 4> <input>qlc:delete_cursor(QC).</input> ok</pre> + <p><c>cursor(<anno>QH</anno>)</c> is equivalent to + <c>cursor(<anno>QH</anno>, [])</c>.</p> </desc> </func> <func> - <name>delete_cursor(QueryCursor) -> ok</name> + <name name="delete_cursor" arity="1"/> <fsummary>Delete a query cursor.</fsummary> <desc> <p>Deletes a query cursor. Only the owner of the cursor can @@ -759,19 +758,11 @@ ok</pre> </func> <func> - <name>eval(QueryHandleOrList [, Options]) -> Answers | Error</name> - <name>e(QueryHandleOrList [, Options]) -> Answers</name> + <name name="eval" arity="1"/> + <name name="eval" arity="2"/> + <name name="e" arity="1"/> + <name name="e" arity="2"/> <fsummary>Return all answers to a query.</fsummary> - <type> - <v>Options = [Option] | Option</v> - <v>Option = {cache_all, Cache} | cache_all - | {max_list_size, MaxListSize} - | {tmpdir_usage, TmpFileUsage} - | {tmpdir, TempDirectory} - | {unique_all, bool()} | unique_all</v> - <v>Error = {error, module(), Reason}</v> - <v>Reason = - as returned by file_sorter(3) -</v> - </type> <desc> <p><marker id="eval"></marker>Evaluates a query handle in the calling process and collects all answers in a list.</p> @@ -780,47 +771,39 @@ ok</pre> 1> <input>QH = qlc:q([{X,Y} || X <- [a,b], Y <- [1,2]]),</input> <input>qlc:eval(QH).</input> [{a,1},{a,2},{b,1},{b,2}]</pre> + <p><c>eval(<anno>QH</anno>)</c> is equivalent to + <c>eval(<anno>QH</anno>, [])</c>.</p> </desc> </func> <func> - <name>fold(Function, Acc0, QueryHandleOrList [, Options]) -> - Acc1 | Error</name> + <name name="fold" arity="3"/> + <name name="fold" arity="4"/> <fsummary>Fold a function over the answers to a query.</fsummary> - <type> - <v>Function = fun(Answer, AccIn) -> AccOut</v> - <v>Acc0 = Acc1 = AccIn = AccOut = term()</v> - <v>Options = [Option] | Option</v> - <v>Option = {cache_all, Cache} | cache_all - | {max_list_size, MaxListSize} - | {tmpdir_usage, TmpFileUsage} - | {tmpdir, TempDirectory} - | {unique_all, bool()} | unique_all</v> - <v>Error = {error, module(), Reason}</v> - <v>Reason = - as returned by file_sorter(3) -</v> - </type> <desc> - <p>Calls <c>Function</c> on successive answers to the query - handle together with an extra argument <c>AccIn</c>. The - query handle and the function are evaluated in the calling - process. <c>Function</c> must return a new accumulator which - is passed to the next call. <c>Acc0</c> is returned if there - are no answers to the query handle.</p> + <p>Calls <c><anno>Function</anno></c> on successive answers to + the query handle together with an extra argument + <c><anno>AccIn</anno></c>. The query handle and the function + are evaluated in the calling process. + <c><anno>Function</anno></c> must return a new accumulator + which is passed to the next call. + <c><anno>Acc0</anno></c> is returned if there are no answers + to the query handle.</p> <pre> 1> <input>QH = [1,2,3,4,5,6],</input> <input>qlc:fold(fun(X, Sum) -> X + Sum end, 0, QH).</input> 21</pre> + <p><c>fold(<anno>Function</anno>, <anno>Acc0</anno>, + <anno>QH</anno>)</c> is equivalent to + <c>fold(<anno>Function</anno>, <anno>Acc0</anno>, + <anno>QH</anno>, [])</c>.</p> </desc> </func> <func> - <name>format_error(Error) -> Chars</name> + <name name="format_error" arity="1"/> <fsummary>Return an English description of a an error tuple.</fsummary> - <type> - <v>Error = {error, module(), term()}</v> - <v>Chars = [char() | Chars]</v> - </type> <desc> <p>Returns a descriptive string in English of an error tuple returned by some of the functions of the <c>qlc</c> module @@ -830,25 +813,9 @@ ok</pre> </func> <func> - <name>info(QueryHandleOrList [, Options]) -> Info</name> + <name name="info" arity="1"/> + <name name="info" arity="2"/> <fsummary>Return code describing a query handle.</fsummary> - <type> - <v>Options = [Option] | Option</v> - <v>Option = EvalOption | ReturnOption</v> - <v>EvalOption = {cache_all, Cache} | cache_all - | {max_list_size, MaxListSize} - | {tmpdir_usage, TmpFileUsage} - | {tmpdir, TempDirectory} - | {unique_all, bool()} | unique_all</v> - <v>ReturnOption = {depth, Depth} - | {flat, bool()} - | {format, Format} - | {n_elements, NElements}</v> - <v>Depth = infinity | int() >= 0</v> - <v>Format = abstract_code | string</v> - <v>NElements = infinity | int() > 0</v> - <v>Info = AbstractExpression | string()</v> - </type> <desc> <p><marker id="info"></marker>Returns information about a query handle. The information describes the simplifications @@ -879,18 +846,18 @@ ok</pre> <input>io:format("~s~n", [qlc:info(QH, unique_all)]).</input> begin V1 = - qlc:q([ + qlc:q([ SQV || SQV <- [x,y] ], [{unique,true}]), V2 = - qlc:q([ + qlc:q([ SQV || SQV <- [a,b] ], [{unique,true}]), - qlc:q([ + qlc:q([ {X,Y} || X <- V1, Y <- V2 @@ -913,19 +880,19 @@ end</pre> <input>io:format("~s~n", [qlc:info(Q)]).</input> begin V1 = - qlc:q([ + qlc:q([ P0 || P0 = {W,Y} <- ets:table(17) ]), V2 = - qlc:q([ + qlc:q([ [G1|G2] || G2 <- V1, G1 <- ets:table(16), element(2, G1) =:= element(1, G2) ], [{join,lookup}]), - qlc:q([ + qlc:q([ {X,Z,W} || [{X,Z}|{W,Y}] <- V2 ]) @@ -936,44 +903,43 @@ end</pre> method chosen. A convention is used for lookup join: the first generator (<c>G2</c>) is the one traversed, the second one (<c>G1</c>) is the table where constants are looked up.</p> + + <p><c>info(<anno>QH</anno>)</c> is equivalent to + <c>info(<anno>QH</anno>, [])</c>.</p> </desc> </func> <func> - <name>keysort(KeyPos, QH1 [, SortOptions]) -> QH2</name> + <name name="keysort" arity="2"/> + <name name="keysort" arity="3"/> <fsummary>Return a query handle.</fsummary> - <type> - <v>QH1 = QueryHandleOrList</v> - <v>QH2 = QueryHandle</v> - </type> <desc> <p>Returns a query handle. When evaluating the query handle - <c>QH2</c> the answers to the query handle <c>QH1</c> are - sorted by <seealso + <c><anno>QH2</anno></c> the answers to the query handle + <c><anno>QH1</anno></c> are sorted by <seealso marker="file_sorter">file_sorter:keysort/4</seealso> according to the options.</p> - <p>The sorter will use temporary files only if <c>QH1</c> does - not evaluate to a list and the size of the binary - representation of the answers exceeds <c>Size</c> bytes, - where <c>Size</c> is the value of the <c>size</c> option.</p> + <p>The sorter will use temporary files only if + <c><anno>QH1</anno></c> does not evaluate to a list and the + size of the binary representation of the answers exceeds + <c>Size</c> bytes, where <c>Size</c> is the value of the + <c>size</c> option.</p> + + <p><c>keysort(<anno>KeyPos</anno>, <anno>QH1</anno>)</c> + is equivalent to + <c>keysort(<anno>KeyPos</anno>, <anno>QH1</anno>, [])</c>.</p> </desc> </func> <func> - <name>next_answers(QueryCursor [, NumberOfAnswers]) -> - Answers | Error</name> + <name name="next_answers" arity="1"/> + <name name="next_answers" arity="2"/> <fsummary>Return some or all answers to a query.</fsummary> - <type> - <v>NumberOfAnswers = all_remaining | int() > 0</v> - <v>Error = {error, module(), Reason}</v> - <v>Reason = - as returned by file_sorter(3) -</v> - </type> <desc> <p>Returns some or all of the remaining answers to a query - cursor. Only the owner of <c>Cursor</c> can retrieve - answers.</p> - + cursor. Only the owner of <c><anno>QueryCursor</anno></c> can + retrieve answers.</p> <p>The optional argument <c>NumberOfAnswers</c>determines the maximum number of answers returned. The default value is <c>10</c>. If less than the requested number of answers is @@ -983,21 +949,9 @@ end</pre> </func> <func> - <name>q(QueryListComprehension [, Options]) -> QueryHandle</name> + <name name="q" arity="1"/> + <name name="q" arity="2"/> <fsummary>Return a handle for a query list comprehension.</fsummary> - <type> - <v>QueryListComprehension = - - literal query listcomprehension -</v> - <v>Options = [Option] | Option</v> - <v>Option = {max_lookup, MaxLookup} - | {cache, Cache} | cache - | {join, Join} - | {lookup, Lookup} - | {unique, bool()} | unique</v> - <v>MaxLookup = int() >= 0 | infinity</v> - <v>Join = any | lookup | merge | nested_loop</v> - <v>Lookup = bool() | any</v> - </type> <desc> <p><marker id="q"></marker>Returns a query handle for a query list comprehension. The query list comprehension must be the @@ -1024,7 +978,7 @@ end</pre> <pre> ... -A = [X || {X} <- [{1},{2}]], +A = [X || {X} <- [{1},{2}]], QH = qlc:q(A), ...</pre> @@ -1034,6 +988,9 @@ QH = qlc:q(A), list comprehension"); the shell process stops with a <c>badarg</c> reason.</p> + <p><c>q(<anno>QLC</anno>)</c> is equivalent to + <c>q(<anno>QLC</anno>, [])</c>.</p> + <p>The <c>{cache, ets}</c> option can be used to cache the answers to a query list comprehension. The answers are stored in one ETS table for each cached query list @@ -1092,26 +1049,26 @@ QH = qlc:q(A), <input>io:format("~s~n", [qlc:info(Q)]).</input> begin V1 = - qlc:q([ + qlc:q([ P0 || P0 = {X,Z} <- qlc:keysort(1, [{a,1},{b,4},{c,6}], []) ]), V2 = - qlc:q([ + qlc:q([ P0 || P0 = {W,Y} <- qlc:keysort(2, [{2,a},{3,b},{4,c}], []) ]), V3 = - qlc:q([ + qlc:q([ [G1|G2] || G1 <- V1, G2 <- V2, element(1, G1) == element(2, G2) ], [{join,merge},{cache,list}]), - qlc:q([ + qlc:q([ {A,X,Z,W} || A <- [a,b,c], [{X,Z}|{W,Y}] <- V3, @@ -1170,7 +1127,7 @@ ets:match_spec_run( elements of the key {X, Y} are compared separately.</p> <p>The <c>{lookup, true}</c> option can be used to ensure - that the <c>qlc</c> module will look up constants in some + that the <c>qlc</c> module will look up constants in some QLC table. If there are more than one QLC table among the generators' list expressions, constants have to be looked up in at least one @@ -1190,7 +1147,7 @@ ets:match_spec_run( <c>{join, nested_loop}</c> invokes the method of matching every pair of objects from two handles. The last method is mostly very slow. The evaluation of the query - fails if the <c>qlc</c> module cannot carry out the chosen + fails if the <c>qlc</c> module cannot carry out the chosen join method. The default value is <c>any</c> which means that some fast join method will be used if possible.</p> @@ -1198,47 +1155,33 @@ ets:match_spec_run( </func> <func> - <name>sort(QH1 [, SortOptions]) -> QH2</name> + <name name="sort" arity="1"/> + <name name="sort" arity="2"/> <fsummary>Return a query handle.</fsummary> - <type> - <v>QH1 = QueryHandleOrList</v> - <v>QH2 = QueryHandle</v> - </type> <desc> <p>Returns a query handle. When evaluating the query handle - <c>QH2</c> the answers to the query handle <c>QH1</c> are - sorted by <seealso + <c><anno>QH2</anno></c> the answers to the query handle + <c><anno>QH1</anno></c> are sorted by <seealso marker="file_sorter">file_sorter:sort/3</seealso> according to the options.</p> - <p>The sorter will use temporary files only if <c>QH1</c> does - not evaluate to a list and the size of the binary - representation of the answers exceeds <c>Size</c> bytes, - where <c>Size</c> is the value of the <c>size</c> option.</p> + <p>The sorter will use temporary files only if + <c><anno>QH1</anno></c> does not evaluate to a list and the + size of the binary representation of the answers exceeds + <c>Size</c> bytes, where <c>Size</c> is the value of the + <c>size</c> option.</p> + + <p><c>sort(<anno>QH1</anno>)</c> is equivalent to + <c>sort(<anno>QH1</anno>, [])</c>.</p> + </desc> </func> <func> - <name>string_to_handle(QueryString [, Options [, Bindings]]) -> - QueryHandle | Error</name> + <name name="string_to_handle" arity="1"/> + <name name="string_to_handle" arity="2"/> + <name name="string_to_handle" arity="3"/> <fsummary>Return a handle for a query list comprehension.</fsummary> - <type> - <v>QueryString = string()</v> - <v>Options = [Option] | Option</v> - <v>Option = {max_lookup, MaxLookup} - | {cache, Cache} | cache - | {join, Join} - | {lookup, Lookup} - | {unique, bool()} | unique</v> - <v>MaxLookup = int() >= 0 | infinity</v> - <v>Join = any | lookup | merge | nested_loop</v> - <v>Lookup = bool() | any</v> - <v>Bindings = - as returned by - erl_eval:bindings/1 -</v> - <v>Error = {error, module(), Reason}</v> - <v>Reason = - ErrorInfo as returned by - erl_scan:string/1 or erl_parse:parse_exprs/1 -</v> - </type> <desc> <p>A string version of <c>qlc:q/1,2</c>. When the query handle is evaluated the fun created by the parse transform is @@ -1253,57 +1196,24 @@ ets:match_spec_run( <input>qlc:eval(QH).</input> [2,3,4]</pre> + <p><c>string_to_handle(<anno>QueryString</anno>)</c> + is equivalent to + <c>string_to_handle(<anno>QueryString</anno>, [])</c>.</p> + + <p><c>string_to_handle(<anno>QueryString</anno>, + <anno>Options</anno>)</c> + is equivalent to + <c>string_to_handle(<anno>QueryString</anno>, + <anno>Options</anno>, erl_eval:new_bindings())</c>.</p> + <p>This function is probably useful mostly when called from outside of Erlang, for instance from a driver written in C.</p> </desc> </func> <func> - <name>table(TraverseFun, Options) -> QueryHandle</name> + <name name="table" arity="2"/> <fsummary>Return a query handle for a table.</fsummary> - <type> - <v>TraverseFun = TraverseFun0 | TraverseFun1</v> - <v>TraverseFun0 = fun() -> TraverseResult</v> - <v>TraverseFun1 = fun(MatchExpression) -> TraverseResult</v> - <v>TraverseResult = Objects | term()</v> - <v>Objects = [] | [term() | ObjectList]</v> - <v>ObjectList = TraverseFun0 | Objects</v> - <v>Options = [Option] | Option</v> - <v>Option = {format_fun, FormatFun} - | {info_fun, InfoFun} - | {lookup_fun, LookupFun} - | {parent_fun, ParentFun} - | {post_fun, PostFun} - | {pre_fun, PreFun} - | {key_equality, KeyComparison}</v> - <v>FormatFun = undefined | fun(SelectedObjects) -> FormatedTable</v> - <v>SelectedObjects = all - | {all, NElements, DepthFun} - | {match_spec, MatchExpression} - | {lookup, Position, Keys} - | {lookup, Position, Keys, NElements, DepthFun}</v> - <v>NElements = infinity | int() > 0</v> - <v>DepthFun = fun(term()) -> term()</v> - <v>FormatedTable = {Mod, Fun, Args} - | AbstractExpression - | character_list()</v> - <v>InfoFun = undefined | fun(InfoTag) -> InfoValue</v> - <v>InfoTag = indices | is_unique_objects | keypos | num_of_objects</v> - <v>InfoValue = undefined | term()</v> - <v>LookupFun = undefined | fun(Position, Keys) -> LookupResult</v> - <v>LookupResult = [term()] | term()</v> - <v>ParentFun = undefined | fun() -> ParentFunValue</v> - <v>PostFun = undefined | fun() -> void()</v> - <v>PreFun = undefined | fun([PreArg]) -> void()</v> - <v>PreArg = {parent_value, ParentFunValue} | {stop_fun, StopFun}</v> - <v>ParentFunValue = undefined | term()</v> - <v>StopFun = undefined | fun() -> void()</v> - <v>KeyComparison = '=:=' | '=='</v> - <v>Position = int() > 0</v> - <v>Keys = [term()]</v> - <v>Mod = Fun = atom()</v> - <v>Args = [term()]</v> - </type> <desc> <p><marker id="table"></marker>Returns a query handle for a QLC table. In Erlang/OTP there is support for ETS, Dets and @@ -1315,77 +1225,90 @@ ets:match_spec_run( as well as properties of the table are handled by callback functions provided as options to <c>qlc:table/2</c>.</p> - <p>The callback function <c>TraverseFun</c> is used for - traversing the table. It is to return a list of objects - terminated by either <c>[]</c> or a nullary fun to be used - for traversing the not yet traversed objects of the table. - Any other return value is immediately returned as value of - the query evaluation. Unary <c>TraverseFun</c>s are to - accept a match specification as argument. The match - specification is created by the parse transform by analyzing - the pattern of the generator calling <c>qlc:table/2</c> and - filters using variables introduced in the pattern. If the - parse transform cannot find a match specification equivalent - to the pattern and filters, <c>TraverseFun</c> will be - called with a match specification returning every object. - Modules that can utilize match specifications for optimized + <p>The callback function <c><anno>TraverseFun</anno></c> is + used for traversing the table. It is to return a list of + objects terminated by either <c>[]</c> or a nullary fun to + be used for traversing the not yet traversed objects of the + table. Any other return value is immediately returned as + value of the query evaluation. Unary + <c><anno>TraverseFun</anno></c>s are to accept a match + specification as argument. The match specification is + created by the parse transform by analyzing the pattern of + the generator calling <c>qlc:table/2</c> and filters using + variables introduced in the pattern. If the parse transform + cannot find a match specification equivalent to the pattern + and filters, <c><anno>TraverseFun</anno></c> will be called + with a match specification returning every object. Modules + that can utilize match specifications for optimized traversal of tables should call <c>qlc:table/2</c> with a - unary <c>TraverseFun</c> while other modules can provide a - nullary <c>TraverseFun</c>. <c>ets:table/2</c> is an example - of the former; <c>gb_table:table/1</c> in the <seealso - marker="#implementing_a_qlc_table">Implementing a QLC - table</seealso> section is an example of the latter.</p> - - <p><c>PreFun</c> is a unary callback function that is called - once before the table is read for the first time. If the - call fails, the query evaluation fails. Similarly, the - nullary callback function <c>PostFun</c> is called once - after the table was last read. The return value, which is - caught, is ignored. If <c>PreFun</c> has been called for a - table, <c>PostFun</c> is guaranteed to be called for that - table, even if the evaluation of the query fails for some - reason. The order in which pre (post) functions for + unary + <c><anno>TraverseFun</anno></c> while other modules can + provide a nullary + <c><anno>TraverseFun</anno></c>. <c>ets:table/2</c> is an + example of the former; <c>gb_table:table/1</c> in the + <seealso marker="#implementing_a_qlc_table">Implementing a + QLC table</seealso> section is an example of the latter.</p> + + <p><c><anno>PreFun</anno></c> is a unary callback function + that is called once before the table is read for the first + time. If the call fails, the query evaluation fails. + Similarly, the nullary callback function + <c><anno>PostFun</anno></c> is called once after the table + was last read. The return value, which is caught, is + ignored. If <c><anno>PreFun</anno></c> has been called for a + table, + <c><anno>PostFun</anno></c> is guaranteed to be called for + that table, even if the evaluation of the query fails for + some reason. The order in which pre (post) functions for different tables are evaluated is not specified. Other table - access than reading, such as calling <c>InfoFun</c>, is - assumed to be OK at any time. The argument <c>PreArgs</c> is - a list of tagged values. Currently there are two tags, + access than reading, such as calling + <c><anno>InfoFun</anno></c>, is assumed to be OK at any + time. The argument <c><anno>PreArgs</anno></c> is a list of + tagged values. Currently there are two tags, <c>parent_value</c> and <c>stop_fun</c>, used by Mnesia for managing transactions. The value of <c>parent_value</c> is - the value returned by <c>ParentFun</c>, or <c>undefined</c> - if there is no <c>ParentFun</c>. <c>ParentFun</c> is called - once just before the call of <c>PreFun</c> in the context of - the process calling <c>eval</c>, <c>fold</c>, or + the value returned by <c><anno>ParentFun</anno></c>, or + <c>undefined</c> if there is no <c>ParentFun</c>. + <c><anno>ParentFun</anno></c> is called once just before the + call of + <c><anno>PreFun</anno></c> in the context of the process + calling + <c>eval</c>, <c>fold</c>, or <c>cursor</c>. The value of <c>stop_fun</c> is a nullary fun that deletes the cursor if called from the parent, or <c>undefined</c> if there is no cursor.</p> <p><marker id="lookup_fun"></marker>The binary callback - function <c>LookupFun</c> is used for looking up objects in - the table. The first argument <c>Position</c> is the key - position or an indexed position and the second argument - <c>Keys</c> is a sorted list of unique values. The return - value is to be a list of all objects (tuples) such that the - element at <c>Position</c> is a member of <c>Keys</c>. Any - other return value is immediately returned as value of the - query evaluation. <c>LookupFun</c> is called instead of + function <c><anno>LookupFun</anno></c> is used for looking + up objects in the table. The first argument + <c><anno>Position</anno></c> is the key position or an + indexed position and the second argument + <c><anno>Keys</anno></c> is a sorted list of unique values. + The return value is to be a list of all objects (tuples) + such that the element at <c>Position</c> is a member of + <c><anno>Keys</anno></c>. Any other return value is + immediately returned as value of the query evaluation. + <c><anno>LookupFun</anno></c> is called instead of traversing the table if the parse transform at compile time can find out that the filters match and compare the element - at <c>Position</c> in such a way that only <c>Keys</c> need - to be looked up in order to find all potential answers. The - key position is obtained by calling <c>InfoFun(keypos)</c> - and the indexed positions by calling - <c>InfoFun(indices)</c>. If the key position can be used for - lookup it is always chosen, otherwise the indexed position - requiring the least number of lookups is chosen. If there is - a tie between two indexed positions the one occurring first - in the list returned by <c>InfoFun</c> is chosen. Positions - requiring more than <seealso - marker="#max_lookup">max_lookup</seealso> lookups are - ignored.</p> - - <p>The unary callback function <c>InfoFun</c> is to return - information about the table. <c>undefined</c> should be - returned if the value of some tag is unknown:</p> + at <c><anno>Position</anno></c> in such a way that only + <c><anno>Keys</anno></c> need to be looked up in order to + find all potential answers. The key position is obtained by + calling + <c><anno>InfoFun</anno>(keypos)</c> and the indexed + positions by calling + <c><anno>InfoFun</anno>(indices)</c>. If the key position + can be used for lookup it is always chosen, otherwise the + indexed position requiring the least number of lookups is + chosen. If there is a tie between two indexed positions the + one occurring first in the list returned by + <c><anno>InfoFun</anno></c> is chosen. Positions requiring + more than <seealso marker="#max_lookup">max_lookup</seealso> + lookups are ignored.</p> + + <p>The unary callback function <c><anno>InfoFun</anno></c> is + to return information about the table. <c>undefined</c> + should be returned if the value of some tag is unknown:</p> <list type="bulleted"> <item><c>indices</c>. Returns a list of indexed @@ -1406,20 +1329,22 @@ ets:match_spec_run( </item> </list> - <p>The unary callback function <c>FormatFun</c> is used by - <seealso marker="#info">qlc:info/1,2</seealso> for - displaying the call that created the table's query handle. - The default value, <c>undefined</c>, means that + <p>The unary callback function <c><anno>FormatFun</anno></c> + is used by <seealso marker="#info">qlc:info/1,2</seealso> + for displaying the call that created the table's query + handle. The default value, <c>undefined</c>, means that <c>info/1,2</c> displays a call to <c>'$MOD':'$FUN'/0</c>. - It is up to <c>FormatFun</c> to present the selected objects - of the table in a suitable way. However, if a character list - is chosen for presentation it must be an Erlang expression - that can be scanned and parsed (a trailing dot will be added - by <c>qlc:info</c> though). <c>FormatFun</c> is called with - an argument that describes the selected objects based on - optimizations done as a result of analyzing the filters of - the QLC where the call to <c>qlc:table/2</c> occurs. The - possible values of the argument are:</p> + It is up to <c><anno>FormatFun</anno></c> to present the + selected objects of the table in a suitable way. However, if + a character list is chosen for presentation it must be an + Erlang expression that can be scanned and parsed (a trailing + dot will be added by <c>qlc:info</c> though). + <c><anno>FormatFun</anno></c> is called with an argument + that describes the selected objects based on optimizations + done as a result of analyzing the filters of the QLC where + the call to + <c>qlc:table/2</c> occurs. The possible values of the + argument are:</p> <list type="bulleted"> <item><c>{lookup, Position, Keys, NElements, DepthFun}</c>. @@ -1443,10 +1368,12 @@ ets:match_spec_run( can be used for limiting the size of terms; calling <c>DepthFun(Term)</c> substitutes <c>'...'</c> for parts of <c>Term</c> below the depth specified by the <c>info/1,2</c> - option <c>depth</c>. If calling <c>FormatFun</c> with an - argument including <c>NElements</c> and <c>DepthFun</c> - fails, <c>FormatFun</c> is called once again with an - argument excluding <c>NElements</c> and <c>DepthFun</c> + option <c>depth</c>. If calling + <c><anno>FormatFun</anno></c> with an argument including + <c>NElements</c> and <c>DepthFun</c> fails, + <c><anno>FormatFun</anno></c> is called once again with an + argument excluding + <c>NElements</c> and <c>DepthFun</c> (<c>{lookup, Position, Keys}</c> or <c>all</c>).</p> @@ -1458,7 +1385,7 @@ ets:match_spec_run( <p>See <seealso marker="ets#qlc_table">ets(3)</seealso>, <seealso marker="dets#qlc_table">dets(3)</seealso> and - <seealso marker="mnesia:mnesia#qlc_table">mnesia(3)</seealso> + <seealso marker="mnesia:mnesia#qlc_table">mnesia(3)</seealso> for the various options recognized by <c>table/1,2</c> in respective module.</p> </desc> @@ -1472,12 +1399,12 @@ ets:match_spec_run( <seealso marker="doc/reference_manual:users_guide"> Erlang Reference Manual</seealso>, <seealso marker="erl_eval">erl_eval(3)</seealso>, - <seealso marker="erts:erlang">erlang(3)</seealso>, + <seealso marker="erts:erlang">erlang(3)</seealso>, <seealso marker="ets">ets(3)</seealso>, - <seealso marker="kernel:file">file(3)</seealso>, - <seealso marker="error_logger:file">error_logger(3)</seealso>, + <seealso marker="kernel:file">file(3)</seealso>, + <seealso marker="error_logger:file">error_logger(3)</seealso>, <seealso marker="file_sorter">file_sorter(3)</seealso>, - <seealso marker="mnesia:mnesia">mnesia(3)</seealso>, + <seealso marker="mnesia:mnesia">mnesia(3)</seealso>, <seealso marker="doc/programming_examples:users_guide"> Programming Examples</seealso>, <seealso marker="shell">shell(3)</seealso></p> diff --git a/lib/stdlib/doc/src/queue.xml b/lib/stdlib/doc/src/queue.xml index 5ada1c2c57..383f52d10d 100644 --- a/lib/stdlib/doc/src/queue.xml +++ b/lib/stdlib/doc/src/queue.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2009</year> + <year>1996</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -88,122 +88,94 @@ <title>Original API</title> </section> + <datatypes> + <datatype> + <name><marker id="type-queue">queue()</marker></name> + <desc><p>As returned by <c>new/0</c>.</p></desc> + </datatype> + </datatypes> + <funcs> <func> - <name>new() -> Q</name> + <name name="new" arity="0"/> <fsummary>Create an empty queue</fsummary> - <type> - <v>Q = queue()</v> - </type> <desc> <p>Returns an empty queue.</p> </desc> </func> <func> - <name>is_queue(Term) -> true | false</name> + <name name="is_queue" arity="1"/> <fsummary>Test if a term is a queue</fsummary> - <type> - <v>Term = term()</v> - </type> <desc> - <p>Tests if <c>Q</c> is a queue and returns <c>true</c> if so and + <p>Tests if <c><anno>Term</anno></c> is a queue and returns <c>true</c> if so and <c>false</c> otherwise.</p> </desc> </func> <func> - <name>is_empty(Q) -> true | false</name> + <name name="is_empty" arity="1"/> <fsummary>Test if a queue is empty</fsummary> - <type> - <v>Q = queue()</v> - </type> <desc> - <p>Tests if <c>Q</c> is empty and returns <c>true</c> if so and + <p>Tests if <c><anno>Q</anno></c> is empty and returns <c>true</c> if so and <c>false</c> otherwise.</p> </desc> </func> <func> - <name>len(Q) -> N</name> + <name name="len" arity="1"/> <fsummary>Get the length of a queue</fsummary> - <type> - <v>Q = queue()</v> - <v>N = integer()</v> - </type> <desc> - <p>Calculates and returns the length of queue <c>Q</c>.</p> + <p>Calculates and returns the length of queue <c><anno>Q</anno></c>.</p> </desc> </func> <func> - <name>in(Item, Q1) -> Q2</name> + <name name="in" arity="2"/> <fsummary>Insert an item at the rear of a queue</fsummary> - <type> - <v>Item = term()</v> - <v>Q1 = Q2 = queue()</v> - </type> <desc> - <p>Inserts <c>Item</c> at the rear of queue <c>Q1</c>. - Returns the resulting queue <c>Q2</c>.</p> + <p>Inserts <c><anno>Item</anno></c> at the rear of queue <c><anno>Q1</anno></c>. + Returns the resulting queue <c><anno>Q2</anno></c>.</p> </desc> </func> <func> - <name>in_r(Item, Q1) -> Q2</name> + <name name="in_r" arity="2"/> <fsummary>Insert an item at the front of a queue</fsummary> - <type> - <v>Item = term()</v> - <v>Q1 = Q2 = queue()</v> - </type> <desc> - <p>Inserts <c>Item</c> at the front of queue <c>Q1</c>. - Returns the resulting queue <c>Q2</c>.</p> + <p>Inserts <c><anno>Item</anno></c> at the front of queue <c><anno>Q1</anno></c>. + Returns the resulting queue <c><anno>Q2</anno></c>.</p> </desc> </func> <func> - <name>out(Q1) -> Result</name> + <name name="out" arity="1"/> <fsummary>Remove the front item from a queue</fsummary> - <type> - <v>Result = {{value, Item}, Q2} | {empty, Q1}</v> - <v>Q1 = Q2 = queue()</v> - </type> <desc> - <p>Removes the item at the front of queue <c>Q1</c>. Returns the - tuple <c>{{value, Item}, Q2}</c>, where <c>Item</c> is the - item removed and <c>Q2</c> is the resulting queue. If <c>Q1</c> is - empty, the tuple <c>{empty, Q1}</c> is returned.</p> + <p>Removes the item at the front of queue <c><anno>Q1</anno></c>. Returns the + tuple <c>{{value, <anno>Item</anno>}, <anno>Q2</anno>}</c>, where <c><anno>Item</anno></c> is the + item removed and <c><anno>Q2</anno></c> is the resulting queue. If <c><anno>Q1</anno></c> is + empty, the tuple <c>{empty, <anno>Q1</anno>}</c> is returned.</p> </desc> </func> <func> - <name>out_r(Q1) -> Result</name> + <name name="out_r" arity="1"/> <fsummary>Remove the rear item from a queue</fsummary> - <type> - <v>Result = {{value, Item}, Q2} | {empty, Q1}</v> - <v>Q1 = Q2 = queue()</v> - </type> <desc> - <p>Removes the item at the rear of the queue <c>Q1</c>. Returns the - tuple <c>{{value, Item}, Q2}</c>, where <c>Item</c> is the - item removed and <c>Q2</c> is the new queue. If <c>Q1</c> is - empty, the tuple <c>{empty, Q1}</c> is returned. </p> + <p>Removes the item at the rear of the queue <c><anno>Q1</anno></c>. Returns the + tuple <c>{{value, <anno>Item</anno>}, <anno>Q2</anno>}</c>, where <c><anno>Item</anno></c> is the + item removed and <c><anno>Q2</anno></c> is the new queue. If <c><anno>Q1</anno></c> is + empty, the tuple <c>{empty, <anno>Q1</anno>}</c> is returned. </p> </desc> </func> <func> - <name>from_list(L) -> queue()</name> + <name name="from_list" arity="1"/> <fsummary>Convert a list to a queue</fsummary> - <type> - <v>L = list()</v> - </type> <desc> - <p>Returns a queue containing the items in <c>L</c> in the + <p>Returns a queue containing the items in <c><anno>L</anno></c> in the same order; the head item of the list will become the front item of the queue.</p> </desc> </func> <func> - <name>to_list(Q) -> list()</name> + <name name="to_list" arity="1"/> <fsummary>Convert a queue to a list</fsummary> - <type> - <v>Q = queue()</v> - </type> <desc> <p>Returns a list of the items in the queue in the same order; the front item of the queue will become the head of the list.</p> @@ -211,57 +183,43 @@ </func> <func> - <name>reverse(Q1) -> Q2</name> + <name name="reverse" arity="1"/> <fsummary>Reverse a queue</fsummary> - <type> - <v>Q1 = Q2 = queue()</v> - </type> <desc> - <p>Returns a queue <c>Q2</c> that contains the items of - <c>Q1</c> in the reverse order.</p> + <p>Returns a queue <c><anno>Q2</anno></c> that contains the items of + <c><anno>Q1</anno></c> in the reverse order.</p> </desc> </func> <func> - <name>split(N, Q1) -> {Q2,Q3}</name> + <name name="split" arity="2"/> <fsummary>Split a queue in two</fsummary> - <type> - <v>N = integer()</v> - <v>Q1 = Q2 = Q3 = queue()</v> - </type> <desc> - <p>Splits <c>Q1</c> in two. The <c>N</c> front items - are put in <c>Q2</c> and the rest in <c>Q3</c></p> + <p>Splits <c><anno>Q1</anno></c> in two. The <c><anno>N</anno></c> front items + are put in <c><anno>Q2</anno></c> and the rest in <c><anno>Q3</anno></c></p> </desc> </func> <func> - <name>join(Q1, Q2) -> Q3</name> + <name name="join" arity="2"/> <fsummary>Join two queues</fsummary> - <type> - <v>Q1 = Q2 = Q3 = queue()</v> - </type> <desc> - <p>Returns a queue <c>Q3</c> that is the result of joining - <c>Q1</c> and <c>Q2</c> with <c>Q1</c> in front of - <c>Q2</c>.</p> + <p>Returns a queue <c><anno>Q3</anno></c> that is the result of joining + <c><anno>Q1</anno></c> and <c><anno>Q2</anno></c> with <c><anno>Q1</anno></c> in front of + <c><anno>Q2</anno></c>.</p> </desc> </func> <func> - <name>filter(Fun, Q1) -> Q2</name> + <name name="filter" arity="2"/> <fsummary>Filter a queue</fsummary> - <type> - <v>Fun = fun(Item) -> bool() | list()</v> - <v>Q1 = Q2 = queue()</v> - </type> <desc> - <p>Returns a queue <c>Q2</c> that is the result of calling - <c>Fun(Item)</c> on all items in <c>Q1</c>, + <p>Returns a queue <c><anno>Q2</anno></c> that is the result of calling + <c><anno>Fun</anno>(<anno>Item</anno>)</c> on all items in <c><anno>Q1</anno></c>, in order from front to rear.</p> - <p>If <c>Fun(Item)</c> returns <c>true</c>, <c>Item</c> + <p>If <c><anno>Fun</anno>(<anno>Item</anno>)</c> returns <c>true</c>, <c>Item</c> is copied to the result queue. If it returns <c>false</c>, - <c>Item</c> is not copied. If it returns a list + <c><anno>Item</anno></c> is not copied. If it returns a list the list elements are inserted instead of <c>Item</c> in the result queue.</p> - <p>So, <c>Fun(Item)</c> returning <c>[Item]</c> is thereby + <p>So, <c><anno>Fun</anno>(<anno>Item</anno>)</c> returning <c>[<anno>Item</anno>]</c> is thereby semantically equivalent to returning <c>true</c>, just as returning <c>[]</c> is semantically equivalent to returning <c>false</c>. But returning a list builds @@ -269,15 +227,11 @@ </desc> </func> <func> - <name>member(Item, Q) -> bool()</name> + <name name="member" arity="2"/> <fsummary>Test if an item is in a queue</fsummary> - <type> - <v>Item = term()</v> - <v>Q = queue()</v> - </type> <desc> - <p>Returns <c>true</c> if <c>Item</c> matches some element - in <c>Q</c>, otherwise <c>false</c>.</p> + <p>Returns <c>true</c> if <c><anno>Item</anno></c> matches some element + in <c><anno>Q</anno></c>, otherwise <c>false</c>.</p> </desc> </func> </funcs> @@ -290,77 +244,53 @@ <funcs> <func> - <name>get(Q) -> Item</name> + <name name="get" arity="1"/> <fsummary>Return the front item of a queue</fsummary> - <type> - <v>Item = term()</v> - <v>Q = queue()</v> - </type> <desc> - <p>Returns <c>Item</c> at the front of queue <c>Q</c>.</p> - <p>Fails with reason <c>empty</c> if <c>Q</c> is empty.</p> + <p>Returns <c><anno>Item</anno></c> at the front of queue <c><anno>Q</anno></c>.</p> + <p>Fails with reason <c>empty</c> if <c><anno>Q</anno></c> is empty.</p> </desc> </func> <func> - <name>get_r(Q) -> Item</name> + <name name="get_r" arity="1"/> <fsummary>Return the rear item of a queue</fsummary> - <type> - <v>Item = term()</v> - <v>Q = queue()</v> - </type> <desc> - <p>Returns <c>Item</c> at the rear of queue <c>Q</c>.</p> - <p>Fails with reason <c>empty</c> if <c>Q</c> is empty.</p> + <p>Returns <c><anno>Item</anno></c> at the rear of queue <c><anno>Q</anno></c>.</p> + <p>Fails with reason <c>empty</c> if <c><anno>Q</anno></c> is empty.</p> </desc> </func> <func> - <name>drop(Q1) -> Q2</name> + <name name="drop" arity="1"/> <fsummary>Remove the front item from a queue</fsummary> - <type> - <v>Item = term()</v> - <v>Q1 = Q2 = queue()</v> - </type> <desc> - <p>Returns a queue <c>Q2</c> that is the result of removing - the front item from <c>Q1</c>.</p> - <p>Fails with reason <c>empty</c> if <c>Q1</c> is empty.</p> + <p>Returns a queue <c><anno>Q2</anno></c> that is the result of removing + the front item from <c><anno>Q1</anno></c>.</p> + <p>Fails with reason <c>empty</c> if <c><anno>Q1</anno></c> is empty.</p> </desc> </func> <func> - <name>drop_r(Q1) -> Q2</name> + <name name="drop_r" arity="1"/> <fsummary>Remove the rear item from a queue</fsummary> - <type> - <v>Item = term()</v> - <v>Q1 = Q2 = queue()</v> - </type> <desc> - <p>Returns a queue <c>Q2</c> that is the result of removing - the rear item from <c>Q1</c>.</p> - <p>Fails with reason <c>empty</c> if <c>Q1</c> is empty.</p> + <p>Returns a queue <c><anno>Q2</anno></c> that is the result of removing + the rear item from <c><anno>Q1</anno></c>.</p> + <p>Fails with reason <c>empty</c> if <c><anno>Q1</anno></c> is empty.</p> </desc> </func> <func> - <name>peek(Q) -> {value,Item} | empty</name> + <name name="peek" arity="1"/> <fsummary>Return the front item of a queue</fsummary> - <type> - <v>Item = term()</v> - <v>Q = queue()</v> - </type> <desc> - <p>Returns the tuple <c>{value, Item}</c> where <c>Item</c> is the - front item of <c>Q</c>, or <c>empty</c> if <c>Q1</c> is empty.</p> + <p>Returns the tuple <c>{value, <anno>Item</anno>}</c> where <c><anno>Item</anno></c> is the + front item of <c><anno>Q</anno></c>, or <c>empty</c> if <c><anno>Q</anno></c> is empty.</p> </desc> </func> <func> - <name>peek_r(Q) -> {value,Item} | empty</name> + <name name="peek_r" arity="1"/> <fsummary>Return the rear item of a queue</fsummary> - <type> - <v>Item = term()</v> - <v>Q = queue()</v> - </type> <desc> - <p>Returns the tuple <c>{value, Item}</c> where <c>Item</c> is the - rear item of <c>Q</c>, or <c>empty</c> if <c>Q1</c> is empty.</p> + <p>Returns the tuple <c>{value, <anno>Item</anno>}</c> where <c><anno>Item</anno></c> is the + rear item of <c><anno>Q</anno></c>, or <c>empty</c> if <c><anno>Q</anno></c> is empty.</p> </desc> </func> </funcs> @@ -372,80 +302,56 @@ <funcs> <func> - <name>cons(Item, Q1) -> Q2</name> + <name name="cons" arity="2"/> <fsummary>Insert an item at the head of a queue</fsummary> - <type> - <v>Item = term()</v> - <v>Q1 = Q2 = queue()</v> - </type> <desc> - <p>Inserts <c>Item</c> at the head of queue <c>Q1</c>. Returns - the new queue <c>Q2</c>.</p> + <p>Inserts <c><anno>Item</anno></c> at the head of queue <c><anno>Q1</anno></c>. Returns + the new queue <c><anno>Q2</anno></c>.</p> </desc> </func> <func> - <name>head(Q) -> Item</name> + <name name="head" arity="1"/> <fsummary>Return the item at the head of a queue</fsummary> - <type> - <v>Item = term()</v> - <v>Q = queue()</v> - </type> <desc> - <p>Returns <c>Item</c> from the head of queue <c>Q</c>.</p> - <p>Fails with reason <c>empty</c> if <c>Q</c> is empty.</p> + <p>Returns <c><anno>Item</anno></c> from the head of queue <c><anno>Q</anno></c>.</p> + <p>Fails with reason <c>empty</c> if <c><anno>Q</anno></c> is empty.</p> </desc> </func> <func> - <name>tail(Q1) -> Q2</name> + <name name="tail" arity="1"/> <fsummary>Remove the head item from a queue</fsummary> - <type> - <v>Item = term()</v> - <v>Q1 = Q2 = queue()</v> - </type> <desc> - <p>Returns a queue <c>Q2</c> that is the result of removing - the head item from <c>Q1</c>.</p> - <p>Fails with reason <c>empty</c> if <c>Q1</c> is empty.</p> + <p>Returns a queue <c><anno>Q2</anno></c> that is the result of removing + the head item from <c><anno>Q1</anno></c>.</p> + <p>Fails with reason <c>empty</c> if <c><anno>Q1</anno></c> is empty.</p> </desc> </func> <func> - <name>snoc(Q1, Item) -> Q2</name> + <name name="snoc" arity="2"/> <fsummary>Insert an item at the tail of a queue</fsummary> - <type> - <v>Item = term()</v> - <v>Q1 = Q2 = queue()</v> - </type> <desc> - <p>Inserts <c>Item</c> as the tail item of queue <c>Q1</c>. Returns - the new queue <c>Q2</c>.</p> + <p>Inserts <c><anno>Item</anno></c> as the tail item of queue <c><anno>Q1</anno></c>. Returns + the new queue <c><anno>Q2</anno></c>.</p> </desc> </func> <func> - <name>daeh(Q) -> Item</name> - <name>last(Q) -> Item</name> + <name name="daeh" arity="1"/> + <name name="last" arity="1"/> <fsummary>Return the tail item of a queue</fsummary> - <type> - <v>Item = term()</v> - <v>Q = queue()</v> - </type> <desc> - <p>Returns the tail item of queue <c>Q</c>.</p> - <p>Fails with reason <c>empty</c> if <c>Q</c> is empty.</p> + <p>Returns the tail item of queue <c><anno>Q</anno></c>.</p> + <p>Fails with reason <c>empty</c> if <c><anno>Q</anno></c> is empty.</p> </desc> </func> <func> - <name>liat(Q1) -> Q2</name> - <name>init(Q1) -> Q2</name> - <name>lait(Q1) -> Q2</name> + <name name="liat" arity="1"/> + <name name="init" arity="1"/> + <name name="lait" arity="1"/> <fsummary>Remove the tail item from a queue</fsummary> - <type> - <v>Item = term()</v> - <v>Q1 = Q2 = queue()</v> - </type> <desc> - <p>Returns a queue <c>Q2</c> that is the result of removing - the tail item from <c>Q1</c>.</p> - <p>Fails with reason <c>empty</c> if <c>Q1</c> is empty.</p> + <p>Returns a queue <c><anno>Q2</anno></c> that is the result of removing + the tail item from <c><anno>Q1</anno></c>.</p> + <p>Fails with reason <c>empty</c> if <c><anno>Q1</anno></c> is empty.</p> <p>The name <c>lait/1</c> is a misspelling - do not use it anymore.</p> </desc> </func> diff --git a/lib/stdlib/doc/src/random.xml b/lib/stdlib/doc/src/random.xml index dcc6d756e1..93affc3191 100644 --- a/lib/stdlib/doc/src/random.xml +++ b/lib/stdlib/doc/src/random.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2009</year> + <year>1996</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -49,9 +49,15 @@ strong. If a strong cryptographic random number generator is needed for example <c>crypto:rand_bytes/1</c> could be used instead.</p> </description> + <datatypes> + <datatype> + <name name="ran"/> + <desc><p>The state.</p></desc> + </datatype> + </datatypes> <funcs> <func> - <name>seed() -> ran()</name> + <name name="seed" arity="0"/> <fsummary>Seeds random number generation with default values</fsummary> <desc> <p>Seeds random number generation with default (fixed) values @@ -59,11 +65,8 @@ </desc> </func> <func> - <name>seed(A1, A2, A3) -> undefined | ran()</name> + <name name="seed" arity="3"/> <fsummary>Seeds random number generator</fsummary> - <type> - <v>A1 = A2 = A3 = integer()</v> - </type> <desc> <p>Seeds random number generation with integer values in the process dictionary, and returns the old state.</p> @@ -76,26 +79,23 @@ </desc> </func> <func> - <name>seed({A1, A2, A3}) -> undefined | ran()</name> + <name name="seed" arity="1"/> <fsummary>Seeds random number generator</fsummary> - <type> - <v>A1 = A2 = A3 = integer()</v> - </type> <desc> <p> - <c>seed({A1, A2, A3})</c> is equivalent to <c>seed(A1, A2, A3)</c>. + <c>seed({<anno>A1</anno>, <anno>A2</anno>, <anno>A3</anno>})</c> is equivalent to <c>seed(<anno>A1</anno>, <anno>A2</anno>, <anno>A3</anno>)</c>. </p> </desc> </func> <func> - <name>seed0() -> ran()</name> + <name name="seed0" arity="0"/> <fsummary>Return default state for random number generation</fsummary> <desc> <p>Returns the default state.</p> </desc> </func> <func> - <name>uniform()-> float()</name> + <name name="uniform" arity="0"/> <fsummary>Return a random float</fsummary> <desc> <p>Returns a random float uniformly distributed between <c>0.0</c> @@ -103,39 +103,29 @@ </desc> </func> <func> - <name>uniform(N) -> integer()</name> + <name name="uniform" arity="1"/> <fsummary>Return a random integer</fsummary> - <type> - <v>N = integer()</v> - </type> <desc> - <p>Given an integer <c>N >= 1</c>, <c>uniform/1</c> returns a + <p>Given an integer <c><anno>N</anno> >= 1</c>, <c>uniform/1</c> returns a random integer uniformly distributed between <c>1</c> and - <c>N</c>, updating the state in the process dictionary.</p> + <c><anno>N</anno></c>, updating the state in the process dictionary.</p> </desc> </func> <func> - <name>uniform_s(State0) -> {float(), State1}</name> + <name name="uniform_s" arity="1"/> <fsummary>Return a random float</fsummary> - <type> - <v>State0 = State1 = ran()</v> - </type> <desc> <p>Given a state, <c>uniform_s/1</c>returns a random float uniformly distributed between <c>0.0</c> and <c>1.0</c>, and a new state.</p> </desc> </func> <func> - <name>uniform_s(N, State0) -> {integer(), State1}</name> + <name name="uniform_s" arity="2"/> <fsummary>Return a random integer</fsummary> - <type> - <v>N = integer()</v> - <v>State0 = State1 = ran()</v> - </type> <desc> - <p>Given an integer <c>N >= 1</c> and a state, <c>uniform_s/2</c> + <p>Given an integer <c><anno>N</anno> >= 1</c> and a state, <c>uniform_s/2</c> returns a random integer uniformly distributed between <c>1</c> and - <c>N</c>, and a new state.</p> + <c><anno>N</anno></c>, and a new state.</p> </desc> </func> </funcs> diff --git a/lib/stdlib/doc/src/re.xml b/lib/stdlib/doc/src/re.xml index 4d2a0e0995..18867cfb68 100644 --- a/lib/stdlib/doc/src/re.xml +++ b/lib/stdlib/doc/src/re.xml @@ -5,7 +5,7 @@ <header> <copyright> <year>2007</year> - <year>2008</year> + <year>2011</year> <holder>Ericsson AB, All Rights Reserved</holder> </copyright> <legalnotice> @@ -37,51 +37,46 @@ <modulesummary>Perl like regular expressions for Erlang</modulesummary> <description> - <p>This module contains functions for regular expression - matching for strings and binaries.</p> + <p>This module contains regular expression matching functions for + strings and binaries.</p> <p>The regular expression syntax and semantics resemble that of - Perl. This library in many ways replaces the old regexp library - written purely in Erlang, as it has a richer syntax as well as - many more options. The library is also faster than the - older regexp implementation.</p> - - <p>Although the library's matching algorithms are currently based - on the PCRE library, it is not to be viewed as an Erlang to PCRE - mapping. Only parts of the PCRE library is interfaced and the re - library in some ways extend PCRE. The PCRE documentation contains - many parts of no interest to the Erlang programmer, why only the - relevant part of the documentation is included here. There should - bee no need to go directly to the PCRE library documentation.</p> + Perl. This library replaces the deprecated pure-Erlang regexp + library; it has a richer syntax, more options and is faster.</p> + + <p>The library's matching algorithms are currently based on the + PCRE library, but not all of the PCRE library is interfaced and + some parts of the library go beyond what PCRE offers. The sections of + the PCRE documentation which are relevant to this module are included + here.</p> <note> - <p>The Erlang literal syntax for strings give special - meaning to the "\" (backslash) character. To literally write - a regular expression or a replacement string containing a - backslash in your code or in the shell, two backslashes have to be written: - "\\".</p> + <p>The Erlang literal syntax for strings uses the "\" + (backslash) character as an escape code. You need to escape + backslashes in literal strings, both in your code and in the shell, + with an additional backslash, i.e.: "\\".</p> </note> </description> - <section> - <title>DATA TYPES</title> - <code type="none"> - iodata() = iolist() | binary() - iolist() = [char() | binary() | iolist()] - - a binary is allowed as the tail of the list</code> - <code type="none"> - unicode_binary() = binary() with characters encoded in UTF-8 coding standard - unicode_char() = integer() representing valid unicode codepoint - - chardata() = charlist() | unicode_binary() - - charlist() = [unicode_char() | unicode_binary() | charlist()] - - a unicode_binary is allowed as the tail of the list</code> - - <code type="none"> - mp() = Opaque datatype containing a compiled regular expression.</code> - </section> + <datatypes> + <datatype> + <name name="mp"/> + <desc> + <p>Opaque datatype containing a compiled regular expression. + The mp() is guaranteed to be a tuple() having the atom + 're_pattern' as its first element, to allow for matching in + guards. The arity of the tuple() or the content of the other fields + may change in future releases.</p> + </desc> + </datatype> + <datatype> + <name name="nl_spec"/> + </datatype> + <datatype> + <name name="compile_option"/> + </datatype> + </datatypes> <funcs> <func> <name>compile(Regexp) -> {ok, MP} | {error, ErrSpec}</name> @@ -97,14 +92,14 @@ <name>compile(Regexp,Options) -> {ok, MP} | {error, ErrSpec}</name> <fsummary>Compile a regular expression into a match program</fsummary> <type> - <v>Regexp = iodata() | charlist()</v> + <v>Regexp = iodata() | <seealso marker="unicode#type-charlist">io:charlist()</seealso></v> <v>Options = [ Option ]</v> - <v>Option = unicode | anchored | caseless | dollar_endonly | dotall | extended | firstline | multiline | no_auto_capture | dupnames | ungreedy | {newline, NLSpec}| bsr_anycrlf | bsr_unicode</v> - <v>NLSpec = cr | crlf | lf | anycrlf | any </v> - <v>MP = mp()</v> + <v>Option = <seealso marker="#type-compile_option">compile_option()</seealso></v> + <v>NLSpec = <seealso marker="#type-nl_spec">nl_spec()</seealso></v> + <v>MP = <seealso marker="#type-mp">mp()</seealso></v> <v>ErrSpec = {ErrString, Position}</v> <v>ErrString = string()</v> - <v>Position = int()</v> + <v>Position = non_neg_integer()</v> </type> <desc> <p>This function compiles a regular expression with the syntax @@ -117,7 +112,7 @@ time one wants to match.</p> <p>When the unicode option is given, the regular expression should be given as a valid unicode <c>charlist()</c>, otherwise as any valid <c>iodata()</c>.</p> - <p>The options have the following meanings:</p> + <p><marker id="compile_options"/>The options have the following meanings:</p> <taglist> <tag><c>unicode</c></tag> <item>The regular expression is given as a unicode <c>charlist()</c> and the resulting regular expression code is to be run against a valid unicode <c>charlist()</c> subject.</item> @@ -128,7 +123,7 @@ <tag><c>dollar_endonly</c></tag> <item>A dollar metacharacter in the pattern matches only at the end of the subject string. Without this option, a dollar also matches immediately before a newline at the end of the string (but not before any other newlines). The <c>dollar_endonly</c> option is ignored if <c>multiline</c> is given. There is no equivalent option in Perl, and no way to set it within a pattern.</item> <tag><c>dotall</c></tag> - <item>A dot maturate in the pattern matches all characters, including those that indicate newline. Without it, a dot does not match when the current position is at a newline. This option is equivalent to Perl's /s option, and it can be changed within a pattern by a (?s) option setting. A negative class such as [^a] always matches newline characters, independent of the setting of this option.</item> + <item>A dot in the pattern matches all characters, including those that indicate newline. Without it, a dot does not match when the current position is at a newline. This option is equivalent to Perl's /s option, and it can be changed within a pattern by a (?s) option setting. A negative class such as [^a] always matches newline characters, independent of this option's setting.</item> <tag><c>extended</c></tag> <item>Whitespace data characters in the pattern are ignored except when escaped or inside a character class. Whitespace does not include the VT character (ASCII 11). In addition, characters between an unescaped # outside a character class and the next newline, inclusive, are also ignored. This is equivalent to Perl's /x option, and it can be changed within a pattern by a (?x) option setting. @@ -138,7 +133,7 @@ This option makes it possible to include comments inside complicated patterns. N <tag><c>multiline</c></tag> <item><p>By default, PCRE treats the subject string as consisting of a single line of characters (even if it actually contains newlines). The "start of line" metacharacter (^) matches only at the start of the string, while the "end of line" metacharacter ($) matches only at the end of the string, or before a terminating newline (unless <c>dollar_endonly</c> is given). This is the same as Perl.</p> -<p>When <c>multiline</c> it is given, the "start of line" and "end of line" constructs match immediately following or immediately before internal newlines in the subject string, respectively, as well as at the very start and end. This is equivalent to Perl's /m option, and it can be changed within a pattern by a (?m) option setting. If there are no newlines in a subject string, or no occurrences of ^ or $ in a pattern, setting <c>multiline</c> has no effect.</p> </item> +<p>When <c>multiline</c> is given, the "start of line" and "end of line" constructs match immediately following or immediately before internal newlines in the subject string, respectively, as well as at the very start and end. This is equivalent to Perl's /m option, and it can be changed within a pattern by a (?m) option setting. If there are no newlines in a subject string, or no occurrences of ^ or $ in a pattern, setting <c>multiline</c> has no effect.</p> </item> <tag><c>no_auto_capture</c></tag> <item>Disables the use of numbered capturing parentheses in the pattern. Any opening parenthesis that is not followed by ? behaves as if it were followed by ?: but named parentheses can still be used for capturing (and they acquire numbers in the usual way). There is no equivalent of this option in Perl. </item> @@ -174,10 +169,10 @@ This option makes it possible to include comments inside complicated patterns. N <name>run(Subject,RE) -> {match, Captured} | nomatch</name> <fsummary>Match a subject against regular expression and capture subpatterns</fsummary> <type> - <v>Subject = iodata() | charlist()</v> - <v>RE = mp() | iodata() | charlist()</v> + <v>Subject = iodata() | <seealso marker="unicode#type-charlist">io:charlist()</seealso></v> + <v>RE = <seealso marker="#type-mp">mp()</seealso> | iodata()</v> <v>Captured = [ CaptureData ]</v> - <v>CaptureData = {int(),int()}</v> + <v>CaptureData = {integer(),integer()}</v> </type> <desc> <p>The same as <c>run(Subject,RE,[])</c>.</p> @@ -187,18 +182,19 @@ This option makes it possible to include comments inside complicated patterns. N <name>run(Subject,RE,Options) -> {match, Captured} | match | nomatch</name> <fsummary>Match a subject against regular expression and capture subpatterns</fsummary> <type> - <v>Subject = iodata() | charlist()</v> - <v>RE = mp() | iodata() | charlist()</v> + <v>Subject = iodata() | <seealso marker="unicode#type-charlist">io:charlist()</seealso></v> + <v>RE = <seealso marker="#type-mp">mp()</seealso> | iodata() | <seealso marker="unicode#type-charlist">io:charlist()</seealso></v> <v>Options = [ Option ]</v> - <v>Option = anchored | global | notbol | noteol | notempty | {offset, int()} | {newline, NLSpec} | bsr_anycrlf | bsr_unicode | {capture, ValueSpec} | {capture, ValueSpec, Type} | CompileOpt</v> + <v>Option = anchored | global | notbol | noteol | notempty | {offset, integer() >= 0} | {newline, NLSpec} | bsr_anycrlf | bsr_unicode | {capture, ValueSpec} | {capture, ValueSpec, Type} | CompileOpt</v> <v>Type = index | list | binary</v> <v>ValueSpec = all | all_but_first | first | none | ValueList</v> <v>ValueList = [ ValueID ]</v> - <v>ValueID = int() | string() | atom()</v> - <v>CompileOpt = see compile/2 above</v> - <v>NLSpec = cr | crlf | lf | anycrlf | any</v> + <v>ValueID = integer() | string() | atom()</v> + <v>CompileOpt = <seealso marker="#type-compile_option">compile_option()</seealso></v> + <d>See <seealso marker="#compile_options">compile/2</seealso> above.</d> + <v>NLSpec = <seealso marker="#type-nl_spec">nl_spec()</seealso></v> <v>Captured = [ CaptureData ] | [ [ CaptureData ] ... ]</v> - <v>CaptureData = {int(),int()} | ListConversionData | binary()</v> + <v>CaptureData = {integer(),integer()} | ListConversionData | binary()</v> <v>ListConversionData = string() | {error, string(), binary()} | {incomplete, string(), binary()}</v> </type> <desc> @@ -210,14 +206,15 @@ This option makes it possible to include comments inside complicated patterns. N or as a pre compiled <c>mp()</c> in which case it is executed against the subject directly.</p> - <p>When compilation is involved, the exception <c>badarg</c> is thrown if - a compilation error occurs. To locate the error in the regular - expression, use the function <c>re:compile/2</c> to get more information.</p> + <p>When compilation is involved, the exception <c>badarg</c> is + thrown if a compilation error occurs. Call <c>re:compile/2</c> + to get information about the location of the error in the + regular expression.</p> <p>If the regular expression is previously compiled, the option list can only contain the options <c>anchored</c>, <c>global</c>, <c>notbol</c>, <c>noteol</c>, - <c>notempty</c>, <c>{offset, int()}</c>, <c>{newline, + <c>notempty</c>, <c>{offset, integer() >= 0}</c>, <c>{newline, NLSpec}</c> and <c>{capture, ValueSpec}/{capture, ValueSpec, Type}</c>. Otherwise all options valid for the <c>re:compile/2</c> function are allowed as well. Options @@ -242,7 +239,7 @@ This option makes it possible to include comments inside complicated patterns. N how captured substrings are to be returned (as index tuples, lists or binaries). The <c>capture</c> option makes the function quite flexible and powerful. The different options are described - in detail below</p> + in detail below.</p> <p>If the capture options describe that no substring capturing at all is to be done (<c>{capture, none}</c>), the function will @@ -252,7 +249,7 @@ This option makes it possible to include comments inside complicated patterns. N be done either by specifying <c>none</c> or an empty list as <c>ValueSpec</c>.</p> - <p>A description of all the options relevant for execution follows:</p> + <p>The options relevant for execution are:</p> <taglist> <tag><c>anchored</c></tag> @@ -266,27 +263,25 @@ This option makes it possible to include comments inside complicated patterns. N <tag><c>global</c></tag> <item> - <p>Implements global (repetitive) search as the <c>g</c> flag in - i.e. Perl. Each match found is returned as a separate + <p>Implements global (repetitive) search (the <c>g</c> flag in + Perl). Each match is returned as a separate <c>list()</c> containing the specific match as well as any matching subexpressions (or as specified by the <c>capture option</c>). The <c>Captured</c> part of the return value will - hence be a <c>list()</c> of <c>list()</c>'s when this + hence be a <c>list()</c> of <c>list()</c>s when this option is given.</p> - <p>When the regular expression matches an empty string, the - behaviour might seem non-intuitive, why the behaviour requites - some clarifying. With the global option, <c>re:run/3</c> - handles empty matches in the same way as Perl, meaning that a - match at any point giving an empty string (with length 0) will - be retried with the options - <c>[anchored, notempty]</c> as well. If that - search gives a result of length > 0, the result is included. - An example:</p> + <p>The interaction of the global option with a regular + expression which matches an empty string surprises some users. + When the global option is given, <c>re:run/3</c> handles empty + matches in the same way as Perl: a zero-length match at any + point will be retried with the options <c>[anchored, + notempty]</c> as well. If that search gives a result of length + > 0, the result is included. For example:</p> <code> re:run("cat","(|at)",[global]).</code> - <p>The matching will be performed as following:</p> + <p>The following matching will be performed:</p> <taglist> <tag>At offset <c>0</c></tag> <item>The regexp <c>(|at)</c> will first match at the initial @@ -298,11 +293,11 @@ This option makes it possible to include comments inside complicated patterns. N <item> The search is retried with the options <c>[anchored, notempty]</c> at the same position, which does not give any interesting result of longer - length, why the search position is now advanced to the next + length, so the search position is now advanced to the next character (<c>a</c>).</item> <tag>At offset <c>1</c></tag> - <item>Now the search results in - <c>[{1,0},{1,0}]</c> meaning this search will also be repeated + <item>This time, the search results in + <c>[{1,0},{1,0}]</c>, so this search will also be repeated with the extra options.</item> <tag>At offset <c>1</c> with <c>[anchored, notempty]</c></tag> <item>Now the <c>ab</c> alternative @@ -329,16 +324,17 @@ This option makes it possible to include comments inside complicated patterns. N entire match fails. For example, if the pattern</p> <code> a?b?</code> <p>is applied to a string not beginning with "a" or "b", it - matches the empty string at the start of the subject. With - <c>notempty</c> given, this match is not valid, so re:run/3 searches - further into the string for occurrences of "a" or "b".</p> + would normally match the empty string at the start of the + subject. With the <c>notempty</c> option, this match is not + valid, so re:run/3 searches further into the string for + occurrences of "a" or "b".</p> <p>Perl has no direct equivalent of <c>notempty</c>, but it does make a special case of a pattern match of the empty string within its split() function, and when using the /g modifier. It is possible to emulate Perl's behavior after matching a null string by first trying the match again at the same offset with - <c>notempty</c> and <c>anchored</c>, and then if that fails by + <c>notempty</c> and <c>anchored</c>, and then, if that fails, by advancing the starting offset (see below) and trying an ordinary match again.</p> </item> @@ -348,7 +344,7 @@ This option makes it possible to include comments inside complicated patterns. N string is not the beginning of a line, so the circumflex metacharacter should not match before it. Setting this without <c>multiline</c> (at compile time) causes circumflex never to - match. This option affects only the behavior of the circumflex + match. This option only affects the behavior of the circumflex metacharacter. It does not affect \A.</item> <tag><c>noteol</c></tag> @@ -361,7 +357,7 @@ This option makes it possible to include comments inside complicated patterns. N behavior of the dollar metacharacter. It does not affect \Z or \z.</item> - <tag><c>{offset, int()}</c></tag> + <tag><c>{offset, integer() >= 0}</c></tag> <item>Start matching at the offset (position) given in the subject string. The offset is zero-based, so that the default is @@ -384,7 +380,7 @@ This option makes it possible to include comments inside complicated patterns. N </taglist> </item> <tag><c>bsr_anycrlf</c></tag> - <item>Specifies specifically that \R is to match only the cr, lf or crlf sequences, not the Unicode specific newline characters.(overrides compilation option)</item> + <item>Specifies specifically that \R is to match only the cr, lf or crlf sequences, not the Unicode specific newline characters. (overrides compilation option)</item> <tag><c>bsr_unicode</c></tag> <item>Specifies specifically that \R is to match all the Unicode newline characters (including crlf etc, the default).(overrides compilation option)</item> @@ -440,7 +436,7 @@ This option makes it possible to include comments inside complicated patterns. N <tag><c>none</c></tag> <item>Do not return matching subpatterns at all, yielding the single atom <c>match</c> as the return value of the function when matching successfully instead of the <c>{match, list()}</c> return. Specifying an empty list gives the same behavior.</item> </taglist> - <p>The value list is a list of indexes for the subpatterns to return, where index 0 is for all of the pattern, and 1 is for the first explicit capturing subpattern in the regular expression, and so forth. When using named captured subpatterns (see below) in the regular expression, one can use <c>atom()</c>'s or <c>string()</c>'s to specify the subpatterns to be returned. This deserves an example, consider the following regular expression:</p> + <p>The value list is a list of indexes for the subpatterns to return, where index 0 is for all of the pattern, and 1 is for the first explicit capturing subpattern in the regular expression, and so forth. When using named captured subpatterns (see below) in the regular expression, one can use <c>atom()</c>s or <c>string()</c>s to specify the subpatterns to be returned. For example, consider the regular expression:</p> <code> ".*(abcd).*"</code> <p>matched against the string ""ABCabcdABC", capturing only the "abcd" part (the first explicit subpattern):</p> <code> re:run("ABCabcdABC",".*(abcd).*",[{capture,[1]}]).</code> @@ -451,7 +447,7 @@ This option makes it possible to include comments inside complicated patterns. N <code> ".*(?<FOO>abcd).*"</code> <p>With this expression, we could still give the index of the subpattern with the following call:</p> <code> re:run("ABCabcdABC",".*(?<FOO>abcd).*",[{capture,[1]}]).</code> - <p>giving the same result as before. But as the subpattern is named, we can also give its name in the value list:</p> + <p>giving the same result as before. But, since the subpattern is named, we can also specify its name in the value list:</p> <code> re:run("ABCabcdABC",".*(?<FOO>abcd).*",[{capture,['FOO']}]).</code> <p>which would yield the same result as the earlier examples, namely:</p> <code> {match,[{3,4}]}</code> @@ -469,15 +465,15 @@ This option makes it possible to include comments inside complicated patterns. N <item><p>Optionally specifies how captured substrings are to be returned. If omitted, the default of <c>index</c> is used. The <c>Type</c> can be one of the following:</p> <taglist> <tag><c>index</c></tag> - <item>Return captured substrings as pairs of byte indexes into the subject string and length of the matching string in the subject (as if the subject string was flattened with <c>iolist_to_binary/1</c> or <c>unicode:characters_to_binary/2</c> prior to matching). Note that the <c>unicode</c> option results in <em>byte-oriented</em> indexes in a (possibly imagined) <em>UTF-8 encoded</em> binary. A byte index tuple <c>{0,2}</c> might therefore represent one or two characters when <c>unicode</c> is in effect. This might seem contra-intuitive, but has been deemed the most effective and useful way to way to do it. To return lists instead might result in simpler code if that is desired. This return type is the default.</item> + <item>Return captured substrings as pairs of byte indexes into the subject string and length of the matching string in the subject (as if the subject string was flattened with <c>iolist_to_binary/1</c> or <c>unicode:characters_to_binary/2</c> prior to matching). Note that the <c>unicode</c> option results in <em>byte-oriented</em> indexes in a (possibly virtual) <em>UTF-8 encoded</em> binary. A byte index tuple <c>{0,2}</c> might therefore represent one or two characters when <c>unicode</c> is in effect. This might seem counter-intuitive, but has been deemed the most effective and useful way to way to do it. To return lists instead might result in simpler code if that is desired. This return type is the default.</item> <tag><c>list</c></tag> - <item>Return matching substrings as lists of characters (Erlang <c>string()</c>'s). It the <c>unicode</c> option is used in combination with the \C sequence in the regular expression, a captured subpattern can contain bytes that has is not valid UTF-8 (\C matches bytes regardless of character encoding). In that case the <c>list</c> capturing may result in the same types of tuples that <c>unicode:characters_to_list/2</c> can return, namely three-tuples with the tag <c>incomplete</c> or <c>error</c>, the successfully converted characters and the invalid UTF-8 tail of the conversion as a binary. The best strategy is to avoid using the \C sequence when capturing lists.</item> + <item>Return matching substrings as lists of characters (Erlang <c>string()</c>s). It the <c>unicode</c> option is used in combination with the \C sequence in the regular expression, a captured subpattern can contain bytes that are not valid UTF-8 (\C matches bytes regardless of character encoding). In that case the <c>list</c> capturing may result in the same types of tuples that <c>unicode:characters_to_list/2</c> can return, namely three-tuples with the tag <c>incomplete</c> or <c>error</c>, the successfully converted characters and the invalid UTF-8 tail of the conversion as a binary. The best strategy is to avoid using the \C sequence when capturing lists.</item> <tag><c>binary</c></tag> - <item>Return matching substrings as binaries. If the <c>unicode</c> option is used, these binaries is in UTF-8. If the \C sequence is used together with <c>unicode</c> the binaries may be invalid UTF-8.</item> + <item>Return matching substrings as binaries. If the <c>unicode</c> option is used, these binaries are in UTF-8. If the \C sequence is used together with <c>unicode</c> the binaries may be invalid UTF-8.</item> </taglist> </item> </taglist> - <p>In general, subpatterns that got assigned no value in the match are returned as the tuple <c>{-1,0}</c> when <c>type</c> is <c>index</c>. Unassigned subpatterns are returned as the empty binary or list respectively for other return types. Consider the regular expression:</p> + <p>In general, subpatterns that were not assigned a value in the match are returned as the tuple <c>{-1,0}</c> when <c>type</c> is <c>index</c>. Unassigned subpatterns are returned as the empty binary or list, respectively, for other return types. Consider the regular expression:</p> <code> ".*((?<FOO>abdd)|a(..d)).*"</code> <p>There are three explicitly capturing subpatterns, where the opening parenthesis position determines the order in the result, hence <c>((?<FOO>abdd)|a(..d))</c> is subpattern index 1, <c>(?<FOO>abdd)</c> is subpattern index 2 and <c>(..d)</c> is subpattern index 3. When matched against the following string:</p> <code> "ABCabcdABC"</code> @@ -504,43 +500,28 @@ This option makes it possible to include comments inside complicated patterns. N </desc> </func> <func> - <name>replace(Subject,RE,Replacement) -> iodata() | charlist()</name> + <name name="replace" arity="3"/> <fsummary>Match a subject against regular expression and replace matching elements with Replacement</fsummary> - <type> - <v>Subject = iodata() | charlist()</v> - <v>RE = mp() | iodata()</v> - <v>Replacement = iodata() | charlist()</v> - </type> <desc> - <p>The same as <c>replace(Subject,RE,Replacement,[])</c>.</p> + <p>The same as <c>replace(<anno>Subject</anno>,<anno>RE</anno>,<anno>Replacement</anno>,[])</c>.</p> </desc> </func> <func> - <name>replace(Subject,RE,Replacement,Options) -> iodata() | charlist() | binary() | list()</name> + <name name="replace" arity="4"/> <fsummary>Match a subject against regular expression and replace matching elements with Replacement</fsummary> - <type> - <v>Subject = iodata() | charlist()</v> - <v>RE = mp() | iodata() | charlist()</v> - <v>Replacement = iodata() | charlist()</v> - <v>Options = [ Option ]</v> - <v>Option = anchored | global | notbol | noteol | notempty | {offset, int()} | {newline, NLSpec} | bsr_anycrlf | bsr_unicode | {return, ReturnType} | CompileOpt</v> - <v>ReturnType = iodata | list | binary</v> - <v>CompileOpt = see compile/2 above</v> - <v>NLSpec = cr | crlf | lf | anycrlf | any </v> - </type> <desc> - <p>Replaces the matched part of the <c>Subject</c> string with the content of <c>Replacement</c>.</p> - <p>Options are given as to the <c>re:run/3</c> function except that the <c>capture</c> option of <c>re:run/3</c> is not allowed. - Instead a <c>{return, ReturnType}</c> is present. The default return type is <c>iodata</c>, constructed in a + <p>Replaces the matched part of the <c><anno>Subject</anno></c> string with the contents of <c><anno>Replacement</anno></c>.</p> + <p>The permissible options are the same as for <c>re:run/3</c>, except that the <c>capture</c> option is not allowed. + Instead a <c>{return, <anno>ReturnType</anno>}</c> is present. The default return type is <c>iodata</c>, constructed in a way to minimize copying. The <c>iodata</c> result can be used directly in many i/o-operations. If a flat <c>list()</c> is desired, specify <c>{return, list}</c> and if a binary is preferred, specify <c>{return, binary}</c>.</p> <p>As in the <c>re:run/3</c> function, an <c>mp()</c> compiled - with the <c>unicode</c> option requires the <c>Subject</c> to be + with the <c>unicode</c> option requires the <c><anno>Subject</anno></c> to be a Unicode <c>charlist()</c>. If compilation is done implicitly and the <c>unicode</c> compilation option is given to this - function, both the regular expression and the <c>Subject</c> - should be given as valid Unicode <c>charlist()</c>'s.</p> + function, both the regular expression and the <c><anno>Subject</anno></c> + should be given as valid Unicode <c>charlist()</c>s.</p> <p>The replacement string can contain the special character <c>&</c>, which inserts the whole matching expression in the @@ -550,7 +531,7 @@ This option makes it possible to include comments inside complicated patterns. N generated by the regular expression, nothing is inserted.</p> <p>To insert an <c>&</c> or <c>\</c> in the result, precede it with a <c>\</c>. Note that Erlang already gives a special - meaning to <c>\</c> in literal strings, why a single <c>\</c> + meaning to <c>\</c> in literal strings, so a single <c>\</c> has to be written as <c>"\\"</c> and therefore a double <c>\</c> as <c>"\\\\"</c>. Example:</p> <code> re:replace("abcd","c","[&]",[{return,list}]).</code> @@ -566,34 +547,17 @@ This option makes it possible to include comments inside complicated patterns. N </desc> </func> <func> - <name>split(Subject,RE) -> SplitList</name> + <name name="split" arity="2"/> <fsummary>Split a string by tokens specified as a regular expression</fsummary> - <type> - <v>Subject = iodata() | charlist()</v> - <v>RE = mp() | iodata()</v> - <v>SplitList = [ iodata() | charlist() ]</v> - </type> <desc> - <p>The same as <c>split(Subject,RE,[])</c>.</p> + <p>The same as <c>split(<anno>Subject</anno>,<anno>RE</anno>,[])</c>.</p> </desc> </func> <func> - <name>split(Subject,RE,Options) -> SplitList</name> + <name name="split" arity="3"/> <fsummary>Split a string by tokens specified as a regular expression</fsummary> - <type> - <v>Subject = iodata() | charlist()</v> - <v>RE = mp() | iodata() | charlist()</v> - <v>Options = [ Option ]</v> - <v>Option = anchored | global | notbol | noteol | notempty | {offset, int()} | {newline, NLSpec} | bsr_anycrlf | bsr_unicode | {return, ReturnType} | {parts, NumParts} | group | trim | CompileOpt</v> - <v>NumParts = int() | infinity</v> - <v>ReturnType = iodata | list | binary</v> - <v>CompileOpt = see compile/2 above</v> - <v>NLSpec = cr | crlf | lf | anycrlf | any </v> - <v>SplitList = [ RetData ] | [ GroupedRetData ]</v> - <v>GroupedRetData = [ RetData ]</v> - <v>RetData = iodata() | charlist() | binary() | list()</v> - </type> + <type_desc variable="CompileOpt">See <seealso marker="#compile_options">compile/2</seealso> above.</type_desc> <desc> <p>This function splits the input into parts by finding tokens according to the regular expression supplied.</p> @@ -603,11 +567,11 @@ This option makes it possible to include comments inside complicated patterns. N of the string is removed from the output.</p> <p>As in the <c>re:run/3</c> function, an <c>mp()</c> compiled - with the <c>unicode</c> option requires the <c>Subject</c> to be + with the <c>unicode</c> option requires the <c><anno>Subject</anno></c> to be a Unicode <c>charlist()</c>. If compilation is done implicitly and the <c>unicode</c> compilation option is given to this - function, both the regular expression and the <c>Subject</c> - should be given as valid Unicode <c>charlist()</c>'s.</p> + function, both the regular expression and the <c><anno>Subject</anno></c> + should be given as valid Unicode <c>charlist()</c>s.</p> <p>The result is given as a list of "strings", the preferred datatype given in the <c>return</c> option (default iodata).</p> @@ -652,25 +616,25 @@ This option makes it possible to include comments inside complicated patterns. N <p>Here the regular expression matched first the "l", causing "Er" to be the first part in the result. When the regular expression matched, the (only) subexpression was - bound to the "l", why the "l" is inserted + bound to the "l", so the "l" is inserted in the group together with "Er". The next match is of the "n", making "a" the next part to be - returned. As the subexpression is bound to the substring + returned. Since the subexpression is bound to the substring "n" in this case, the "n" is inserted into this group. The last group consists of the rest of the string, as no more matches are found.</p> <p>By default, all parts of the string, including the empty - strings are returned from the function. As an example:</p> + strings, are returned from the function. For example:</p> <code> re:split("Erlang","[lg]",[{return,list}]).</code> - <p>The result will be:</p> + <p>will return:</p> <code> ["Er","an",[]]</code> - <p>as the matching of the "g" in the end of the string + <p>since the matching of the "g" in the end of the string leaves an empty rest which is also returned. This behaviour differs from the default behaviour of the split function in Perl, where empty strings at the end are by default removed. To @@ -697,10 +661,10 @@ This option makes it possible to include comments inside complicated patterns. N <p>Note that the last part is "ang", not "an", as we only specified splitting into two parts, - and the splitting stops when enough parts are given, why the - result differs from that of <c>trim</c>.</p> + and the splitting stops when enough parts are given, which is + why the result differs from that of <c>trim</c>.</p> - <p>More than three parts are not possible with this indata, why</p> + <p>More than three parts are not possible with this indata, so</p> <code> re:split("Erlang","[lg]",[{return,list},{parts,4}]).</code> @@ -723,7 +687,7 @@ This option makes it possible to include comments inside complicated patterns. N <p>Summary of options not previously described for the <c>re:run/3</c> function:</p> <taglist> - <tag>{return,ReturnType}</tag> + <tag>{return,<anno>ReturnType</anno>}</tag> <item><p>Specifies how the parts of the original string are presented in the result list. The possible types are:</p> <taglist> <tag>iodata</tag> @@ -741,7 +705,7 @@ This option makes it possible to include comments inside complicated patterns. N the parts of the string matching the subexpressions of the regexp.</p> <p>The return value from the function will in this case be a - <c>list()</c> of <c>list()</c>'s. Each sublist begins with the + <c>list()</c> of <c>list()</c>s. Each sublist begins with the string picked out of the subject string, followed by the parts matching each of the subexpressions in order of occurrence in the regular expression.</p> @@ -778,10 +742,8 @@ This option makes it possible to include comments inside complicated patterns. N <title>PERL LIKE REGULAR EXPRESSIONS SYNTAX</title> <p>The following sections contain reference material for the regular expressions used by this module. The regular expression - reference is taken from the PCRE documentation, but converted as - needed.</p> - <p>The documentation is altered where appropriate and where the re - module behaves differently than the PCRE library.</p> + reference is based on the PCRE documentation, with changes in + cases where the re module behaves differently to the PCRE library.</p> </section> <section><title>PCRE regular expression details</title> diff --git a/lib/stdlib/doc/src/ref_man.xml b/lib/stdlib/doc/src/ref_man.xml index f6ae368e92..85aae6151d 100644 --- a/lib/stdlib/doc/src/ref_man.xml +++ b/lib/stdlib/doc/src/ref_man.xml @@ -4,7 +4,7 @@ <application xmlns:xi="http://www.w3.org/2001/XInclude"> <header> <copyright> - <year>1996</year><year>2009</year> + <year>1996</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>STDLIB Reference Manual</title> @@ -37,6 +37,7 @@ <xi:include href="array.xml"/> <xi:include href="base64.xml"/> <xi:include href="beam_lib.xml"/> + <xi:include href="binary.xml"/> <xi:include href="c.xml"/> <xi:include href="calendar.xml"/> <xi:include href="dets.xml"/> diff --git a/lib/stdlib/doc/src/regexp.xml b/lib/stdlib/doc/src/regexp.xml index 8c4191c88f..35d8e1c3f8 100644 --- a/lib/stdlib/doc/src/regexp.xml +++ b/lib/stdlib/doc/src/regexp.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2009</year> + <year>1996</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -40,176 +40,150 @@ <p>This module contains functions for regular expression matching and substitution.</p> </description> + <datatypes> + <datatype> + <name name="errordesc"></name> + </datatype> + <datatype> + <name name="regexp"></name> + <desc><p>Internal representation of a regular expression.</p></desc> + </datatype> + </datatypes> <funcs> <func> - <name>match(String, RegExp) -> MatchRes</name> + <name name="match" arity="2"/> <fsummary>Match a regular expression</fsummary> - <type> - <v>String = RegExp = string()</v> - <v>MatchRes = {match,Start,Length} | nomatch | {error,errordesc()}</v> - <v>Start = Length = integer()</v> - </type> <desc> - <p>Finds the first, longest match of the regular expression <c>RegExp</c> in <c>String</c>. This function searches for the longest possible match and returns the first one found if there are several expressions of the same length. It returns as follows:</p> + <p>Finds the first, longest match of the regular expression <c><anno>RegExp</anno></c> in <c><anno>String</anno></c>. This function searches for the longest possible match and returns the first one found if there are several expressions of the same length. It returns as follows:</p> <taglist> - <tag><c>{match,Start,Length}</c></tag> + <tag><c>{match,<anno>Start</anno>,<anno>Length</anno>}</c></tag> <item> - <p>if the match succeeded. <c>Start</c> is the starting - position of the match, and <c>Length</c> is the length of + <p>if the match succeeded. <c><anno>Start</anno></c> is the starting + position of the match, and <c><anno>Length</anno></c> is the length of the matching string.</p> </item> <tag><c>nomatch</c></tag> <item> <p>if there were no matching characters.</p> </item> - <tag><c>{error,Error}</c></tag> + <tag><c>{error,<anno>Error</anno>}</c></tag> <item> - <p>if there was an error in <c>RegExp</c>.</p> + <p>if there was an error in <c><anno>RegExp</anno></c>.</p> </item> </taglist> </desc> </func> <func> - <name>first_match(String, RegExp) -> MatchRes</name> + <name name="first_match" arity="2"/> <fsummary>Match a regular expression</fsummary> - <type> - <v>String = RegExp = string()</v> - <v>MatchRes = {match,Start,Length} | nomatch | {error,errordesc()}</v> - <v>Start = Length = integer()</v> - </type> <desc> - <p>Finds the first match of the regular expression <c>RegExp</c> in <c>String</c>. This call is + <p>Finds the first match of the regular expression <c><anno>RegExp</anno></c> in <c><anno>String</anno></c>. This call is usually faster than <c>match</c> and it is also a useful way to ascertain that a match exists. It returns as follows:</p> <taglist> - <tag><c>{match,Start,Length}</c></tag> + <tag><c>{match,<anno>Start</anno>,<anno>Length</anno>}</c></tag> <item> - <p>if the match succeeded. <c>Start</c> is the starting - position of the match and <c>Length</c> is the length of + <p>if the match succeeded. <c><anno>Start</anno></c> is the starting + position of the match and <c><anno>Length</anno></c> is the length of the matching string.</p> </item> <tag><c>nomatch</c></tag> <item> <p>if there were no matching characters.</p> </item> - <tag><c>{error,Error}</c></tag> + <tag><c>{error,<anno>Error</anno>}</c></tag> <item> - <p>if there was an error in <c>RegExp</c>.</p> + <p>if there was an error in <c><anno>RegExp</anno></c>.</p> </item> </taglist> </desc> </func> <func> - <name>matches(String, RegExp) -> MatchRes</name> + <name name="matches" arity="2"/> <fsummary>Match a regular expression</fsummary> - <type> - <v>String = RegExp = string()</v> - <v>MatchRes = {match, Matches} | {error, errordesc()}</v> - <v>Matches = list()</v> - </type> <desc> <p>Finds all non-overlapping matches of the - expression <c>RegExp</c> in <c>String</c>. + expression <c><anno>RegExp</anno></c> in <c><anno>String</anno></c>. It returns as follows:</p> <taglist> - <tag><c>{match, Matches}</c></tag> + <tag><c>{match, <anno>Matches</anno>}</c></tag> <item> <p>if the regular expression was correct. - The list will be empty if there was no match. Each element in the list looks like <c>{Start, Length}</c>, where <c>Start</c> is the starting position of the match, and <c>Length</c> is the length of the matching string.</p> + The list will be empty if there was no match. Each element in the list looks like <c>{<anno>Start</anno>, <anno>Length</anno>}</c>, where <c><anno>Start</anno></c> is the starting position of the match, and <c><anno>Length</anno></c> is the length of the matching string.</p> </item> - <tag><c>{error,Error}</c></tag> + <tag><c>{error,<anno>Error</anno>}</c></tag> <item> - <p>if there was an error in <c>RegExp</c>.</p> + <p>if there was an error in <c><anno>RegExp</anno></c>.</p> </item> </taglist> </desc> </func> <func> - <name>sub(String, RegExp, New) -> SubRes</name> + <name name="sub" arity="3"/> <fsummary>Substitute the first occurrence of a regular expression</fsummary> - <type> - <v>String = RegExp = New = string()</v> - <v>SubRes = {ok,NewString,RepCount} | {error,errordesc()}</v> - <v>RepCount = integer()</v> - </type> <desc> - <p>Substitutes the first occurrence of a substring matching <c>RegExp</c> in <c>String</c> with the string <c>New</c>. A <c><![CDATA[&]]></c> in the string <c>New</c> is replaced by the matched substring of <c>String</c>. <c><![CDATA[\&]]></c> puts a literal <c><![CDATA[&]]></c> into the replacement string. It returns as follows:</p> + <p>Substitutes the first occurrence of a substring matching <c><anno>RegExp</anno></c> in <c><anno>String</anno></c> with the string <c><anno>New</anno></c>. A <c><![CDATA[&]]></c> in the string <c><anno>New</anno></c> is replaced by the matched substring of <c><anno>String</anno></c>. <c><![CDATA[\&]]></c> puts a literal <c><![CDATA[&]]></c> into the replacement string. It returns as follows:</p> <taglist> - <tag><c>{ok,NewString,RepCount}</c></tag> + <tag><c>{ok,<anno>NewString</anno>,<anno>RepCount</anno>}</c></tag> <item> - <p>if <c>RegExp</c> is correct. <c>RepCount</c> is the number of replacements which have been made + <p>if <c><anno>RegExp</anno></c> is correct. <c><anno>RepCount</anno></c> is the number of replacements which have been made (this will be either 0 or 1).</p> </item> - <tag><c>{error, Error}</c></tag> + <tag><c>{error, <anno>Error</anno>}</c></tag> <item> - <p>if there is an error in <c>RegExp</c>.</p> + <p>if there is an error in <c><anno>RegExp</anno></c>.</p> </item> </taglist> </desc> </func> <func> - <name>gsub(String, RegExp, New) -> SubRes</name> + <name name="gsub" arity="3"/> <fsummary>Substitute all occurrences of a regular expression</fsummary> - <type> - <v>String = RegExp = New = string()</v> - <v>SubRes = {ok,NewString,RepCount} | {error,errordesc()}</v> - <v>RepCount = integer()</v> - </type> <desc> <p>The same as <c>sub</c>, except that all non-overlapping occurrences of a substring matching - <c>RegExp</c> in <c>String</c> are replaced by the string <c>New</c>. It returns:</p> + <c><anno>RegExp</anno></c> in <c><anno>String</anno></c> are replaced by the string <c><anno>New</anno></c>. It returns:</p> <taglist> - <tag><c>{ok,NewString,RepCount}</c></tag> + <tag><c>{ok,<anno>NewString</anno>,<anno>RepCount</anno>}</c></tag> <item> - <p>if <c>RegExp</c> is correct. <c>RepCount</c> is the number of replacements which have been made.</p> + <p>if <c><anno>RegExp</anno></c> is correct. <c><anno>RepCount</anno></c> is the number of replacements which have been made.</p> </item> - <tag><c>{error, Error}</c></tag> + <tag><c>{error, <anno>Error</anno>}</c></tag> <item> - <p>if there is an error in <c>RegExp</c>.</p> + <p>if there is an error in <c><anno>RegExp</anno></c>.</p> </item> </taglist> </desc> </func> <func> - <name>split(String, RegExp) -> SplitRes</name> + <name name="split" arity="2"/> <fsummary>Split a string into fields</fsummary> - <type> - <v>String = RegExp = string()</v> - <v>SubRes = {ok,FieldList} | {error,errordesc()}</v> - <v>Fieldlist = [string()]</v> - </type> <desc> - <p><c>String</c> is split into fields (sub-strings) by the - regular expression <c>RegExp</c>.</p> + <p><c><anno>String</anno></c> is split into fields (sub-strings) by the + regular expression <c><anno>RegExp</anno></c>.</p> <p>If the separator expression is <c>" "</c> (a single space), then the fields are separated by blanks and/or tabs and leading and trailing blanks and tabs are discarded. For all other values of the separator, leading and trailing blanks and tabs are not discarded. It returns:</p> <taglist> - <tag><c>{ok, FieldList}</c></tag> + <tag><c>{ok, <anno>FieldList</anno>}</c></tag> <item> <p>to indicate that the string has been split up into the fields of - <c>FieldList</c>.</p> + <c><anno>FieldList</anno></c>.</p> </item> - <tag><c>{error, Error}</c></tag> + <tag><c>{error, <anno>Error</anno>}</c></tag> <item> - <p>if there is an error in <c>RegExp</c>.</p> + <p>if there is an error in <c><anno>RegExp</anno></c>.</p> </item> </taglist> </desc> </func> <func> - <name>sh_to_awk(ShRegExp) -> AwkRegExp</name> + <name name="sh_to_awk" arity="1"/> <fsummary>Convert an <c>sh</c>regular expression into an <c>AWK</c>one</fsummary> - <type> - <v>ShRegExp AwkRegExp = string()</v> - <v>SubRes = {ok,NewString,RepCount} | {error,errordesc()}</v> - <v>RepCount = integer()</v> - </type> <desc> <p>Converts the <c>sh</c> type regular expression - <c>ShRegExp</c> into a full <c>AWK</c> regular + <c><anno>ShRegExp</anno></c> into a full <c>AWK</c> regular expression. Returns the converted regular expression string. <c>sh</c> expressions are used in the shell for matching file names and have the following special @@ -236,40 +210,32 @@ </desc> </func> <func> - <name>parse(RegExp) -> ParseRes</name> + <name name="parse" arity="1"/> <fsummary>Parse a regular expression</fsummary> - <type> - <v>RegExp = string()</v> - <v>ParseRes = {ok,RE} | {error,errordesc()}</v> - </type> <desc> - <p>Parses the regular expression <c>RegExp</c> and builds the + <p>Parses the regular expression <c><anno>RegExp</anno></c> and builds the internal representation used in the other regular expression functions. Such representations can be used in all of the other functions instead of a regular expression string. This is more efficient when the same regular expression is used in many strings. It returns:</p> <taglist> - <tag><c>{ok, RE}</c>if <c>RegExp</c>is correct and <c>RE</c>is the internal representation.</tag> + <tag><c>{ok, <anno>RE</anno>}</c></tag> <item> - <p></p> + <p>if <c>RegExp</c> is correct and <c><anno>RE</anno></c> is the internal representation.</p> </item> - <tag><c>{error, Error}</c>if there is an error in <c>RegExpString</c>.</tag> + <tag><c>{error, <anno>Error</anno>}</c></tag> <item> - <p></p> + <p>if there is an error in <c><anno>RegExp</anno></c>.</p> </item> </taglist> </desc> </func> <func> - <name>format_error(ErrorDescriptor) -> Chars</name> + <name name="format_error" arity="1"/> <fsummary>Format an error descriptor</fsummary> - <type> - <v>ErrorDescriptor = errordesc()</v> - <v>Chars = [char() | Chars]</v> - </type> <desc> - <p>Returns a string which describes the error <c>ErrorDescriptor</c> + <p>Returns a string which describes the error <c><anno>ErrorDescriptor</anno></c> returned when there is an error in a regular expression.</p> </desc> </func> diff --git a/lib/stdlib/doc/src/sets.xml b/lib/stdlib/doc/src/sets.xml index 3610bb0184..071ee437cb 100644 --- a/lib/stdlib/doc/src/sets.xml +++ b/lib/stdlib/doc/src/sets.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>2000</year><year>2009</year> + <year>2000</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -43,202 +43,141 @@ different if and only if they do not compare equal (<c>==</c>).</p> </description> - <section> - <title>DATA TYPES</title> - <code type="none"> -set() - as returned by new/0</code> - </section> + <datatypes> + <datatype> + <name><marker id="type-dict">set()</marker></name> + <desc><p>As returned by <c>new/0</c>.</p></desc> + </datatype> + </datatypes> <funcs> <func> - <name>new() -> Set</name> + <name name="new" arity="0"/> <fsummary>Return an empty set</fsummary> - <type> - <v>Set = set()</v> - </type> <desc> <p>Returns a new empty set.</p> </desc> </func> <func> - <name>is_set(Set) -> bool()</name> + <name name="is_set" arity="1"/> <fsummary>Test for an <c>Set</c></fsummary> - <type> - <v>Set = term()</v> - </type> <desc> - <p>Returns <c>true</c> if <c>Set</c> is a set of + <p>Returns <c>true</c> if <c><anno>Set</anno></c> is a set of elements, otherwise <c>false</c>.</p> </desc> </func> <func> - <name>size(Set) -> int()</name> + <name name="size" arity="1"/> <fsummary>Return the number of elements in a set</fsummary> - <type> - <v>Set = term()</v> - </type> <desc> - <p>Returns the number of elements in <c>Set</c>.</p> + <p>Returns the number of elements in <c><anno>Set</anno></c>.</p> </desc> </func> <func> - <name>to_list(Set) -> List</name> + <name name="to_list" arity="1"/> <fsummary>Convert an <c>Set</c>into a list</fsummary> - <type> - <v>Set = set()</v> - <v>List = [term()]</v> - </type> <desc> - <p>Returns the elements of <c>Set</c> as a list.</p> + <p>Returns the elements of <c><anno>Set</anno></c> as a list.</p> </desc> </func> <func> - <name>from_list(List) -> Set</name> + <name name="from_list" arity="1"/> <fsummary>Convert a list into an <c>Set</c></fsummary> - <type> - <v>List = [term()]</v> - <v>Set = set()</v> - </type> <desc> - <p>Returns an set of the elements in <c>List</c>.</p> + <p>Returns an set of the elements in <c><anno>List</anno></c>.</p> </desc> </func> <func> - <name>is_element(Element, Set) -> bool()</name> + <name name="is_element" arity="2"/> <fsummary>Test for membership of an <c>Set</c></fsummary> - <type> - <v>Element = term()</v> - <v>Set = set()</v> - </type> <desc> - <p>Returns <c>true</c> if <c>Element</c> is an element of - <c>Set</c>, otherwise <c>false</c>.</p> + <p>Returns <c>true</c> if <c><anno>Element</anno></c> is an element of + <c><anno>Set</anno></c>, otherwise <c>false</c>.</p> </desc> </func> <func> - <name>add_element(Element, Set1) -> Set2</name> + <name name="add_element" arity="2"/> <fsummary>Add an element to an <c>Set</c></fsummary> - <type> - <v>Element = term()</v> - <v>Set1 = Set2 = set()</v> - </type> <desc> - <p>Returns a new set formed from <c>Set1</c> with - <c>Element</c> inserted.</p> + <p>Returns a new set formed from <c><anno>Set1</anno></c> with + <c><anno>Element</anno></c> inserted.</p> </desc> </func> <func> - <name>del_element(Element, Set1) -> Set2</name> + <name name="del_element" arity="2"/> <fsummary>Remove an element from an <c>Set</c></fsummary> - <type> - <v>Element = term()</v> - <v>Set1 = Set2 = set()</v> - </type> <desc> - <p>Returns <c>Set1</c>, but with <c>Element</c> removed.</p> + <p>Returns <c><anno>Set1</anno></c>, but with <c><anno>Element</anno></c> removed.</p> </desc> </func> <func> - <name>union(Set1, Set2) -> Set3</name> + <name name="union" arity="2"/> <fsummary>Return the union of two <c>Sets</c></fsummary> - <type> - <v>Set1 = Set2 = Set3 = set()</v> - </type> <desc> - <p>Returns the merged (union) set of <c>Set1</c> and - <c>Set2</c>.</p> + <p>Returns the merged (union) set of <c><anno>Set1</anno></c> and + <c><anno>Set2</anno></c>.</p> </desc> </func> <func> - <name>union(SetList) -> Set</name> + <name name="union" arity="1"/> <fsummary>Return the union of a list of <c>Sets</c></fsummary> - <type> - <v>SetList = [set()]</v> - <v>Set = set()</v> - </type> <desc> <p>Returns the merged (union) set of the list of sets.</p> </desc> </func> <func> - <name>intersection(Set1, Set2) -> Set3</name> + <name name="intersection" arity="2"/> <fsummary>Return the intersection of two <c>Sets</c></fsummary> - <type> - <v>Set1 = Set2 = Set3 = set()</v> - </type> <desc> - <p>Returns the intersection of <c>Set1</c> and - <c>Set2</c>.</p> + <p>Returns the intersection of <c><anno>Set1</anno></c> and + <c><anno>Set2</anno></c>.</p> </desc> </func> <func> - <name>intersection(SetList) -> Set</name> + <name name="intersection" arity="1"/> <fsummary>Return the intersection of a list of <c>Sets</c></fsummary> - <type> - <v>SetList = [set()]</v> - <v>Set = set()</v> - </type> <desc> <p>Returns the intersection of the non-empty list of sets.</p> </desc> </func> <func> - <name>is_disjoint(Set1, Set2) -> bool()</name> + <name name="is_disjoint" arity="2"/> <fsummary>Check whether two <c>Sets</c> are disjoint</fsummary> - <type> - <v>Set1 = Set2 = set()</v> - </type> <desc> - <p>Returns <c>true</c> if <c>Set1</c> and - <c>Set2</c> are disjoint (have no elements in common), + <p>Returns <c>true</c> if <c><anno>Set1</anno></c> and + <c><anno>Set2</anno></c> are disjoint (have no elements in common), and <c>false</c> otherwise.</p> </desc> </func> <func> - <name>subtract(Set1, Set2) -> Set3</name> + <name name="subtract" arity="2"/> <fsummary>Return the difference of two <c>Sets</c></fsummary> - <type> - <v>Set1 = Set2 = Set3 = set()</v> - </type> <desc> - <p>Returns only the elements of <c>Set1</c> which are not - also elements of <c>Set2</c>.</p> + <p>Returns only the elements of <c><anno>Set1</anno></c> which are not + also elements of <c><anno>Set2</anno></c>.</p> </desc> </func> <func> - <name>is_subset(Set1, Set2) -> bool()</name> + <name name="is_subset" arity="2"/> <fsummary>Test for subset</fsummary> - <type> - <v>Set1 = Set2 = set()</v> - </type> <desc> - <p>Returns <c>true</c> when every element of <c>Set</c>1 is - also a member of <c>Set2</c>, otherwise <c>false</c>.</p> + <p>Returns <c>true</c> when every element of <c><anno>Set1</anno></c>1 is + also a member of <c><anno>Set2</anno></c>, otherwise <c>false</c>.</p> </desc> </func> <func> - <name>fold(Function, Acc0, Set) -> Acc1</name> + <name name="fold" arity="3"/> <fsummary>Fold over set elements</fsummary> - <type> - <v>Function = fun (E, AccIn) -> AccOut</v> - <v>Acc0 = Acc1 = AccIn = AccOut = term()</v> - <v>Set = set()</v> - </type> <desc> - <p>Fold <c>Function</c> over every element in <c>Set</c> + <p>Fold <c><anno>Function</anno></c> over every element in <c><anno>Set</anno></c> returning the final value of the accumulator.</p> </desc> </func> <func> - <name>filter(Pred, Set1) -> Set2</name> + <name name="filter" arity="2"/> <fsummary>Filter set elements</fsummary> - <type> - <v>Pred = fun (E) -> bool()</v> - <v>Set1 = Set2 = set()</v> - </type> <desc> - <p>Filter elements in <c>Set1</c> with boolean function - <c>Fun</c>.</p> + <p>Filter elements in <c><anno>Set1</anno></c> with boolean function + <c><anno>Pred</anno></c>.</p> </desc> </func> </funcs> diff --git a/lib/stdlib/doc/src/shell.xml b/lib/stdlib/doc/src/shell.xml index 73cc1b33bd..bc2120c37d 100644 --- a/lib/stdlib/doc/src/shell.xml +++ b/lib/stdlib/doc/src/shell.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2010</year> + <year>1996</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -763,26 +763,20 @@ loop(N) -> <funcs> <func> - <name>history(N) -> integer()</name> + <name name="history" arity="1"/> <fsummary>Sets the number of previous commands to keep</fsummary> - <type> - <v>N = integer()</v> - </type> <desc> <p>Sets the number of previous commands to keep in the - history list to <c>N</c>. The previous number is returned. + history list to <c><anno>N</anno></c>. The previous number is returned. The default number is 20.</p> </desc> </func> <func> - <name>results(N) -> integer()</name> + <name name="results" arity="1"/> <fsummary>Sets the number of previous results to keep</fsummary> - <type> - <v>N = integer()</v> - </type> <desc> <p>Sets the number of results from previous commands to keep in - the history list to <c>N</c>. The previous number is returned. + the history list to <c><anno>N</anno></c>. The previous number is returned. The default number is 20.</p> </desc> </func> @@ -790,7 +784,7 @@ loop(N) -> <name>catch_exception(Bool) -> Bool</name> <fsummary>Sets the exception handling of the shell</fsummary> <type> - <v>Bool = bool()</v> + <v>Bool = boolean()</v> </type> <desc> <p>Sets the exception handling of the evaluator process. The @@ -804,38 +798,29 @@ loop(N) -> </desc> </func> <func> - <name>prompt_func(PromptFunc) -> prompt_func()</name> + <name name="prompt_func" arity="1"/> <fsummary>Sets the shell prompt</fsummary> - <type> - <v>PromptFunc = prompt_func()</v> - <v>prompt_func() = default | {Mod, Func}</v> - <v>Mod = Func = atom()</v> - </type> <desc> <p>Sets the shell prompt function to <c>PromptFunc</c>. The previous prompt function is returned.</p> </desc> </func> <func> - <name>start_restricted(Module) -> ok | {error, Reason}</name> + <name name="start_restricted" arity="1"/> <fsummary>Exits a normal shell and starts a restricted shell.</fsummary> - <type> - <v>Module = atom()</v> - <v>Reason = atom()</v> - </type> <desc> <p>Exits a normal shell and starts a restricted - shell. <c>Module</c> specifies the callback module for the + shell. <c><anno>Module</anno></c> specifies the callback module for the functions <c>local_allowed/3</c> and <c>non_local_allowed/3</c>. The function is meant to be called from the shell.</p> <p>If the callback module cannot be loaded, an error tuple is - returned. The <c>Reason</c> in the error tuple is the one + returned. The <c><anno>Reason</anno></c> in the error tuple is the one returned by the code loader when trying to load the code of the callback module.</p> </desc> </func> <func> - <name>stop_restricted() -> ok</name> + <name name="stop_restricted" arity="0"/> <fsummary>Exits a restricted shell and starts a normal shell.</fsummary> <desc> <p>Exits a restricted shell and starts a normal shell. The function diff --git a/lib/stdlib/doc/src/shell_default.xml b/lib/stdlib/doc/src/shell_default.xml index 4f8cc6c5bb..f7e7d5388a 100644 --- a/lib/stdlib/doc/src/shell_default.xml +++ b/lib/stdlib/doc/src/shell_default.xml @@ -5,7 +5,7 @@ <header> <copyright> <year>1996</year> - <year>2007</year> + <year>2011</year> <holder>Ericsson AB, All Rights Reserved</holder> </copyright> <legalnotice> diff --git a/lib/stdlib/doc/src/slave.xml b/lib/stdlib/doc/src/slave.xml index 168d83f301..15b6711731 100644 --- a/lib/stdlib/doc/src/slave.xml +++ b/lib/stdlib/doc/src/slave.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2009</year> + <year>1996</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -56,22 +56,16 @@ </description> <funcs> <func> - <name>start(Host) -></name> - <name>start(Host, Name) -></name> - <name>start(Host, Name, Args) -> {ok, Node} | {error, Reason}</name> + <name name="start" arity="1"/> + <name name="start" arity="2"/> + <name name="start" arity="3"/> <fsummary>Start a slave node on a host</fsummary> - <type> - <v>Host = Name = atom()</v> - <v>Args = string()</v> - <v>Node = node()</v> - <v>Reason = timeout | no_rsh | {already_running, Node}</v> - </type> <desc> - <p>Starts a slave node on the host <c>Host</c>. Host names need + <p>Starts a slave node on the host <c><anno>Host</anno></c>. Host names need not necessarily be specified as fully qualified names; short names can also be used. This is the same condition that applies to names of distributed Erlang nodes.</p> - <p>The name of the started node will be <c>Name@Host</c>. If no + <p>The name of the started node will be <c><anno>Name</anno>@<anno>Host</anno></c>. If no name is provided, the name will be the same as the node which executes the call (with the exception of the host name part of the node name).</p> @@ -79,7 +73,7 @@ terminal I/O which is produced at the slave is automatically relayed to the master. Also, the file process will be relayed to the master.</p> - <p>The <c>Args</c> argument is used to set <c>erl</c> command + <p>The <c><anno>Args</anno></c> argument is used to set <c>erl</c> command line arguments. If provided, it is passed to the new node and can be used for a variety of purposes. See <seealso marker="erts:erl#erl">erl(1)</seealso></p> @@ -103,9 +97,9 @@ E = " -env DISPLAY " ++ net_adm:localhost() ++ ":0 ", Arg = "-mnesia_dir " ++ M ++ " -pa " ++ Dir ++ E, slave:start(H, Name, Arg).</code> - <p>If successful, the function returns <c>{ok, Node}</c>, - where <c>Node</c> is the name of the new node. Otherwise it - returns <c>{error, Reason}</c>, where <c>Reason</c> can be + <p>If successful, the function returns <c>{ok, <anno>Node</anno>}</c>, + where <c><anno>Node</anno></c> is the name of the new node. Otherwise it + returns <c>{error, <anno>Reason</anno>}</c>, where <c><anno>Reason</anno></c> can be one of:</p> <taglist> <tag><c>timeout</c></tag> @@ -123,24 +117,18 @@ slave:start(H, Name, Arg).</code> <item> <p>There is no <c>rsh</c> program on the computer.</p> </item> - <tag><c>{already_running, Node}</c></tag> + <tag><c>{already_running, <anno>Node</anno>}</c></tag> <item> - <p>A node with the name <c>Name@Host</c> already exists.</p> + <p>A node with the name <c><anno>Name</anno>@<anno>Host</anno></c> already exists.</p> </item> </taglist> </desc> </func> <func> - <name>start_link(Host) -></name> - <name>start_link(Host, Name) -></name> - <name>start_link(Host, Name, Args) -> {ok, Node} | {error, Reason}</name> + <name name="start_link" arity="1"/> + <name name="start_link" arity="2"/> + <name name="start_link" arity="3"/> <fsummary>Start and link to a slave node on a host</fsummary> - <type> - <v>Host = Name = atom()</v> - <v>Args = string()</v> - <v>Node = node()</v> - <v>Reason = timeout | no_rsh | {already_running, Node}</v> - </type> <desc> <p>Starts a slave node in the same way as <c>start/1,2,3</c>, except that the slave node is linked to the currently @@ -151,11 +139,8 @@ slave:start(H, Name, Arg).</code> </desc> </func> <func> - <name>stop(Node) -> ok</name> + <name name="stop" arity="1"/> <fsummary>Stop (kill) a node</fsummary> - <type> - <v>Node = node()</v> - </type> <desc> <p>Stops (kills) a node.</p> </desc> @@ -177,12 +162,8 @@ slave:start(H, Name, Arg).</code> </desc> </func> <func> - <name>pseudo(Master, ServerList) -> ok</name> + <name name="pseudo" arity="2"/> <fsummary>Start a number of pseudo servers</fsummary> - <type> - <v>Master = node()</v> - <v>ServerList = [atom()]</v> - </type> <desc> <p>Starts a number of pseudo servers. A pseudo server is a server with a registered name which does absolutely nothing @@ -198,16 +179,13 @@ rpc:call(N, slave, pseudo, [node(), [pxw_server]]).</code> </desc> </func> <func> - <name>relay(Pid)</name> + <name name="relay" arity="1"/> <fsummary>Run a pseudo server</fsummary> - <type> - <v>Pid = pid()</v> - </type> <desc> <p>Runs a pseudo server. This function never returns any value and the process which executes the function will receive messages. All messages received will simply be passed on to - <c>Pid</c>.</p> + <c><anno>Pid</anno></c>.</p> </desc> </func> </funcs> diff --git a/lib/stdlib/doc/src/sofs.xml b/lib/stdlib/doc/src/sofs.xml index 8c8ae51262..2e7768a1df 100644 --- a/lib/stdlib/doc/src/sofs.xml +++ b/lib/stdlib/doc/src/sofs.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>2001</year><year>2010</year> + <year>2001</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -181,10 +181,11 @@ the <marker id="canonical_map"></marker><em>canonical map</em> is the function that maps every element of X onto its equivalence class. </p> - <p>Relations as defined above (as sets of ordered pairs) will from - now on be referred to as <em>binary relations</em>. We call a - set of ordered sets (x[1], ..., x[n]) - an <em>(n-ary) relation</em>, and say that the relation is a subset of + <p><marker id="binary_relation"></marker>Relations as defined above + (as sets of ordered pairs) will from now on be referred to as + <em>binary relations</em>. We call a set of ordered sets + (x[1], ..., x[n]) an <marker id="n_ary_relation"></marker> + <em>(n-ary) relation</em>, and say that the relation is a subset of the <marker id="Cartesian_product_tuple"></marker>Cartesian product X[1] × ... × X[n] where x[i] is an element of X[i], 1 <= i <= n. @@ -210,7 +211,7 @@ X[i] to Y[i] and S a subset of X[1] × ... × X[n]. The <marker id="multiple_relative_product"></marker><em>multiple - relative product</em> of TR and and S is defined to be the + relative product</em> of TR and S is defined to be the set {z : z = ((x[1], ..., x[n]), (y[1],...,y[n])) for some (x[1], ..., x[n]) in S and for some (x[i], y[i]) in R[i], @@ -293,7 +294,8 @@ <c>partition_family/2</c>, <c>projection/2</c>, <c>restriction/3</c>, <c>substitution/2</c>) accept an Erlang function as a means to modify each element of a given unordered - set. Such a function, called SetFun in the following, can be + set. <marker id="set_fun"></marker>Such a function, called + SetFun in the following, can be specified as a functional object (fun), a tuple <c>{external, Fun}</c>, or an integer. If SetFun is specified as a fun, the fun is applied to each element of the @@ -337,34 +339,73 @@ fun(S) -> sofs:partition(1, S) end message when given badly formed arguments or sets the types of which are not compatible.</p> <p>When comparing external sets the operator <c>==/2</c> is used.</p> - <p><em>Types</em></p> - <pre> -anyset() = - an unordered, ordered or atomic set - -binary_relation() = - a binary relation - -bool() = true | false -external_set() = - an external set - -family() = - a family (of subsets) - -function() = - a function - -ordset() = - an ordered set - -relation() = - an n-ary relation - -set() = - an unordered set - -set_of_sets() = - an unordered set of set() - -set_fun() = integer() >= 1 - | {external, fun(external_set()) -> external_set()} - | fun(anyset()) -> anyset() -spec_fun() = {external, fun(external_set()) -> bool()} - | fun(anyset()) -> bool() -type() = - a type - </pre> </description> + <datatypes> + <datatype> + <name name="anyset"></name> + <desc><p>Any kind of set (also included are the atomic sets).</p></desc> + </datatype> + <datatype> + <name name="binary_relation"></name> + <desc><p>A <seealso marker="#binary_relation">binary + relation</seealso>.</p></desc> + </datatype> + <datatype> + <name name="external_set"></name> + <desc><p>An <seealso marker="#external_set">external + set</seealso>.</p></desc> + </datatype> + <datatype> + <name name="family"></name> + <desc><p>A <seealso marker="#family">family</seealso> (of subsets).</p> + </desc> + </datatype> + <datatype> + <name name="a_function"></name> + <desc><p>A <seealso marker="#function">function</seealso>.</p></desc> + </datatype> + <datatype> + <name name="ordset"></name> + <desc><p>An <seealso marker="#sets_definition">ordered + set</seealso>.</p></desc> + </datatype> + <datatype> + <name name="relation"></name> + <desc><p>An <seealso marker="#n_ary_relation">n-ary relation</seealso>. + </p></desc> + </datatype> + <datatype> + <name name="a_set"></name> + <desc><p>An <seealso marker="#sets_definition">unordered + set</seealso>.</p></desc> + </datatype> + <datatype> + <name name="set_of_sets"></name> + <desc><p>An <seealso marker="#sets_definition">unordered + set</seealso> of unordered sets.</p></desc> + </datatype> + <datatype> + <name name="set_fun"></name> + <desc><p>A <seealso marker="#set_fun">SetFun</seealso>.</p></desc> + </datatype> + <datatype> + <name name="spec_fun"></name> + </datatype> + <datatype> + <name name="type"></name> + <desc><p>A <seealso marker="#type">type</seealso>.</p></desc> + </datatype> + <datatype> + <!-- Parameterized opaque types are NYI: --> + <name><marker id="type-tuple_of">tuple_of(T)</marker></name> + <desc><p>A tuple where the elements are of type <c>T</c>.</p></desc> + </datatype> + </datatypes> <funcs> <func> - <name>a_function(Tuples [, Type]) -> Function</name> + <name name="a_function" arity="1"/> + <name name="a_function" arity="2"/> <fsummary>Create a function.</fsummary> - <type> - <v>Function = function()</v> - <v>Tuples = [tuple()]</v> - <v>Type = type()</v> - </type> <desc> <p>Creates a <seealso marker="#function">function</seealso>. <c>a_function(F, T)</c> is equivalent to @@ -375,16 +416,12 @@ type() = - a type - </pre> </desc> </func> <func> - <name>canonical_relation(SetOfSets) -> BinRel</name> + <name name="canonical_relation" arity="1"/> <fsummary>Return the canonical map.</fsummary> - <type> - <v>BinRel = binary_relation()</v> - <v>SetOfSets = set_of_sets()</v> - </type> <desc> <p>Returns the binary relation containing the elements - (E, Set) such that Set belongs to SetOfSets and E - belongs to Set. If SetOfSets is + (E, Set) such that Set belongs to <anno>SetOfSets</anno> and E + belongs to Set. If SetOfSets is a <seealso marker="#partition">partition</seealso> of a set X and R is the equivalence relation in X induced by SetOfSets, then the returned relation is @@ -398,14 +435,12 @@ type() = - a type - </pre> </desc> </func> <func> - <name>composite(Function1, Function2) -> Function3</name> + <name name="composite" arity="2"/> <fsummary>Return the composite of two functions.</fsummary> - <type> - <v>Function1 = Function2 = Function3 = function()</v> - </type> <desc> <p>Returns the <seealso marker="#composite">composite</seealso> of - the functions Function1 and Function2.</p> + the functions <anno>Function1</anno> and + <anno>Function2</anno>.</p> <pre> 1> <input>F1 = sofs:a_function([{a,1},{b,2},{c,2}]),</input> <input>F2 = sofs:a_function([{1,x},{2,y},{3,z}]),</input> @@ -415,14 +450,9 @@ type() = - a type - </pre> </desc> </func> <func> - <name>constant_function(Set, AnySet) -> Function</name> + <name name="constant_function" arity="2"/> <fsummary>Create the function that maps each element of a set onto another set.</fsummary> - <type> - <v>AnySet = anyset()</v> - <v>Function = function()</v> - <v>Set = set()</v> - </type> <desc> <p>Creates the <seealso marker="#function">function</seealso> that maps each element of the set Set onto AnySet.</p> @@ -435,14 +465,11 @@ type() = - a type - </pre> </desc> </func> <func> - <name>converse(BinRel1) -> BinRel2</name> + <name name="converse" arity="1"/> <fsummary>Return the converse of a binary relation.</fsummary> - <type> - <v>BinRel1 = BinRel2 = binary_relation()</v> - </type> <desc> <p>Returns the <seealso marker="#converse">converse</seealso> - of the binary relation BinRel1.</p> + of the binary relation <anno>BinRel1</anno>.</p> <pre> 1> <input>R1 = sofs:relation([{1,a},{2,b},{3,a}]),</input> <input>R2 = sofs:converse(R1),</input> @@ -451,31 +478,25 @@ type() = - a type - </pre> </desc> </func> <func> - <name>difference(Set1, Set2) -> Set3</name> + <name name="difference" arity="2"/> <fsummary>Return the difference of two sets.</fsummary> - <type> - <v>Set1 = Set2 = Set3 = set()</v> - </type> <desc> <p>Returns the <seealso marker="#difference">difference</seealso> of - the sets Set1 and Set2.</p> + the sets <anno>Set1</anno> and <anno>Set2</anno>.</p> </desc> </func> <func> - <name>digraph_to_family(Graph [, Type]) -> Family</name> + <name name="digraph_to_family" arity="1"/> + <name name="digraph_to_family" arity="2"/> <fsummary>Create a family from a directed graph.</fsummary> - <type> - <v>Graph = digraph() - see digraph(3) -</v> - <v>Family = family()</v> - <v>Type = type()</v> - </type> <desc> <p>Creates a <seealso marker="#family">family</seealso> from - the directed graph Graph. Each vertex a of Graph is + the directed graph <anno>Graph</anno>. Each vertex a of + <anno>Graph</anno> is represented by a pair (a, {b[1], ..., b[n]}) where the b[i]'s are the out-neighbours of a. If no type is explicitly given, [{atom, [atom]}] is used as type of - the family. It is assumed that Type is + the family. It is assumed that <anno>Type</anno> is a <seealso marker="#valid_type">valid type</seealso> of the external set of the family.</p> <p>If G is a directed graph, it holds that the vertices and @@ -484,15 +505,11 @@ type() = - a type - </pre> </desc> </func> <func> - <name>domain(BinRel) -> Set</name> + <name name="domain" arity="1"/> <fsummary>Return the domain of a binary relation.</fsummary> - <type> - <v>BinRel = binary_relation()</v> - <v>Set = set()</v> - </type> <desc> <p>Returns the <seealso marker="#domain">domain</seealso> of - the binary relation BinRel.</p> + the binary relation <anno>BinRel</anno>.</p> <pre> 1> <input>R = sofs:relation([{1,a},{1,b},{2,b},{2,c}]),</input> <input>S = sofs:domain(R),</input> @@ -501,16 +518,13 @@ type() = - a type - </pre> </desc> </func> <func> - <name>drestriction(BinRel1, Set) -> BinRel2</name> + <name name="drestriction" arity="2"/> <fsummary>Return a restriction of a binary relation.</fsummary> - <type> - <v>BinRel1 = BinRel2 = binary_relation()</v> - <v>Set = set()</v> - </type> <desc> - <p>Returns the difference between the binary relation BinRel1 + <p>Returns the difference between the binary relation + <anno>BinRel1</anno> and the <seealso marker="#restriction">restriction</seealso> - of BinRel1 to Set.</p> + of <anno>BinRel1</anno> to <anno>Set</anno>.</p> <pre> 1> <input>R1 = sofs:relation([{1,a},{2,b},{3,c}]),</input> <input>S = sofs:set([2,4,6]),</input> @@ -522,16 +536,13 @@ type() = - a type - </pre> </desc> </func> <func> - <name>drestriction(SetFun, Set1, Set2) -> Set3</name> + <name name="drestriction" arity="3"/> <fsummary>Return a restriction of a relation.</fsummary> - <type> - <v>SetFun = set_fun()</v> - <v>Set1 = Set2 = Set3 = set()</v> - </type> - <desc> - <p>Returns a subset of Set1 containing those elements that do - not yield an element in Set2 as the result of applying - SetFun.</p> + <desc> + <p>Returns a subset of <anno>Set1</anno> containing those elements + that do + not yield an element in <anno>Set2</anno> as the result of applying + <anno>SetFun</anno>.</p> <pre> 1> <input>SetFun = {external, fun({_A,B,C}) -> {B,C} end},</input> <input>R1 = sofs:relation([{a,aa,1},{b,bb,2},{c,cc,3}]),</input> @@ -544,11 +555,8 @@ type() = - a type - </pre> </desc> </func> <func> - <name>empty_set() -> Set</name> + <name name="empty_set" arity="0"/> <fsummary>Return the untyped empty set.</fsummary> - <type> - <v>Set = set()</v> - </type> <desc> <p>Returns the <seealso marker="#sets_definition">untyped empty set</seealso>. <c>empty_set()</c> is equivalent to @@ -556,19 +564,14 @@ type() = - a type - </pre> </desc> </func> <func> - <name>extension(BinRel1, Set, AnySet) -> BinRel2</name> + <name name="extension" arity="3"/> <fsummary>Extend the domain of a binary relation.</fsummary> - <type> - <v>AnySet = anyset()</v> - <v>BinRel1 = BinRel2 = binary_relation()</v> - <v>Set = set()</v> - </type> <desc> <p>Returns the <seealso marker="#extension">extension</seealso> of - BinRel1 such that - for each element E in Set that does not belong to the - <seealso marker="#domain">domain</seealso> of BinRel1, - BinRel2 contains the pair (E, AnySet).</p> + <anno>BinRel1</anno> such that + for each element E in <anno>Set</anno> that does not belong to the + <seealso marker="#domain">domain</seealso> of <anno>BinRel1</anno>, + <anno>BinRel2</anno> contains the pair (E, AnySet).</p> <pre> 1> <input>S = sofs:set([b,c]),</input> <input>A = sofs:empty_set(),</input> @@ -579,13 +582,9 @@ type() = - a type - </pre> </desc> </func> <func> - <name>family(Tuples [, Type]) -> Family</name> + <name name="family" arity="1"/> + <name name="family" arity="2"/> <fsummary>Create a family of subsets.</fsummary> - <type> - <v>Family = family()</v> - <v>Tuples = [tuple()]</v> - <v>Type = type()</v> - </type> <desc> <p>Creates a <seealso marker="#family">family of subsets</seealso>. <c>family(F, T)</c> is equivalent to @@ -596,18 +595,17 @@ type() = - a type - </pre> </desc> </func> <func> - <name>family_difference(Family1, Family2) -> Family3</name> + <name name="family_difference" arity="2"/> <fsummary>Return the difference of two families.</fsummary> - <type> - <v>Family1 = Family2 = Family3 = family()</v> - </type> <desc> - <p>If Family1 and Family2 + <p>If <anno>Family1</anno> and <anno>Family2</anno> are <seealso marker="#family">families</seealso>, then - Family3 is the family + <anno>Family3</anno> is the family such that the index set is equal to the index set of - Family1, and Family3[i] is the difference between Family1[i] - and Family2[i] if Family2 maps i, Family1[i] otherwise.</p> + <anno>Family1</anno>, and <anno>Family3</anno>[i] is the + difference between <anno>Family1</anno>[i] + and <anno>Family2</anno>[i] if <anno>Family2</anno> maps i, + <anno>Family1</anno>[i] otherwise.</p> <pre> 1> <input>F1 = sofs:family([{a,[1,2]},{b,[3,4]}]),</input> <input>F2 = sofs:family([{b,[4,5]},{c,[6,7]}]),</input> @@ -617,17 +615,18 @@ type() = - a type - </pre> </desc> </func> <func> - <name>family_domain(Family1) -> Family2</name> + <name name="family_domain" arity="1"/> <fsummary>Return a family of domains.</fsummary> - <type> - <v>Family1 = Family2 = family()</v> - </type> - <desc> - <p>If Family1 is a <seealso marker="#family">family</seealso> - and Family1[i] is a binary relation for every i in the index - set of Family1, then Family2 is the family with the same - index set as Family1 such that Family2[i] is - the <seealso marker="#domain">domain</seealso> of Family1[i].</p> + <desc> + <p>If <anno>Family1</anno> is + a <seealso marker="#family">family</seealso> + and <anno>Family1</anno>[i] is a binary relation for every i + in the index set of <anno>Family1</anno>, + then <anno>Family2</anno> is the family with the same index + set as <anno>Family1</anno> such + that <anno>Family2</anno>[i] is + the <seealso marker="#domain">domain</seealso> of + <anno>Family1</anno>[i].</p> <pre> 1> <input>FR = sofs:from_term([{a,[{1,a},{2,b},{3,c}]},{b,[]},{c,[{4,d},{5,e}]}]),</input> <input>F = sofs:family_domain(FR),</input> @@ -636,17 +635,18 @@ type() = - a type - </pre> </desc> </func> <func> - <name>family_field(Family1) -> Family2</name> + <name name="family_field" arity="1"/> <fsummary>Return a family of fields.</fsummary> - <type> - <v>Family1 = Family2 = family()</v> - </type> - <desc> - <p>If Family1 is a <seealso marker="#family">family</seealso> - and Family1[i] is a binary relation for every i in the index - set of Family1, then Family2 is the family with the same - index set as Family1 such that Family2[i] is - the <seealso marker="#field">field</seealso> of Family1[i].</p> + <desc> + <p>If <anno>Family1</anno> is + a <seealso marker="#family">family</seealso> + and <anno>Family1</anno>[i] is a binary relation for every i + in the index set of <anno>Family1</anno>, + then <anno>Family2</anno> is the family with the same index + set as <anno>Family1</anno> such + that <anno>Family2</anno>[i] is + the <seealso marker="#field">field</seealso> of + <anno>Family1</anno>[i].</p> <pre> 1> <input>FR = sofs:from_term([{a,[{1,a},{2,b},{3,c}]},{b,[]},{c,[{4,d},{5,e}]}]),</input> <input>F = sofs:family_field(FR),</input> @@ -657,21 +657,21 @@ type() = - a type - </pre> </desc> </func> <func> - <name>family_intersection(Family1) -> Family2</name> + <name name="family_intersection" arity="1"/> <fsummary>Return the intersection of a family of sets of sets.</fsummary> - <type> - <v>Family1 = Family2 = family()</v> - </type> - <desc> - <p>If Family1 is a <seealso marker="#family">family</seealso> - and Family1[i] is a set of sets for every i in the index set - of Family1, then Family2 is the family with the same index - set as Family1 such that Family2[i] is - the <seealso marker="#intersection_n">intersection</seealso> of - Family1[i].</p> - <p>If Family1[i] is an empty set for some i, then the process - exits with a <c>badarg</c> message.</p> + <desc> + <p>If <anno>Family1</anno> is + a <seealso marker="#family">family</seealso> + and <anno>Family1</anno>[i] is a set of sets for every i in + the index set of <anno>Family1</anno>, + then <anno>Family2</anno> is the family with the same index + set as <anno>Family1</anno> such + that <anno>Family2</anno>[i] is + the <seealso marker="#intersection_n">intersection</seealso> + of <anno>Family1</anno>[i].</p> + <p>If <anno>Family1</anno>[i] is an empty set for some i, then + the process exits with a <c>badarg</c> message.</p> <pre> 1> <input>F1 = sofs:from_term([{a,[[1,2,3],[2,3,4]]},{b,[[x,y,z],[x,y]]}]),</input> <input>F2 = sofs:family_intersection(F1),</input> @@ -680,17 +680,16 @@ type() = - a type - </pre> </desc> </func> <func> - <name>family_intersection(Family1, Family2) -> Family3</name> + <name name="family_intersection" arity="2"/> <fsummary>Return the intersection of two families.</fsummary> - <type> - <v>Family1 = Family2 = Family3 = family()</v> - </type> - <desc> - <p>If Family1 and Family2 - are <seealso marker="#family">families</seealso>, then Family3 - is the family such that the index set is the intersection of - Family1's and Family2's index sets, and Family3[i] is the - intersection of Family1[i] and Family2[i].</p> + <desc> + <p>If <anno>Family1</anno> and <anno>Family2</anno> + are <seealso marker="#family">families</seealso>, + then <anno>Family3</anno> is the family such that the index + set is the intersection of <anno>Family1</anno>'s and + <anno>Family2</anno>'s index sets, + and <anno>Family3</anno>[i] is the intersection of + <anno>Family1</anno>[i] and <anno>Family2</anno>[i].</p> <pre> 1> <input>F1 = sofs:family([{a,[1,2]},{b,[3,4]},{c,[5,6]}]),</input> <input>F2 = sofs:family([{b,[4,5]},{c,[7,8]},{d,[9,10]}]),</input> @@ -700,18 +699,16 @@ type() = - a type - </pre> </desc> </func> <func> - <name>family_projection(SetFun, Family1) -> Family2</name> + <name name="family_projection" arity="2"/> <fsummary>Return a family of modified subsets.</fsummary> - <type> - <v>SetFun = set_fun()</v> - <v>Family1 = Family2 = family()</v> - <v>Set = set()</v> - </type> - <desc> - <p>If Family1 is a <seealso marker="#family">family</seealso> - then Family2 is the family with the same index set as - Family1 such that Family2[i] is the result of calling SetFun - with Family1[i] as argument.</p> + <desc> + <p>If <anno>Family1</anno> is + a <seealso marker="#family">family</seealso> + then <anno>Family2</anno> is the family with the same index + set as <anno>Family1</anno> such + that <anno>Family2</anno>[i] is the result of + calling <anno>SetFun</anno> with <anno>Family1</anno>[i] as + argument.</p> <pre> 1> <input>F1 = sofs:from_term([{a,[[1,2],[2,3]]},{b,[[]]}]),</input> <input>F2 = sofs:family_projection({sofs, union}, F1),</input> @@ -720,17 +717,18 @@ type() = - a type - </pre> </desc> </func> <func> - <name>family_range(Family1) -> Family2</name> + <name name="family_range" arity="1"/> <fsummary>Return a family of ranges.</fsummary> - <type> - <v>Family1 = Family2 = family()</v> - </type> - <desc> - <p>If Family1 is a <seealso marker="#family">family</seealso> - and Family1[i] is a binary relation for every i in the index - set of Family1, then Family2 is the family with the same - index set as Family1 such that Family2[i] is - the <seealso marker="#range">range</seealso> of Family1[i].</p> + <desc> + <p>If <anno>Family1</anno> is + a <seealso marker="#family">family</seealso> + and <anno>Family1</anno>[i] is a binary relation for every i + in the index set of <anno>Family1</anno>, + then <anno>Family2</anno> is the family with the same index + set as <anno>Family1</anno> such + that <anno>Family2</anno>[i] is + the <seealso marker="#range">range</seealso> of + <anno>Family1</anno>[i].</p> <pre> 1> <input>FR = sofs:from_term([{a,[{1,a},{2,b},{3,c}]},{b,[]},{c,[{4,d},{5,e}]}]),</input> <input>F = sofs:family_range(FR),</input> @@ -739,22 +737,21 @@ type() = - a type - </pre> </desc> </func> <func> - <name>family_specification(Fun, Family1) -> Family2</name> + <name name="family_specification" arity="2"/> <fsummary>Select a subset of a family using a predicate.</fsummary> - <type> - <v>Fun = spec_fun()</v> - <v>Family1 = Family2 = family()</v> - </type> - <desc> - <p>If Family1 is a <seealso marker="#family">family</seealso>, - then Family2 is - the <seealso marker="#restriction">restriction</seealso> of - Family1 to those elements i of the - index set for which Fun applied to Family1[i] returns - <c>true</c>. If Fun is a tuple <c>{external, Fun2}</c>, - Fun2 is applied to - the <seealso marker="#external_set">external set</seealso> of - Family1[i], otherwise Fun is applied to Family1[i].</p> + <desc> + <p>If <anno>Family1</anno> is + a <seealso marker="#family">family</seealso>, + then <anno>Family2</anno> is + the <seealso marker="#restriction">restriction</seealso> of + <anno>Family1</anno> to those elements i of the index set + for which <anno>Fun</anno> applied + to <anno>Family1</anno>[i] returns + <c>true</c>. If <anno>Fun</anno> is a + tuple <c>{external, Fun2}</c>, Fun2 is applied to + the <seealso marker="#external_set">external set</seealso> + of <anno>Family1</anno>[i], otherwise <anno>Fun</anno> is + applied to <anno>Family1</anno>[i].</p> <pre> 1> <input>F1 = sofs:family([{a,[1,2,3]},{b,[1,2]},{c,[1]}]),</input> <input>SpecFun = fun(S) -> sofs:no_elements(S) =:= 2 end,</input> @@ -764,24 +761,22 @@ type() = - a type - </pre> </desc> </func> <func> - <name>family_to_digraph(Family [, GraphType]) -> Graph</name> + <name name="family_to_digraph" arity="1"/> + <name name="family_to_digraph" arity="2"/> <fsummary>Create a directed graph from a family.</fsummary> - <type> - <v>Graph = digraph()</v> - <v>Family = family()</v> - <v>GraphType = - see digraph(3) -</v> - </type> <desc> <p>Creates a directed graph from - the <seealso marker="#family">family</seealso> Family. For each - pair (a, {b[1], ..., b[n]}) of Family, the vertex + the <seealso marker="#family">family</seealso> <anno>Family</anno>. + For each pair (a, {b[1], ..., b[n]}) + of <anno>Family</anno>, the vertex a as well the edges (a, b[i]) for 1 <= i <= n are added to a newly created directed graph.</p> - <p>If no graph type is given, <c>digraph:new/1</c> is used for - creating the directed graph, otherwise the GraphType + <p>If no graph type is given <seealso marker="digraph#new/0"> + digraph:new/0</seealso> is used for + creating the directed graph, otherwise the <anno>GraphType</anno> argument is passed on as second argument to - <c>digraph:new/2</c>.</p> + <seealso marker="digraph#new/1">digraph:new/1</seealso>.</p> <p>It F is a family, it holds that F is a subset of <c>digraph_to_family(family_to_digraph(F), type(F))</c>. Equality holds if <c>union_of_family(F)</c> is a subset of @@ -791,17 +786,15 @@ type() = - a type - </pre> </desc> </func> <func> - <name>family_to_relation(Family) -> BinRel</name> + <name name="family_to_relation" arity="1"/> <fsummary>Create a binary relation from a family.</fsummary> - <type> - <v>Family = family()</v> - <v>BinRel = binary_relation()</v> - </type> - <desc> - <p>If Family is a <seealso marker="#family">family</seealso>, - then BinRel is the binary relation containing all pairs - (i, x) such that i belongs to the index set of Family - and x belongs to Family[i].</p> + <desc> + <p>If <anno>Family</anno> is + a <seealso marker="#family">family</seealso>, + then <anno>BinRel</anno> is the binary relation containing + all pairs (i, x) such that i belongs to the index set + of <anno>Family</anno> and x belongs + to <anno>Family</anno>[i].</p> <pre> 1> <input>F = sofs:family([{a,[]}, {b,[1]}, {c,[2,3]}]),</input> <input>R = sofs:family_to_relation(F),</input> @@ -810,17 +803,18 @@ type() = - a type - </pre> </desc> </func> <func> - <name>family_union(Family1) -> Family2</name> + <name name="family_union" arity="1"/> <fsummary>Return the union of a family of sets of sets.</fsummary> - <type> - <v>Family1 = Family2 = family()</v> - </type> - <desc> - <p>If Family1 is a <seealso marker="#family">family</seealso> - and Family1[i] is a set of sets for each i in the index set - of Family1, then Family2 is the family with the same index - set as Family1 such that Family2[i] is - the <seealso marker="#union_n">union</seealso> of Family1[i].</p> + <desc> + <p>If <anno>Family1</anno> is + a <seealso marker="#family">family</seealso> + and <anno>Family1</anno>[i] is a set of sets for each i in + the index set of <anno>Family1</anno>, + then <anno>Family2</anno> is the family with the same index + set as <anno>Family1</anno> such + that <anno>Family2</anno>[i] is + the <seealso marker="#union_n">union</seealso> of + <anno>Family1</anno>[i].</p> <pre> 1> <input>F1 = sofs:from_term([{a,[[1,2],[2,3]]},{b,[[]]}]),</input> <input>F2 = sofs:family_union(F1),</input> @@ -831,18 +825,18 @@ type() = - a type - </pre> </desc> </func> <func> - <name>family_union(Family1, Family2) -> Family3</name> + <name name="family_union" arity="2"/> <fsummary>Return the union of two families.</fsummary> - <type> - <v>Family1 = Family2 = Family3 = family()</v> - </type> - <desc> - <p>If Family1 and Family2 - are <seealso marker="#family">families</seealso>, then Family3 - is the family such that the index set is the union of Family1's - and Family2's index sets, and Family3[i] is the union of - Family1[i] and Family2[i] if both maps i, Family1[i] or - Family2[i] otherwise.</p> + <desc> + <p>If <anno>Family1</anno> and <anno>Family2</anno> + are <seealso marker="#family">families</seealso>, + then <anno>Family3</anno> is the family such that the index + set is the union of <anno>Family1</anno>'s + and <anno>Family2</anno>'s index sets, + and <anno>Family3</anno>[i] is the union + of <anno>Family1</anno>[i] and <anno>Family2</anno>[i] if + both maps i, <anno>Family1</anno>[i] + or <anno>Family2</anno>[i] otherwise.</p> <pre> 1> <input>F1 = sofs:family([{a,[1,2]},{b,[3,4]},{c,[5,6]}]),</input> <input>F2 = sofs:family([{b,[4,5]},{c,[7,8]},{d,[9,10]}]),</input> @@ -852,15 +846,11 @@ type() = - a type - </pre> </desc> </func> <func> - <name>field(BinRel) -> Set</name> + <name name="field" arity="1"/> <fsummary>Return the field of a binary relation.</fsummary> - <type> - <v>BinRel = binary_relation()</v> - <v>Set = set()</v> - </type> <desc> <p>Returns the <seealso marker="#field">field</seealso> of the - binary relation BinRel.</p> + binary relation <anno>BinRel</anno>.</p> <pre> 1> <input>R = sofs:relation([{1,a},{1,b},{2,b},{2,c}]),</input> <input>S = sofs:field(R),</input> @@ -871,31 +861,24 @@ type() = - a type - </pre> </desc> </func> <func> - <name>from_external(ExternalSet, Type) -> AnySet</name> + <name name="from_external" arity="2"/> <fsummary>Create a set.</fsummary> - <type> - <v>ExternalSet = external_set()</v> - <v>AnySet = anyset()</v> - <v>Type = type()</v> - </type> <desc> <p>Creates a set from the <seealso marker="#external_set">external - set</seealso> ExternalSet - and the <seealso marker="#type">type</seealso> Type. It is - assumed that Type is a <seealso marker="#valid_type">valid - type</seealso> of ExternalSet.</p> + set</seealso> <anno>ExternalSet</anno> + and the <seealso marker="#type">type</seealso> <anno>Type</anno>. + It is assumed that <anno>Type</anno> is + a <seealso marker="#valid_type">valid + type</seealso> of <anno>ExternalSet</anno>.</p> </desc> </func> <func> - <name>from_sets(ListOfSets) -> Set</name> + <name name="from_sets" arity="1" clause_i="1"/> <fsummary>Create a set out of a list of sets.</fsummary> - <type> - <v>Set = set()</v> - <v>ListOfSets = [anyset()]</v> - </type> <desc> <p>Returns the <seealso marker="#sets_definition">unordered - set</seealso> containing the sets of the list ListOfSets.</p> + set</seealso> containing the sets of the list + <anno>ListOfSets</anno>.</p> <pre> 1> <input>S1 = sofs:relation([{a,1},{b,2}]),</input> <input>S2 = sofs:relation([{x,3},{y,4}]),</input> @@ -905,38 +888,33 @@ type() = - a type - </pre> </desc> </func> <func> - <name>from_sets(TupleOfSets) -> Ordset</name> + <name name="from_sets" arity="1" clause_i="2"/> <fsummary>Create an ordered set out of a tuple of sets.</fsummary> - <type> - <v>Ordset = ordset()</v> - <v>TupleOfSets = tuple-of(anyset())</v> - </type> <desc> <p>Returns the <seealso marker="#sets_definition">ordered set</seealso> containing the sets of the non-empty tuple - TupleOfSets.</p> + <anno>TupleOfSets</anno>.</p> </desc> </func> <func> - <name>from_term(Term [, Type]) -> AnySet</name> + <name name="from_term" arity="1"/> + <name name="from_term" arity="2"/> <fsummary>Create a set.</fsummary> - <type> - <v>AnySet = anyset()</v> - <v>Term = term()</v> - <v>Type = type()</v> - </type> <desc> <p><marker id="from_term"></marker>Creates an element of <seealso marker="#sets_definition">Sets</seealso> by - traversing the term Term, sorting lists, removing duplicates and + traversing the term <anno>Term</anno>, sorting lists, + removing duplicates and deriving or verifying a <seealso marker="#valid_type">valid type</seealso> for the so obtained external set. An - explicitly given <seealso marker="#type">type</seealso> Type + explicitly given <seealso marker="#type">type</seealso> + <anno>Type</anno> can be used to limit the depth of the traversal; an atomic type stops the traversal, as demonstrated by this example where "foo" and {"foo"} are left unmodified:</p> <pre> -1> <input>S = sofs:from_term([{{"foo"},[1,1]},{"foo",[2,2]}], [{atom,[atom]}]),</input> +1> <input>S = sofs:from_term([{{"foo"},[1,1]},{"foo",[2,2]}], +[{atom,[atom]}]),</input> <input>sofs:to_external(S).</input> [{{"foo"},[1]},{"foo",[2]}]</pre> <p><c>from_term</c> can be used for creating atomic or ordered @@ -963,15 +941,12 @@ type() = - a type - </pre> </desc> </func> <func> - <name>image(BinRel, Set1) -> Set2</name> + <name name="image" arity="2"/> <fsummary>Return the image of a set under a binary relation.</fsummary> - <type> - <v>BinRel = binary_relation()</v> - <v>Set1 = Set2 = set()</v> - </type> <desc> <p>Returns the <seealso marker="#image">image</seealso> of the - set Set1 under the binary relation BinRel.</p> + set <anno>Set1</anno> under the binary + relation <anno>BinRel</anno>.</p> <pre> 1> <input>R = sofs:relation([{1,a},{2,b},{2,c},{3,d}]),</input> <input>S1 = sofs:set([1,2]),</input> @@ -981,42 +956,32 @@ type() = - a type - </pre> </desc> </func> <func> - <name>intersection(SetOfSets) -> Set</name> + <name name="intersection" arity="1"/> <fsummary>Return the intersection of a set of sets.</fsummary> - <type> - <v>Set = set()</v> - <v>SetOfSets = set_of_sets()</v> - </type> <desc> <p>Returns the <seealso marker="#intersection_n">intersection</seealso> of - the set of sets SetOfSets.</p> + the set of sets <anno>SetOfSets</anno>.</p> <p>Intersecting an empty set of sets exits the process with a <c>badarg</c> message.</p> </desc> </func> <func> - <name>intersection(Set1, Set2) -> Set3</name> + <name name="intersection" arity="2"/> <fsummary>Return the intersection of two sets.</fsummary> - <type> - <v>Set1 = Set2 = Set3 = set()</v> - </type> <desc> <p>Returns the <seealso marker="#intersection">intersection</seealso> of - Set1 and Set2.</p> + <anno>Set1</anno> and <anno>Set2</anno>.</p> </desc> </func> <func> - <name>intersection_of_family(Family) -> Set</name> + <name name="intersection_of_family" arity="1"/> <fsummary>Return the intersection of a family.</fsummary> - <type> - <v>Family = family()</v> - <v>Set = set()</v> - </type> <desc> <p>Returns the intersection of - the <seealso marker="#family">family</seealso> Family.</p> + the <seealso marker="#family">family</seealso> <anno>Family</anno>. + </p> <p>Intersecting an empty family exits the process with a <c>badarg</c> message.</p> <pre> @@ -1027,14 +992,11 @@ type() = - a type - </pre> </desc> </func> <func> - <name>inverse(Function1) -> Function2</name> + <name name="inverse" arity="1"/> <fsummary>Return the inverse of a function.</fsummary> - <type> - <v>Function1 = Function2 = function()</v> - </type> <desc> <p>Returns the <seealso marker="#inverse">inverse</seealso> - of the function Function1.</p> + of the function <anno>Function1</anno>.</p> <pre> 1> <input>R1 = sofs:relation([{1,a},{2,b},{3,c}]),</input> <input>R2 = sofs:inverse(R1),</input> @@ -1043,16 +1005,13 @@ type() = - a type - </pre> </desc> </func> <func> - <name>inverse_image(BinRel, Set1) -> Set2</name> + <name name="inverse_image" arity="2"/> <fsummary>Return the inverse image of a set under a binary relation.</fsummary> - <type> - <v>BinRel = binary_relation()</v> - <v>Set1 = Set2 = set()</v> - </type> <desc> - <p>Returns the <seealso marker="#inverse_image">inverse - image</seealso> of Set1 under the binary relation BinRel.</p> + <p>Returns the <seealso marker="#inverse_image">inverse + image</seealso> of <anno>Set1</anno> under the binary + relation <anno>BinRel</anno>.</p> <pre> 1> <input>R = sofs:relation([{1,a},{2,b},{2,c},{3,d}]),</input> <input>S1 = sofs:set([c,d,e]),</input> @@ -1062,52 +1021,38 @@ type() = - a type - </pre> </desc> </func> <func> - <name>is_a_function(BinRel) -> Bool</name> + <name name="is_a_function" arity="1"/> <fsummary>Test for a function.</fsummary> - <type> - <v>Bool = bool()</v> - <v>BinRel = binary_relation()</v> - </type> <desc> - <p>Returns <c>true</c> if the binary relation BinRel is a - <seealso marker="#function">function</seealso> or the + <p>Returns <c>true</c> if the binary relation <anno>BinRel</anno> + is a <seealso marker="#function">function</seealso> or the untyped empty set, <c>false</c> otherwise.</p> </desc> </func> <func> - <name>is_disjoint(Set1, Set2) -> Bool</name> + <name name="is_disjoint" arity="2"/> <fsummary>Test for disjoint sets.</fsummary> - <type> - <v>Bool = bool()</v> - <v>Set1 = Set2 = set()</v> - </type> <desc> - <p>Returns <c>true</c> if Set1 and Set2 + <p>Returns <c>true</c> if <anno>Set1</anno> + and <anno>Set2</anno> are <seealso marker="#disjoint">disjoint</seealso>, <c>false</c> otherwise.</p> </desc> </func> <func> - <name>is_empty_set(AnySet) -> Bool</name> + <name name="is_empty_set" arity="1"/> <fsummary>Test for an empty set.</fsummary> - <type> - <v>AnySet = anyset()</v> - <v>Bool = bool()</v> - </type> <desc> - <p>Returns <c>true</c> if Set is an empty unordered set, - <c>false</c> otherwise.</p> + <p>Returns <c>true</c> if <anno>AnySet</anno> is an empty + unordered set, <c>false</c> otherwise.</p> </desc> </func> <func> - <name>is_equal(AnySet1, AnySet2) -> Bool</name> + <name name="is_equal" arity="2"/> <fsummary>Test two sets for equality.</fsummary> - <type> - <v>AnySet1 = AnySet2 = anyset()</v> - <v>Bool = bool()</v> - </type> <desc> - <p>Returns <c>true</c> if the AnySet1 and AnySet2 + <p>Returns <c>true</c> if the <anno>AnySet1</anno> + and <anno>AnySet2</anno> are <seealso marker="#equal">equal</seealso>, <c>false</c> otherwise. This example shows that <c>==/2</c> is used when comparing sets for equality:</p> @@ -1119,67 +1064,49 @@ true</pre> </desc> </func> <func> - <name>is_set(AnySet) -> Bool</name> + <name name="is_set" arity="1"/> <fsummary>Test for an unordered set.</fsummary> - <type> - <v>AnySet = anyset()</v> - <v>Bool = bool()</v> - </type> <desc> - <p>Returns <c>true</c> if AnySet is + <p>Returns <c>true</c> if <anno>AnySet</anno> is an <seealso marker="#sets_definition">unordered set</seealso>, and - <c>false</c> if AnySet is an ordered set or an atomic set.</p> + <c>false</c> if <anno>AnySet</anno> is an ordered set or an + atomic set.</p> </desc> </func> <func> - <name>is_sofs_set(Term) -> Bool</name> + <name name="is_sofs_set" arity="1"/> <fsummary>Test for an unordered set.</fsummary> - <type> - <v>Bool = bool()</v> - <v>Term = term()</v> - </type> <desc> - <p>Returns <c>true</c> if Term is + <p>Returns <c>true</c> if <anno>Term</anno> is an <seealso marker="#sets_definition">unordered set</seealso>, an ordered set or an atomic set, <c>false</c> otherwise.</p> </desc> </func> <func> - <name>is_subset(Set1, Set2) -> Bool</name> + <name name="is_subset" arity="2"/> <fsummary>Test two sets for subset.</fsummary> - <type> - <v>Bool = bool()</v> - <v>Set1 = Set2 = set()</v> - </type> <desc> - <p>Returns <c>true</c> if Set1 is - a <seealso marker="#subset">subset</seealso> of Set2, <c>false</c> - otherwise.</p> + <p>Returns <c>true</c> if <anno>Set1</anno> is + a <seealso marker="#subset">subset</seealso> + of <anno>Set2</anno>, <c>false</c> otherwise.</p> </desc> </func> <func> - <name>is_type(Term) -> Bool</name> + <name name="is_type" arity="1"/> <fsummary>Test for a type.</fsummary> - <type> - <v>Bool = bool()</v> - <v>Term = term()</v> - </type> <desc> - <p>Returns <c>true</c> if the term Term is + <p>Returns <c>true</c> if the term <anno>Term</anno> is a <seealso marker="#type">type</seealso>.</p> </desc> </func> <func> - <name>join(Relation1, I, Relation2, J) -> Relation3</name> + <name name="join" arity="4"/> <fsummary>Return the join of two relations.</fsummary> - <type> - <v>Relation1 = Relation2 = Relation3 = relation()</v> - <v>I = J = integer() > 0</v> - </type> <desc> <p>Returns the <seealso marker="#natural_join">natural - join</seealso> of the relations Relation1 and Relation2 on - coordinates I and J.</p> + join</seealso> of the relations <anno>Relation1</anno> + and <anno>Relation2</anno> on coordinates <anno>I</anno> and + <anno>J</anno>.</p> <pre> 1> <input>R1 = sofs:relation([{a,x,1},{b,y,2}]),</input> <input>R2 = sofs:relation([{1,f,g},{1,h,i},{2,3,4}]),</input> @@ -1189,20 +1116,17 @@ true</pre> </desc> </func> <func> - <name>multiple_relative_product(TupleOfBinRels, BinRel1) -> BinRel2</name> + <name name="multiple_relative_product" arity="2"/> <fsummary>Return the multiple relative product of a tuple of binary relations and a relation.</fsummary> - <type> - <v>TupleOfBinRels = tuple-of(BinRel)</v> - <v>BinRel = BinRel1 = BinRel2 = binary_relation()</v> - </type> - <desc> - <p>If TupleOfBinRels is a non-empty tuple - {R[1], ..., R[n]} of binary relations and BinRel1 - is a binary relation, then BinRel2 is + <desc> + <p>If <anno>TupleOfBinRels</anno> is a non-empty tuple + {R[1], ..., R[n]} of binary relations + and <anno>BinRel1</anno> is a binary relation, + then <anno>BinRel2</anno> is the <seealso marker="#multiple_relative_product">multiple relative product</seealso> of the ordered set - (R[i], ..., R[n]) and BinRel1.</p> + (R[i], ..., R[n]) and <anno>BinRel1</anno>.</p> <pre> 1> <input>Ri = sofs:relation([{a,1},{b,2},{c,3}]),</input> <input>R = sofs:relation([{a,b},{b,c},{c,a}]),</input> @@ -1212,29 +1136,21 @@ true</pre> </desc> </func> <func> - <name>no_elements(ASet) -> NoElements</name> + <name name="no_elements" arity="1"/> <fsummary>Return the number of elements of a set.</fsummary> - <type> - <v>ASet = set() | ordset()</v> - <v>NoElements = integer() >= 0 </v> - </type> <desc> <p>Returns the number of elements of the ordered or unordered - set ASet.</p> + set <anno>ASet</anno>.</p> </desc> </func> <func> - <name>partition(SetOfSets) -> Partition</name> + <name name="partition" arity="1"/> <fsummary>Return the coarsest partition given a set of sets.</fsummary> - <type> - <v>SetOfSets = set_of_sets()</v> - <v>Partition = set()</v> - </type> <desc> <p>Returns the <seealso marker="#partition">partition</seealso> of - the union of the set of sets SetOfSets such that two + the union of the set of sets <anno>SetOfSets</anno> such that two elements are considered equal if they belong to the same - elements of SetOfSets.</p> + elements of <anno>SetOfSets</anno>.</p> <pre> 1> <input>Sets1 = sofs:from_term([[a,b,c],[d,e,f],[g,h,i]]),</input> <input>Sets2 = sofs:from_term([[b,c,d],[e,f,g],[h,i,j]]),</input> @@ -1244,17 +1160,12 @@ true</pre> </desc> </func> <func> - <name>partition(SetFun, Set) -> Partition</name> + <name name="partition" arity="2"/> <fsummary>Return a partition of a set.</fsummary> - <type> - <v>SetFun = set_fun()</v> - <v>Partition = set()</v> - <v>Set = set()</v> - </type> <desc> <p>Returns the <seealso marker="#partition">partition</seealso> of - Set such that two elements are considered equal if the - results of applying SetFun are equal.</p> + <anno>Set</anno> such that two elements are considered equal + if the results of applying <anno>SetFun</anno> are equal.</p> <pre> 1> <input>Ss = sofs:from_term([[a],[b],[c,d],[e,f]]),</input> <input>SetFun = fun(S) -> sofs:from_term(sofs:no_elements(S)) end,</input> @@ -1264,19 +1175,16 @@ true</pre> </desc> </func> <func> - <name>partition(SetFun, Set1, Set2) -> {Set3, Set4}</name> + <name name="partition" arity="3"/> <fsummary>Return a partition of a set.</fsummary> - <type> - <v>SetFun = set_fun()</v> - <v>Set1 = Set2 = Set3 = Set4 = set()</v> - </type> <desc> <p>Returns a pair of sets that, regarded as constituting a set, forms a <seealso marker="#partition">partition</seealso> of - Set1. If the - result of applying SetFun to an element of Set1 yields an - element in Set2, the element belongs to Set3, otherwise the - element belongs to Set4.</p> + <anno>Set1</anno>. If the + result of applying <anno>SetFun</anno> to an element + of <anno>Set1</anno> yields an element in <anno>Set2</anno>, + the element belongs to <anno>Set3</anno>, otherwise the + element belongs to <anno>Set4</anno>.</p> <pre> 1> <input>R1 = sofs:relation([{1,a},{2,b},{3,c}]),</input> <input>S = sofs:set([2,4,6]),</input> @@ -1289,21 +1197,17 @@ true</pre> </desc> </func> <func> - <name>partition_family(SetFun, Set) -> Family</name> + <name name="partition_family" arity="2"/> <fsummary>Return a family indexing a partition.</fsummary> - <type> - <v>Family = family()</v> - <v>SetFun = set_fun()</v> - <v>Set = set()</v> - </type> <desc> <p>Returns the <seealso marker="#family">family</seealso> - Family where the indexed set is - a <seealso marker="#partition">partition</seealso> of Set - such that two elements are considered equal if the results - of applying SetFun are the same value i. This i is the index - that Family maps onto - the <seealso marker="#equivalence_class">equivalence + <anno>Family</anno> where the indexed set is + a <seealso marker="#partition">partition</seealso> + of <anno>Set</anno> such that two elements are considered + equal if the results of applying <anno>SetFun</anno> are the + same value i. This i is the index that <anno>Family</anno> + maps onto + the <seealso marker="#equivalence_class">equivalence class</seealso>.</p> <pre> 1> <input>S = sofs:relation([{a,a,a,a},{a,a,b,b},{a,b,b,b}]),</input> @@ -1314,18 +1218,15 @@ true</pre> </desc> </func> <func> - <name>product(TupleOfSets) -> Relation</name> + <name name="product" arity="1"/> <fsummary>Return the Cartesian product of a tuple of sets.</fsummary> - <type> - <v>Relation = relation()</v> - <v>TupleOfSets = tuple-of(set())</v> - </type> <desc> <p>Returns the <seealso marker="#Cartesian_product_tuple">Cartesian product</seealso> of the non-empty tuple of sets - TupleOfSets. If (x[1], ..., x[n]) is an element of - the n-ary relation Relation, then x[i] is drawn from element - i of TupleOfSets.</p> + <anno>TupleOfSets</anno>. If (x[1], ..., x[n]) is + an element of the n-ary relation <anno>Relation</anno>, then + x[i] is drawn from element i + of <anno>TupleOfSets</anno>.</p> <pre> 1> <input>S1 = sofs:set([a,b]),</input> <input>S2 = sofs:set([1,2]),</input> @@ -1336,15 +1237,12 @@ true</pre> </desc> </func> <func> - <name>product(Set1, Set2) -> BinRel</name> + <name name="product" arity="2"/> <fsummary>Return the Cartesian product of two sets.</fsummary> - <type> - <v>BinRel = binary_relation()</v> - <v>Set1 = Set2 = set()</v> - </type> <desc> <p>Returns the <seealso marker="#Cartesian_product">Cartesian - product</seealso> of Set1 and Set2.</p> + product</seealso> of <anno>Set1</anno> + and <anno>Set2</anno>.</p> <pre> 1> <input>S1 = sofs:set([1,2]),</input> <input>S2 = sofs:set([a,b]),</input> @@ -1356,19 +1254,16 @@ true</pre> </desc> </func> <func> - <name>projection(SetFun, Set1) -> Set2</name> + <name name="projection" arity="2"/> <fsummary>Return a set of substituted elements.</fsummary> - <type> - <v>SetFun = set_fun()</v> - <v>Set1 = Set2 = set()</v> - </type> <desc> <p>Returns the set created by substituting each element of - Set1 by the result of applying SetFun to the element.</p> - <p>If SetFun is a number i >= 1 and Set1 is a - relation, then the returned set is - the <seealso marker="#projection">projection</seealso> of Set1 - onto coordinate i.</p> + <anno>Set1</anno> by the result of + applying <anno>SetFun</anno> to the element.</p> + <p>If <anno>SetFun</anno> is a number i >= 1 and + <anno>Set1</anno> is a relation, then the returned set is + the <seealso marker="#projection">projection</seealso> of + <anno>Set1</anno> onto coordinate i.</p> <pre> 1> <input>S1 = sofs:from_term([{1,a},{2,b},{3,a}]),</input> <input>S2 = sofs:projection(2, S1),</input> @@ -1377,15 +1272,11 @@ true</pre> </desc> </func> <func> - <name>range(BinRel) -> Set</name> + <name name="range" arity="1"/> <fsummary>Return the range of a binary relation.</fsummary> - <type> - <v>BinRel = binary_relation()</v> - <v>Set = set()</v> - </type> <desc> <p>Returns the <seealso marker="#range">range</seealso> of the - binary relation BinRel.</p> + binary relation <anno>BinRel</anno>.</p> <pre> 1> <input>R = sofs:relation([{1,a},{1,b},{2,b},{2,c}]),</input> <input>S = sofs:range(R),</input> @@ -1394,41 +1285,33 @@ true</pre> </desc> </func> <func> - <name>relation(Tuples [, Type]) -> Relation</name> + <name name="relation" arity="1"/> + <name name="relation" arity="2"/> <fsummary>Create a relation.</fsummary> - <type> - <v>N = integer()</v> - <v>Type = N | type()</v> - <v>Relation = relation()</v> - <v>Tuples = [tuple()]</v> - </type> <desc> <p>Creates a <seealso marker="#relation">relation</seealso>. <c>relation(R, T)</c> is equivalent to <c>from_term(R, T)</c>, if T is a <seealso marker="#type">type</seealso> and the result is a - relation. If Type is an integer N, then + relation. If <anno>Type</anno> is an integer N, then <c>[{atom, ..., atom}])</c>, where the size of the tuple is N, is used as type of the relation. If no type is - explicitly given, the size of the first tuple of Tuples is + explicitly given, the size of the first tuple of + <anno>Tuples</anno> is used if there is such a tuple. <c>relation([])</c> is equivalent to <c>relation([], 2)</c>.</p> </desc> </func> <func> - <name>relation_to_family(BinRel) -> Family</name> + <name name="relation_to_family" arity="1"/> <fsummary>Create a family from a binary relation.</fsummary> - <type> - <v>Family = family()</v> - <v>BinRel = binary_relation()</v> - </type> <desc> <p>Returns the <seealso marker="#family">family</seealso> - Family such that the index set is equal to + <anno>Family</anno> such that the index set is equal to the <seealso marker="#domain">domain</seealso> of the binary - relation BinRel, and Family[i] is + relation <anno>BinRel</anno>, and <anno>Family</anno>[i] is the <seealso marker="#image">image</seealso> of the set of i - under BinRel.</p> + under <anno>BinRel</anno>.</p> <pre> 1> <input>R = sofs:relation([{b,1},{c,2},{c,3}]),</input> <input>F = sofs:relation_to_family(R),</input> @@ -1437,63 +1320,57 @@ true</pre> </desc> </func> <func> - <name>relative_product(TupleOfBinRels [, BinRel1]) -> BinRel2</name> - <fsummary>Return the relative product of a tuple of binary relations + <name name="relative_product" arity="1"/> + <name name="relative_product" arity="2" clause_i="1"/> + <fsummary>Return the relative product of a list of binary relations and a binary relation.</fsummary> - <type> - <v>TupleOfBinRels = tuple-of(BinRel)</v> - <v>BinRel = BinRel1 = BinRel2 = binary_relation()</v> - </type> - <desc> - <p>If TupleOfBinRels is a non-empty tuple - {R[1], ..., R[n]} of binary relations and BinRel1 - is a binary relation, then BinRel2 is - the <seealso marker="#tuple_relative_product">relative - product</seealso> of the ordered set (R[i], ..., R[n]) - and BinRel1.</p> - <p>If BinRel1 is omitted, the relation of equality between the - elements of - the <seealso marker="#Cartesian_product_tuple">Cartesian - product</seealso> of the ranges of R[i], + <desc> + <p>If <anno>ListOfBinRels</anno> is a non-empty list + [R[1], ..., R[n]] of binary relations and + <anno>BinRel1</anno> + is a binary relation, then <anno>BinRel2</anno> is the <seealso + marker="#tuple_relative_product">relative product</seealso> + of the ordered set (R[i], ..., R[n]) and + <anno>BinRel1</anno>.</p> + <p>If <anno>BinRel1</anno> is omitted, the relation of equality + between the elements of + the <seealso marker="#Cartesian_product_tuple">Cartesian + product</seealso> of the ranges of R[i], range R[1] × ... × range R[n], is used instead (intuitively, nothing is "lost").</p> <pre> 1> <input>TR = sofs:relation([{1,a},{1,aa},{2,b}]),</input> <input>R1 = sofs:relation([{1,u},{2,v},{3,c}]),</input> -<input>R2 = sofs:relative_product({TR, R1}),</input> +<input>R2 = sofs:relative_product([TR, R1]),</input> <input>sofs:to_external(R2).</input> [{1,{a,u}},{1,{aa,u}},{2,{b,v}}]</pre> - <p>Note that <c>relative_product({R1}, R2)</c> is + <p>Note that <c>relative_product([R1], R2)</c> is different from <c>relative_product(R1, R2)</c>; the - tuple of one element is not identified with the element + list of one element is not identified with the element itself.</p> </desc> </func> <func> - <name>relative_product(BinRel1, BinRel2) -> BinRel3</name> + <name name="relative_product" arity="2" clause_i="2"/> <fsummary>Return the relative product of two binary relations.</fsummary> - <type> - <v>BinRel1 = BinRel2 = BinRel3 = binary_relation()</v> - </type> <desc> <p><marker id="relprod_impl"></marker>Returns the <seealso marker="#relative_product">relative - product</seealso> of the binary relations BinRel1 and BinRel2.</p> + product</seealso> of the binary relations <anno>BinRel1</anno> + and <anno>BinRel2</anno>.</p> </desc> </func> <func> - <name>relative_product1(BinRel1, BinRel2) -> BinRel3</name> + <name name="relative_product1" arity="2"/> <fsummary>Return the relative_product of two binary relations.</fsummary> - <type> - <v>BinRel1 = BinRel2 = BinRel3 = binary_relation()</v> - </type> <desc> <p>Returns the <seealso marker="#relative_product">relative product</seealso> of the <seealso marker="#converse">converse</seealso> of the - binary relation BinRel1 and the binary relation BinRel2.</p> + binary relation <anno>BinRel1</anno> and the binary + relation <anno>BinRel2</anno>.</p> <pre> 1> <input>R1 = sofs:relation([{1,a},{1,aa},{2,b}]),</input> <input>R2 = sofs:relation([{1,u},{2,v},{3,c}]),</input> @@ -1505,15 +1382,12 @@ true</pre> </desc> </func> <func> - <name>restriction(BinRel1, Set) -> BinRel2</name> + <name name="restriction" arity="2"/> <fsummary>Return a restriction of a binary relation.</fsummary> - <type> - <v>BinRel1 = BinRel2 = binary_relation()</v> - <v>Set = set()</v> - </type> <desc> <p>Returns the <seealso marker="#restriction">restriction</seealso> of - the binary relation BinRel1 to Set.</p> + the binary relation <anno>BinRel1</anno> + to <anno>Set</anno>.</p> <pre> 1> <input>R1 = sofs:relation([{1,a},{2,b},{3,c}]),</input> <input>S = sofs:set([1,2,4]),</input> @@ -1523,15 +1397,12 @@ true</pre> </desc> </func> <func> - <name>restriction(SetFun, Set1, Set2) -> Set3</name> + <name name="restriction" arity="3"/> <fsummary>Return a restriction of a set.</fsummary> - <type> - <v>SetFun = set_fun()</v> - <v>Set1 = Set2 = Set3 = set()</v> - </type> <desc> - <p>Returns a subset of Set1 containing those elements that - yield an element in Set2 as the result of applying SetFun.</p> + <p>Returns a subset of <anno>Set1</anno> containing those + elements that yield an element in <anno>Set2</anno> as the + result of applying <anno>SetFun</anno>.</p> <pre> 1> <input>S1 = sofs:relation([{1,a},{2,b},{3,c}]),</input> <input>S2 = sofs:set([b,c,d]),</input> @@ -1541,13 +1412,9 @@ true</pre> </desc> </func> <func> - <name>set(Terms [, Type]) -> Set</name> + <name name="set" arity="1"/> + <name name="set" arity="2"/> <fsummary>Create a set of atoms or any type of sets.</fsummary> - <type> - <v>Set = set()</v> - <v>Terms = [term()]</v> - <v>Type = type()</v> - </type> <desc> <p>Creates an <seealso marker="#sets_definition">unordered set</seealso>. <c>set(L, T)</c> is equivalent to @@ -1557,18 +1424,16 @@ true</pre> </desc> </func> <func> - <name>specification(Fun, Set1) -> Set2</name> + <name name="specification" arity="2"/> <fsummary>Select a subset using a predicate.</fsummary> - <type> - <v>Fun = spec_fun()</v> - <v>Set1 = Set2 = set()</v> - </type> <desc> - <p>Returns the set containing every element of Set1 for which - Fun returns <c>true</c>. If Fun is a tuple + <p>Returns the set containing every element + of <anno>Set1</anno> for which <anno>Fun</anno> + returns <c>true</c>. If <anno>Fun</anno> is a tuple <c>{external, Fun2}</c>, Fun2 is applied to the <seealso marker="#external_set">external set</seealso> of - each element, otherwise Fun is applied to each element.</p> + each element, otherwise <anno>Fun</anno> is applied to each + element.</p> <pre> 1> <input>R1 = sofs:relation([{a,1},{b,2}]),</input> <input>R2 = sofs:relation([{x,1},{x,2},{y,3}]),</input> @@ -1579,15 +1444,13 @@ true</pre> </desc> </func> <func> - <name>strict_relation(BinRel1) -> BinRel2</name> + <name name="strict_relation" arity="1"/> <fsummary>Return the strict relation corresponding to a given relation.</fsummary> - <type> - <v>BinRel1 = BinRel2 = binary_relation()</v> - </type> <desc> <p>Returns the <seealso marker="#strict_relation">strict - relation</seealso> corresponding to the binary relation BinRel1.</p> + relation</seealso> corresponding to the binary + relation <anno>BinRel1</anno>.</p> <pre> 1> <input>R1 = sofs:relation([{1,1},{1,2},{2,1},{2,2}]),</input> <input>R2 = sofs:strict_relation(R1),</input> @@ -1596,16 +1459,13 @@ true</pre> </desc> </func> <func> - <name>substitution(SetFun, Set1) -> Set2</name> + <name name="substitution" arity="2"/> <fsummary>Return a function with a given set as domain.</fsummary> - <type> - <v>SetFun = set_fun()</v> - <v>Set1 = Set2 = set()</v> - </type> - <desc> - <p>Returns a function, the domain of which is Set1. The value - of an element of the domain is the result of applying SetFun - to the element.</p> + <desc> + <p>Returns a function, the domain of which + is <anno>Set1</anno>. The value of an element of the domain + is the result of applying <anno>SetFun</anno> to the + element.</p> <pre> 1> <input>L = [{a,1},{b,2}].</input> [{a,1},{b,2}] @@ -1647,14 +1507,12 @@ images2(SetOfSets, BinRel) -> </desc> </func> <func> - <name>symdiff(Set1, Set2) -> Set3</name> + <name name="symdiff" arity="2"/> <fsummary>Return the symmetric difference of two sets.</fsummary> - <type> - <v>Set1 = Set2 = Set3 = set()</v> - </type> <desc> <p>Returns the <seealso marker="#symmetric_difference">symmetric - difference</seealso> (or the Boolean sum) of Set1 and Set2.</p> + difference</seealso> (or the Boolean sum) + of <anno>Set1</anno> and <anno>Set2</anno>.</p> <pre> 1> <input>S1 = sofs:set([1,2,3]),</input> <input>S2 = sofs:set([2,3,4]),</input> @@ -1664,88 +1522,67 @@ images2(SetOfSets, BinRel) -> </desc> </func> <func> - <name>symmetric_partition(Set1, Set2) -> {Set3, Set4, Set5}</name> + <name name="symmetric_partition" arity="2"/> <fsummary>Return a partition of two sets.</fsummary> - <type> - <v>Set1 = Set2 = Set3 = Set4 = Set5 = set()</v> - </type> <desc> - <p>Returns a triple of sets: Set3 contains the elements - of Set1 that do not belong to Set2; Set4 contains the - elements of Set1 that belong to Set2; Set5 contains the - elements of Set2 that do not belong to Set1.</p> + <p>Returns a triple of sets: <anno>Set3</anno> contains the + elements of <anno>Set1</anno> that do not belong + to <anno>Set2</anno>; <anno>Set4</anno> contains the + elements of <anno>Set1</anno> that belong + to <anno>Set2</anno>; <anno>Set5</anno> contains the + elements of <anno>Set2</anno> that do not belong + to <anno>Set1</anno>.</p> </desc> </func> <func> - <name>to_external(AnySet) -> ExternalSet</name> + <name name="to_external" arity="1"/> <fsummary>Return the elements of a set.</fsummary> - <type> - <v>ExternalSet = external_set()</v> - <v>AnySet = anyset()</v> - </type> <desc> <p>Returns the <seealso marker="#external_set">external set</seealso> of an atomic, ordered or unordered set.</p> </desc> </func> <func> - <name>to_sets(ASet) -> Sets</name> + <name name="to_sets" arity="1"/> <fsummary>Return a list or a tuple of the elements of set.</fsummary> - <type> - <v>ASet = set() | ordset()</v> - <v>Sets = tuple_of(AnySet) | [AnySet]</v> - </type> <desc> - <p>Returns the elements of the ordered set ASet as a tuple of - sets, and the elements of the unordered set ASet as a sorted - list of sets without duplicates.</p> + <p>Returns the elements of the ordered set <anno>ASet</anno> + as a tuple of sets, and the elements of the unordered set + <anno>ASet</anno> as a sorted list of sets without + duplicates.</p> </desc> </func> <func> - <name>type(AnySet) -> Type</name> + <name name="type" arity="1"/> <fsummary>Return the type of a set.</fsummary> - <type> - <v>AnySet = anyset()</v> - <v>Type = type()</v> - </type> <desc> <p>Returns the <seealso marker="#type">type</seealso> of an atomic, ordered or unordered set.</p> </desc> </func> <func> - <name>union(SetOfSets) -> Set</name> + <name name="union" arity="1"/> <fsummary>Return the union of a set of sets.</fsummary> - <type> - <v>Set = set()</v> - <v>SetOfSets = set_of_sets()</v> - </type> <desc> <p>Returns the <seealso marker="#union_n">union</seealso> of the - set of sets SetOfSets.</p> + set of sets <anno>SetOfSets</anno>.</p> </desc> </func> <func> - <name>union(Set1, Set2) -> Set3</name> + <name name="union" arity="2"/> <fsummary>Return the union of two sets.</fsummary> - <type> - <v>Set1 = Set2 = Set3 = set()</v> - </type> <desc> <p>Returns the <seealso marker="#union">union</seealso> of - Set1 and Set2.</p> + <anno>Set1</anno> and <anno>Set2</anno>.</p> </desc> </func> <func> - <name>union_of_family(Family) -> Set</name> + <name name="union_of_family" arity="1"/> <fsummary>Return the union of a family.</fsummary> - <type> - <v>Family = family()</v> - <v>Set = set()</v> - </type> <desc> <p>Returns the union of - the <seealso marker="#family">family</seealso> Family.</p> + the <seealso marker="#family">family</seealso> <anno>Family</anno>. + </p> <pre> 1> <input>F = sofs:family([{a,[0,2,4]},{b,[0,1,2]},{c,[2,3]}]),</input> <input>S = sofs:union_of_family(F),</input> @@ -1754,17 +1591,15 @@ images2(SetOfSets, BinRel) -> </desc> </func> <func> - <name>weak_relation(BinRel1) -> BinRel2</name> + <name name="weak_relation" arity="1"/> <fsummary>Return the weak relation corresponding to a given relation.</fsummary> - <type> - <v>BinRel1 = BinRel2 = binary_relation()</v> - </type> <desc> <p>Returns a subset S of the <seealso marker="#weak_relation">weak relation</seealso> W - corresponding to the binary relation BinRel1. Let F be the - <seealso marker="#field">field</seealso> of BinRel1. The + corresponding to the binary relation <anno>BinRel1</anno>. + Let F be the <seealso marker="#field">field</seealso> of + <anno>BinRel1</anno>. The subset S is defined so that x S y if x W y for some x in F and for some y in F.</p> <pre> diff --git a/lib/stdlib/doc/src/specs.xml b/lib/stdlib/doc/src/specs.xml new file mode 100644 index 0000000000..98338b5ec2 --- /dev/null +++ b/lib/stdlib/doc/src/specs.xml @@ -0,0 +1,63 @@ +<?xml version="1.0" encoding="latin1" ?> +<specs xmlns:xi="http://www.w3.org/2001/XInclude"> + <xi:include href="../specs/specs_array.xml"/> + <xi:include href="../specs/specs_base64.xml"/> + <xi:include href="../specs/specs_beam_lib.xml"/> + <xi:include href="../specs/specs_binary.xml"/> + <xi:include href="../specs/specs_c.xml"/> + <xi:include href="../specs/specs_calendar.xml"/> + <xi:include href="../specs/specs_dets.xml"/> + <xi:include href="../specs/specs_dict.xml"/> + <xi:include href="../specs/specs_digraph.xml"/> + <xi:include href="../specs/specs_digraph_utils.xml"/> + <xi:include href="../specs/specs_epp.xml"/> + <xi:include href="../specs/specs_erl_eval.xml"/> + <xi:include href="../specs/specs_erl_expand_records.xml"/> + <xi:include href="../specs/specs_erl_id_trans.xml"/> + <xi:include href="../specs/specs_erl_internal.xml"/> + <xi:include href="../specs/specs_erl_lint.xml"/> + <xi:include href="../specs/specs_erl_parse.xml"/> + <xi:include href="../specs/specs_erl_pp.xml"/> + <xi:include href="../specs/specs_erl_scan.xml"/> + <xi:include href="../specs/specs_erl_tar.xml"/> + <xi:include href="../specs/specs_ets.xml"/> + <xi:include href="../specs/specs_file_sorter.xml"/> + <xi:include href="../specs/specs_filelib.xml"/> + <xi:include href="../specs/specs_filename.xml"/> + <xi:include href="../specs/specs_gb_sets.xml"/> + <xi:include href="../specs/specs_gb_trees.xml"/> + <xi:include href="../specs/specs_gen_event.xml"/> + <xi:include href="../specs/specs_gen_fsm.xml"/> + <xi:include href="../specs/specs_gen_server.xml"/> + <xi:include href="../specs/specs_io.xml"/> + <xi:include href="../specs/specs_io_lib.xml"/> + <xi:include href="../specs/specs_lib.xml"/> + <xi:include href="../specs/specs_lists.xml"/> + <xi:include href="../specs/specs_log_mf_h.xml"/> + <xi:include href="../specs/specs_math.xml"/> + <xi:include href="../specs/specs_ms_transform.xml"/> + <xi:include href="../specs/specs_orddict.xml"/> + <xi:include href="../specs/specs_ordsets.xml"/> + <xi:include href="../specs/specs_pg.xml"/> + <xi:include href="../specs/specs_pool.xml"/> + <xi:include href="../specs/specs_proc_lib.xml"/> + <xi:include href="../specs/specs_proplists.xml"/> + <xi:include href="../specs/specs_qlc.xml"/> + <xi:include href="../specs/specs_queue.xml"/> + <xi:include href="../specs/specs_random.xml"/> + <xi:include href="../specs/specs_re.xml"/> + <xi:include href="../specs/specs_regexp.xml"/> + <xi:include href="../specs/specs_sets.xml"/> + <xi:include href="../specs/specs_shell.xml"/> + <xi:include href="../specs/specs_shell_default.xml"/> + <xi:include href="../specs/specs_slave.xml"/> + <xi:include href="../specs/specs_sofs.xml"/> + <xi:include href="../specs/specs_string.xml"/> + <xi:include href="../specs/specs_supervisor.xml"/> + <xi:include href="../specs/specs_supervisor_bridge.xml"/> + <xi:include href="../specs/specs_sys.xml"/> + <xi:include href="../specs/specs_timer.xml"/> + <xi:include href="../specs/specs_unicode.xml"/> + <xi:include href="../specs/specs_win32reg.xml"/> + <xi:include href="../specs/specs_zip.xml"/> +</specs> diff --git a/lib/stdlib/doc/src/string.xml b/lib/stdlib/doc/src/string.xml index de1b99a2d5..48867ffe72 100644 --- a/lib/stdlib/doc/src/string.xml +++ b/lib/stdlib/doc/src/string.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2009</year> + <year>1996</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -38,65 +38,46 @@ </description> <funcs> <func> - <name>len(String) -> Length</name> + <name name="len" arity="1"/> <fsummary>Return the length of a string</fsummary> - <type> - <v>String = string()</v> - <v>Length = integer()</v> - </type> <desc> <p>Returns the number of characters in the string.</p> </desc> </func> <func> - <name>equal(String1, String2) -> bool()</name> + <name name="equal" arity="2"/> <fsummary>Test string equality</fsummary> - <type> - <v>String1 = String2 = string()</v> - </type> <desc> <p>Tests whether two strings are equal. Returns <c>true</c> if they are, otherwise <c>false</c>.</p> </desc> </func> <func> - <name>concat(String1, String2) -> String3</name> + <name name="concat" arity="2"/> <fsummary>Concatenate two strings</fsummary> - <type> - <v>String1 = String2 = String3 = string()</v> - </type> <desc> <p>Concatenates two strings to form a new string. Returns the new string.</p> </desc> </func> <func> - <name>chr(String, Character) -> Index</name> - <name>rchr(String, Character) -> Index</name> + <name name="chr" arity="2"/> + <name name="rchr" arity="2"/> <fsummary>Return the index of the first/last occurrence of<c>Character</c>in <c>String</c></fsummary> - <type> - <v>String = string()</v> - <v>Character = char()</v> - <v>Index = integer()</v> - </type> <desc> <p>Returns the index of the first/last occurrence of - <c>Character</c> in <c>String</c>. <c>0</c> is returned if <c>Character</c> does not + <c><anno>Character</anno></c> in <c><anno>String</anno></c>. <c>0</c> is returned if <c><anno>Character</anno></c> does not occur.</p> </desc> </func> <func> - <name>str(String, SubString) -> Index</name> - <name>rstr(String, SubString) -> Index</name> + <name name="str" arity="2"/> + <name name="rstr" arity="2"/> <fsummary>Find the index of a substring</fsummary> - <type> - <v>String = SubString = string()</v> - <v>Index = integer()</v> - </type> <desc> <p>Returns the position where the first/last occurrence of - <c>SubString</c> begins in <c>String</c>. <c>0</c> is returned if <c>SubString</c> - does not exist in <c>String</c>. + <c><anno>SubString</anno></c> begins in <c><anno>String</anno></c>. <c>0</c> is returned if <c><anno>SubString</anno></c> + does not exist in <c><anno>String</anno></c>. For example:</p> <code type="none"> > string:str(" Hello Hello World World ", "Hello World"). @@ -104,17 +85,13 @@ </desc> </func> <func> - <name>span(String, Chars) -> Length </name> - <name>cspan(String, Chars) -> Length</name> + <name name="span" arity="2"/> + <name name="cspan" arity="2"/> <fsummary>Span characters at start of string</fsummary> - <type> - <v>String = Chars = string()</v> - <v>Length = integer()</v> - </type> <desc> <p>Returns the length of the maximum initial segment of - String, which consists entirely of characters from (not - from) Chars.</p> + <c><anno>String</anno></c>, which consists entirely of characters from (not + from) <c><anno>Chars</anno></c>.</p> <p>For example:</p> <code type="none"> > string:span("\t abcdef", " \t"). @@ -124,17 +101,13 @@ </desc> </func> <func> - <name>substr(String, Start) -> SubString</name> - <name>substr(String, Start, Length) -> Substring</name> + <name name="substr" arity="2"/> + <name name="substr" arity="3"/> <fsummary>Return a substring of <c>String</c></fsummary> - <type> - <v>String = SubString = string()</v> - <v>Start = Length = integer()</v> - </type> <desc> - <p>Returns a substring of <c>String</c>, starting at the - position <c>Start</c>, and ending at the end of the string or - at length <c>Length</c>.</p> + <p>Returns a substring of <c><anno>String</anno></c>, starting at the + position <c><anno>Start</anno></c>, and ending at the end of the string or + at length <c><anno>Length</anno></c>.</p> <p>For example:</p> <code type="none"> > substr("Hello World", 4, 5). @@ -142,15 +115,11 @@ </desc> </func> <func> - <name>tokens(String, SeparatorList) -> Tokens</name> + <name name="tokens" arity="2"/> <fsummary>Split string into tokens</fsummary> - <type> - <v>String = SeparatorList = string()</v> - <v>Tokens = [string()]</v> - </type> <desc> - <p>Returns a list of tokens in <c>String</c>, separated by the - characters in <c>SeparatorList</c>.</p> + <p>Returns a list of tokens in <c><anno>String</anno></c>, separated by the + characters in <c><anno>SeparatorList</anno></c>.</p> <p>For example:</p> <code type="none"> > tokens("abc defxxghix jkl", "x "). @@ -158,15 +127,11 @@ </desc> </func> <func> - <name>join(StringList, Separator) -> String</name> + <name name="join" arity="2"/> <fsummary>Join a list of strings with separator</fsummary> - <type> - <v>StringList = [string()]</v> - <v>Separator = string()</v> - </type> <desc> - <p>Returns a string with the elements of <c>StringList</c> - separated by the string in <c>Seperator</c>.</p> + <p>Returns a string with the elements of <c><anno>StringList</anno></c> + separated by the string in <c><anno>Separator</anno></c>.</p> <p>For example:</p> <code type="none"> > join(["one", "two", "three"], ", "). @@ -174,44 +139,30 @@ </desc> </func> <func> - <name>chars(Character, Number) -> String</name> - <name>chars(Character, Number, Tail) -> String</name> + <name name="chars" arity="2"/> + <name name="chars" arity="3"/> <fsummary>Returns a string consisting of numbers of characters</fsummary> - <type> - <v>Character = char()</v> - <v>Number = integer()</v> - <v>String = string()</v> - </type> <desc> - <p>Returns a string consisting of <c>Number</c> of characters - <c>Character</c>. Optionally, the string can end with the - string <c>Tail</c>.</p> + <p>Returns a string consisting of <c><anno>Number</anno></c> of characters + <c><anno>Character</anno></c>. Optionally, the string can end with the + string <c><anno>Tail</anno></c>.</p> </desc> </func> <func> - <name>copies(String, Number) -> Copies</name> + <name name="copies" arity="2"/> <fsummary>Copy a string</fsummary> - <type> - <v>String = Copies = string()</v> - <v>Number = integer()</v> - </type> <desc> - <p>Returns a string containing <c>String</c> repeated - <c>Number</c> times.</p> + <p>Returns a string containing <c><anno>String</anno></c> repeated + <c><anno>Number</anno></c> times.</p> </desc> </func> <func> - <name>words(String) -> Count</name> - <name>words(String, Character) -> Count</name> + <name name="words" arity="1"/> + <name name="words" arity="2"/> <fsummary>Count blank separated words</fsummary> - <type> - <v>String = string()</v> - <v>Character = char()</v> - <v>Count = integer()</v> - </type> <desc> - <p>Returns the number of words in <c>String</c>, separated by - blanks or <c>Character</c>.</p> + <p>Returns the number of words in <c><anno>String</anno></c>, separated by + blanks or <c><anno>Character</anno></c>.</p> <p>For example:</p> <code type="none"> > words(" Hello old boy!", $o). @@ -219,17 +170,12 @@ </desc> </func> <func> - <name>sub_word(String, Number) -> Word</name> - <name>sub_word(String, Number, Character) -> Word</name> + <name name="sub_word" arity="2"/> + <name name="sub_word" arity="3"/> <fsummary>Extract subword</fsummary> - <type> - <v>String = Word = string()</v> - <v>Character = char()</v> - <v>Number = integer()</v> - </type> <desc> - <p>Returns the word in position <c>Number</c> of <c>String</c>. - Words are separated by blanks or <c>Character</c>s.</p> + <p>Returns the word in position <c><anno>Number</anno></c> of <c><anno>String</anno></c>. + Words are separated by blanks or <c><anno>Character</anno></c>s.</p> <p>For example:</p> <code type="none"> > string:sub_word(" Hello old boy !",3,$o). @@ -237,19 +183,14 @@ </desc> </func> <func> - <name>strip(String) -> Stripped</name> - <name>strip(String, Direction) -> Stripped</name> - <name>strip(String, Direction, Character) -> Stripped</name> + <name name="strip" arity="1"/> + <name name="strip" arity="2"/> + <name name="strip" arity="3"/> <fsummary>Strip leading or trailing characters</fsummary> - <type> - <v>String = Stripped = string()</v> - <v>Direction = left | right | both</v> - <v>Character = char()</v> - </type> <desc> <p>Returns a string, where leading and/or trailing blanks or a - number of <c>Character</c> have been removed. - <c>Direction</c> can be <c>left</c>, <c>right</c>, or + number of <c><anno>Character</anno></c> have been removed. + <c><anno>Direction</anno></c> can be <c>left</c>, <c>right</c>, or <c>both</c> and indicates from which direction blanks are to be removed. The function <c>strip/1</c> is equivalent to <c>strip(String, both)</c>.</p> @@ -260,19 +201,14 @@ </desc> </func> <func> - <name>left(String, Number) -> Left</name> - <name>left(String, Number, Character) -> Left</name> + <name name="left" arity="2"/> + <name name="left" arity="3"/> <fsummary>Adjust left end of string</fsummary> - <type> - <v>String = Left = string()</v> - <v>Character = char</v> - <v>Number = integer()</v> - </type> <desc> - <p>Returns the <c>String</c> with the length adjusted in - accordance with <c>Number</c>. The left margin is - fixed. If the <c>length(String)</c> < <c>Number</c>, - <c>String</c> is padded with blanks or <c>Character</c>s.</p> + <p>Returns the <c><anno>String</anno></c> with the length adjusted in + accordance with <c><anno>Number</anno></c>. The left margin is + fixed. If the <c>length(<anno>String</anno>)</c> < <c><anno>Number</anno></c>, + <c><anno>String</anno></c> is padded with blanks or <c><anno>Character</anno></c>s.</p> <p>For example:</p> <code type="none"> > string:left("Hello",10,$.). @@ -280,19 +216,14 @@ </desc> </func> <func> - <name>right(String, Number) -> Right</name> - <name>right(String, Number, Character) -> Right</name> + <name name="right" arity="2"/> + <name name="right" arity="3"/> <fsummary>Adjust right end of string</fsummary> - <type> - <v>String = Right = string()</v> - <v>Character = char</v> - <v>Number = integer()</v> - </type> <desc> - <p>Returns the <c>String</c> with the length adjusted in - accordance with <c>Number</c>. The right margin is - fixed. If the length of <c>(String)</c> < <c>Number</c>, - <c>String</c> is padded with blanks or <c>Character</c>s.</p> + <p>Returns the <c><anno>String</anno></c> with the length adjusted in + accordance with <c><anno>Number</anno></c>. The right margin is + fixed. If the length of <c>(<anno>String</anno>)</c> < <c><anno>Number</anno></c>, + <c><anno>String</anno></c> is padded with blanks or <c><anno>Character</anno></c>s.</p> <p>For example:</p> <code type="none"> > string:right("Hello", 10, $.). @@ -300,32 +231,23 @@ </desc> </func> <func> - <name>centre(String, Number) -> Centered</name> - <name>centre(String, Number, Character) -> Centered</name> + <name name="centre" arity="2"/> + <name name="centre" arity="3"/> <fsummary>Center a string</fsummary> - <type> - <v>String = Centered = string()</v> - <v>Character = char</v> - <v>Number = integer()</v> - </type> <desc> - <p>Returns a string, where <c>String</c> is centred in the + <p>Returns a string, where <c><anno>String</anno></c> is centred in the string and surrounded by blanks or characters. The resulting - string will have the length <c>Number</c>.</p> + string will have the length <c><anno>Number</anno></c>.</p> </desc> </func> <func> - <name>sub_string(String, Start) -> SubString</name> - <name>sub_string(String, Start, Stop) -> SubString</name> + <name name="sub_string" arity="2"/> + <name name="sub_string" arity="3"/> <fsummary>Extract a substring</fsummary> - <type> - <v>String = SubString = string()</v> - <v>Start = Stop = integer()</v> - </type> <desc> - <p>Returns a substring of <c>String</c>, starting at the - position <c>Start</c> to the end of the string, or to and - including the <c>Stop</c> position.</p> + <p>Returns a substring of <c><anno>String</anno></c>, starting at the + position <c><anno>Start</anno></c> to the end of the string, or to and + including the <c><anno>Stop</anno></c> position.</p> <p>For example:</p> <code type="none"> sub_string("Hello World", 4, 8). @@ -383,15 +305,15 @@ sub_string("Hello World", 4, 8). </desc> </func> <func> - <name>to_lower(String) -> Result</name> - <name>to_lower(Char) -> CharResult</name> - <name>to_upper(String) -> Result</name> - <name>to_upper(Char) -> CharResult</name> + <name name="to_lower" arity="1" clause_i="1"/> + <name name="to_lower" arity="1" clause_i="2"/> + <name name="to_upper" arity="1" clause_i="1"/> + <name name="to_upper" arity="1" clause_i="2"/> <fsummary>Convert case of string (ISO/IEC 8859-1)</fsummary> - <type> - <v>String = Result = string()</v> - <v>Char = CharResult = integer()</v> - </type> + <type variable="String" name_i="1"/> + <type variable="Result" name_i="1"/> + <type variable="Char"/> + <type variable="CharResult"/> <desc> <p>The given string or character is case-converted. Note that the supported character set is ISO/IEC 8859-1 (a.k.a. Latin 1), diff --git a/lib/stdlib/doc/src/supervisor.xml b/lib/stdlib/doc/src/supervisor.xml index c696434d49..ec607d6e4c 100644 --- a/lib/stdlib/doc/src/supervisor.xml +++ b/lib/stdlib/doc/src/supervisor.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2010</year> + <year>1996</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -59,7 +59,6 @@ processes are started in order from left to right according to this list. When the supervisor terminates, it first terminates its child processes in reversed start order, from right to left.</p> - <p></p> <p>A supervisor can have one of the following <em>restart strategies</em>:</p> <list type="bulleted"> <item> @@ -83,11 +82,17 @@ supervisor, where all child processes are dynamically added instances of the same process type, i.e. running the same code.</p> - <p>The functions <c>terminate_child/2</c>, <c>delete_child/2</c> + <p>The functions <c>delete_child/2</c> and <c>restart_child/2</c> are invalid for <c>simple_one_for_one</c> supervisors and will return <c>{error,simple_one_for_one}</c> if the specified supervisor uses this restart strategy.</p> + <p>The function <c>terminate_child/2</c> can be used for + children under <c>simple_one_for_one</c> supervisors by + giving the child's <c>pid()</c> as the second argument. If + instead the child specification identifier is used, + <c>terminate_child/2</c> will return + <c>{error,simple_one_for_one}</c>.</p> </item> </list> <p>To prevent a supervisor from getting into an infinite loop of @@ -144,9 +149,12 @@ child_spec() = {Id,StartFunc,Restart,Shutdown,Type,Modules} <p><c>Restart</c> defines when a terminated child process should be restarted. A <c>permanent</c> child process should always be restarted, a <c>temporary</c> child process should - never be restarted and a <c>transient</c> child process - should be restarted only if it terminates abnormally, i.e. - with another exit reason than <c>normal</c>.</p> + never be restarted (even when the supervisor's restart strategy + is <c>rest_for_one</c> or <c>one_for_all</c> and a sibling's + death causes the temporary process to be terminated) and a + <c>transient</c> child process should be restarted only if + it terminates abnormally, i.e. with another exit reason + than <c>normal</c>.</p> </item> <item> <p><c>Shutdown</c> defines how a child process should be @@ -156,7 +164,7 @@ child_spec() = {Id,StartFunc,Restart,Shutdown,Type,Modules} the child process to terminate by calling <c>exit(Child,shutdown)</c> and then wait for an exit signal with reason <c>shutdown</c> back from the child process. If - no exit signal is received within the specified time, + no exit signal is received within the specified number of milliseconds, the child process is unconditionally terminated using <c>exit(Child,kill)</c>.</p> <p>If the child process is another supervisor, <c>Shutdown</c> @@ -193,51 +201,81 @@ child_spec() = {Id,StartFunc,Restart,Shutdown,Type,Modules} </item> </list> </section> + <datatypes> + <datatype> + <name name="child"/> + </datatype> + <datatype> + <name name="child_id"/> + <desc><p>Not a <c>pid()</c>.</p></desc> + </datatype> + <datatype> + <name name="child_spec"/> + </datatype> + <datatype> + <name name="mfargs"/> + <desc><p><c>A</c> (the argument list) has the value + <c>undefined</c> if <c>Restart</c> is <c>temporary</c>.</p> + </desc> + </datatype> + <datatype> + <name name="modules"/> + </datatype> + <datatype> + <name name="restart"/> + </datatype> + <datatype> + <name name="shutdown"/> + </datatype> + <datatype> + <name name="strategy"/> + </datatype> + <datatype> + <name name="sup_ref"/> + </datatype> + <datatype> + <name name="worker"/> + </datatype> + </datatypes> <funcs> <func> - <name>start_link(Module, Args) -> Result</name> - <name>start_link(SupName, Module, Args) -> Result</name> + <name name="start_link" arity="2"/> + <name name="start_link" arity="3"/> <fsummary>Create a supervisor process.</fsummary> - <type> - <v>SupName = {local,Name} | {global,Name}</v> - <v> Name = atom()</v> - <v>Module = atom()</v> - <v>Args = term()</v> - <v>Result = {ok,Pid} | ignore | {error,Error}</v> - <v> Pid = pid()</v> - <v> Error = {already_started,Pid}} | shutdown | term()</v> - </type> + <type name="startlink_ret"/> + <type name="startlink_err"/> + <type name="sup_name"/> <desc> <p>Creates a supervisor process as part of a supervision tree. The function will, among other things, ensure that the supervisor is linked to the calling process (its supervisor).</p> - <p>The created supervisor process calls <c>Module:init/1</c> to + <p>The created supervisor process calls <c><anno>Module</anno>:init/1</c> to find out about restart strategy, maximum restart frequency and child processes. To ensure a synchronized start-up procedure, <c>start_link/2,3</c> does not return until - <c>Module:init/1</c> has returned and all child processes + <c><anno>Module</anno>:init/1</c> has returned and all child processes have been started.</p> - <p>If <c>SupName={local,Name}</c> the supervisor is registered + <p>If <c><anno>SupName</anno>={local,Name}</c> the supervisor is registered locally as <c>Name</c> using <c>register/2</c>. If - <c>SupName={global,Name}</c> the supervisor is registered + <c><anno>SupName</anno>={global,Name}</c> the supervisor is registered globally as <c>Name</c> using <c>global:register_name/2</c>. If no name is provided, the supervisor is not registered.</p> - <p><c>Module</c> is the name of the callback module.</p> - <p><c>Args</c> is an arbitrary term which is passed as - the argument to <c>Module:init/1</c>.</p> + <p><c><anno>Module</anno></c> is the name of the callback module.</p> + <p><c><anno>Args</anno></c> is an arbitrary term which is passed as + the argument to <c><anno>Module</anno>:init/1</c>.</p> <p>If the supervisor and its child processes are successfully created (i.e. if all child process start functions return <c>{ok,Child}</c>, <c>{ok,Child,Info}</c>, or <c>ignore</c>) the function returns <c>{ok,Pid}</c>, where <c>Pid</c> is the pid of the supervisor. If there already exists a process - with the specified <c>SupName</c> the function returns + with the specified <c><anno>SupName</anno></c> the function returns <c>{error,{already_started,Pid}}</c>, where <c>Pid</c> is the pid of that process.</p> - <p>If <c>Module:init/1</c> returns <c>ignore</c>, this function + <p>If <c><anno>Module</anno>:init/1</c> returns <c>ignore</c>, this function returns <c>ignore</c> as well and the supervisor terminates with reason <c>normal</c>. - If <c>Module:init/1</c> fails or returns an incorrect value, + If <c><anno>Module</anno>:init/1</c> fails or returns an incorrect value, this function returns <c>{error,Term}</c> where <c>Term</c> is a term with information about the error, and the supervisor terminates with reason <c>Term</c>.</p> @@ -249,21 +287,15 @@ child_spec() = {Id,StartFunc,Restart,Shutdown,Type,Modules} </desc> </func> <func> - <name>start_child(SupRef, ChildSpec) -> Result</name> + <name name="start_child" arity="2"/> <fsummary>Dynamically add a child process to a supervisor.</fsummary> - <type> - <v>SupRef = Name | {Name,Node} | {global,Name} | pid()</v> - <v> Name = Node = atom()</v> - <v>ChildSpec = child_spec() | [term()]</v> - <v>Result = {ok,Child} | {ok,Child,Info} | {error,Error}</v> - <v> Child = pid() | undefined</v> - <v> Info = term()</v> - <v> Error = already_present | {already_started,Child} | term()</v> - </type> + <type name="child_spec"/> + <type name="startchild_ret"/> + <type name="startchild_err"/> <desc> <p>Dynamically adds a child specification to the supervisor - <c>SupRef</c> which starts the corresponding child process.</p> - <p><c>SupRef</c> can be:</p> + <c><anno>SupRef</anno></c> which starts the corresponding child process.</p> + <p><marker id="SupRef"><c><anno>SupRef</anno></c></marker> can be:</p> <list type="bulleted"> <item>the pid,</item> <item><c>Name</c>, if the supervisor is locally registered,</item> @@ -272,26 +304,26 @@ child_spec() = {Id,StartFunc,Restart,Shutdown,Type,Modules} <item><c>{global,Name}</c>, if the supervisor is globally registered.</item> </list> - <p><c>ChildSpec</c> should be a valid child specification + <p><c><anno>ChildSpec</anno></c> should be a valid child specification (unless the supervisor is a <c>simple_one_for_one</c> supervisor, see below). The child process will be started by using the start function as defined in the child specification.</p> <p>If the case of a <c>simple_one_for_one</c> supervisor, the child specification defined in <c>Module:init/1</c> will - be used and <c>ChildSpec</c> should instead be an arbitrary - list of terms <c>List</c>. The child process will then be - started by appending <c>List</c> to the existing start + be used and <c><anno>ChildSpec</anno></c> should instead be an arbitrary + list of terms <c><anno>List</anno></c>. The child process will then be + started by appending <c><anno>List</anno></c> to the existing start function arguments, i.e. by calling - <c>apply(M, F, A++List)</c> where <c>{M,F,A}</c> is the start + <c>apply(M, F, A++<anno>List</anno>)</c> where <c>{M,F,A}</c> is the start function defined in the child specification.</p> <p>If there already exists a child specification with - the specified <c>Id</c>, <c>ChildSpec</c> is discarded and + the specified <c><anno>Id</anno></c>, <c><anno>ChildSpec</anno></c> is discarded and the function returns <c>{error,already_present}</c> or - <c>{error,{already_started,Child}}</c>, depending on if + <c>{error,{already_started,<anno>Child</anno>}}</c>, depending on if the corresponding child process is running or not.</p> - <p>If the child process start function returns <c>{ok,Child}</c> - or <c>{ok,Child,Info}</c>, the child specification and pid is + <p>If the child process start function returns <c>{ok,<anno>Child</anno>}</c> + or <c>{ok,<anno>Child</anno>,<anno>Info</anno>}</c>, the child specification and pid is added to the supervisor and the function returns the same value.</p> <p>If the child process start function returns <c>ignore</c>, @@ -306,138 +338,114 @@ child_spec() = {Id,StartFunc,Restart,Shutdown,Type,Modules} </desc> </func> <func> - <name>terminate_child(SupRef, Id) -> Result</name> + <name name="terminate_child" arity="2"/> <fsummary>Terminate a child process belonging to a supervisor.</fsummary> - <type> - <v>SupRef = Name | {Name,Node} | {global,Name} | pid()</v> - <v> Name = Node = atom()</v> - <v>Id = term()</v> - <v>Result = ok | {error,Error}</v> - <v> Error = not_found | simple_one_for_one</v> - </type> <desc> - <p>Tells the supervisor <c>SupRef</c> to terminate the child - process corresponding to the child specification identified - by <c>Id</c>. The process, if there is one, is terminated but - the child specification is kept by the supervisor. This means - that the child process may be later be restarted by - the supervisor. The child process can also be restarted - explicitly by calling <c>restart_child/2</c>. Use - <c>delete_child/2</c> to remove the child specification.</p> - <p>See <c>start_child/2</c> for a description of - <c>SupRef</c>.</p> + <p>Tells the supervisor <c><anno>SupRef</anno></c> to terminate the given + child.</p> + <p>If the supervisor is not <c>simple_one_for_one</c>, + <c><anno>Id</anno></c> must be the child specification identifier. The + process, if there is one, is terminated but the child + specification is kept by the supervisor. The child process + may later be restarted by the supervisor. The child process + can also be restarted explicitly by calling + <c>restart_child/2</c>. Use <c>delete_child/2</c> to remove + the child specification.</p> + <p>If the supervisor is <c>simple_one_for_one</c>, <c><anno>Id</anno></c> + must be the child process' <c>pid()</c>. I the specified + process is alive, but is not a child of the given + supervisor, the function will return + <c>{error,not_found}</c>. If the child specification + identifier is given instead instead of a <c>pid()</c>, the + function will return <c>{error,simple_one_for_one}</c>.</p> <p>If successful, the function returns <c>ok</c>. If there is - no child specification with the specified <c>Id</c>, - the function returns <c>{error,not_found}</c>.</p> + no child specification with the specified <c><anno>Id</anno></c>, the + function returns <c>{error,not_found}</c>.</p> + <p>See <c>start_child/2</c> for a description of + <c><anno>SupRef</anno></c>.</p> </desc> </func> <func> - <name>delete_child(SupRef, Id) -> Result</name> + <name name="delete_child" arity="2"/> <fsummary>Delete a child specification from a supervisor.</fsummary> - <type> - <v>SupRef = Name | {Name,Node} | {global,Name} | pid()</v> - <v> Name = Node = atom()</v> - <v>Id = term()</v> - <v>Result = ok | {error,Error}</v> - <v> Error = running | not_found | simple_one_for_one</v> - </type> <desc> - <p>Tells the supervisor <c>SupRef</c> to delete the child - specification identified by <c>Id</c>. The corresponding child + <p>Tells the supervisor <c><anno>SupRef</anno></c> to delete the child + specification identified by <c><anno>Id</anno></c>. The corresponding child process must not be running, use <c>terminate_child/2</c> to terminate it.</p> - <p>See <c>start_child/2</c> for a description of <c>SupRef</c>.</p> + <p>See <seealso marker="#SupRef"><c>start_child/2</c></seealso> for a description of + <c>SupRef</c>.</p> <p>If successful, the function returns <c>ok</c>. If the child - specification identified by <c>Id</c> exists but + specification identified by <c><anno>Id</anno></c> exists but the corresponding child process is running, the function returns <c>{error,running}</c>. If the child specification - identified by <c>Id</c> does not exist, the function returns + identified by <c><anno>Id</anno></c> does not exist, the function returns <c>{error,not_found}</c>.</p> </desc> </func> <func> - <name>restart_child(SupRef, Id) -> Result</name> + <name name="restart_child" arity="2"/> <fsummary>Restart a terminated child process belonging to a supervisor.</fsummary> - <type> - <v>SupRef = Name | {Name,Node} | {global,Name} | pid()</v> - <v> Name = Node = atom()</v> - <v>Id = term()</v> - <v>Result = {ok,Child} | {ok,Child,Info} | {error,Error}</v> - <v> Child = pid() | undefined</v> - <v> Error = running | not_found | simple_one_for_one | term()</v> - </type> <desc> - <p>Tells the supervisor <c>SupRef</c> to restart a child process + <p>Tells the supervisor <c><anno>SupRef</anno></c> to restart a child process corresponding to the child specification identified by - <c>Id</c>. The child specification must exist and + <c><anno>Id</anno></c>. The child specification must exist and the corresponding child process must not be running.</p> - <p>See <c>start_child/2</c> for a description of <c>SupRef</c>.</p> - <p>If the child specification identified by <c>Id</c> does not + <p>See <seealso marker="#SupRef"><c>start_child/2</c></seealso> for a description of + <c>SupRef</c>.</p> + <p>If the child specification identified by <c><anno>Id</anno></c> does not exist, the function returns <c>{error,not_found}</c>. If the child specification exists but the corresponding process is already running, the function returns <c>{error,running}</c>.</p> - <p>If the child process start function returns <c>{ok,Child}</c> - or <c>{ok,Child,Info}</c>, the pid is added to the supervisor + <p>If the child process start function returns <c>{ok,<anno>Child</anno>}</c> + or <c>{ok,<anno>Child</anno>,<anno>Info</anno>}</c>, the pid is added to the supervisor and the function returns the same value.</p> <p>If the child process start function returns <c>ignore</c>, the pid remains set to <c>undefined</c> and the function returns <c>{ok,undefined}</c>.</p> <p>If the child process start function returns an error tuple or an erroneous value, or if it fails, the function returns - <c>{error,Error}</c> where <c>Error</c> is a term containing + <c>{error,<anno>Error</anno>}</c> where <c><anno>Error</anno></c> is a term containing information about the error.</p> </desc> </func> <func> - <name>which_children(SupRef) -> [{Id,Child,Type,Modules}]</name> + <name name="which_children" arity="1"/> <fsummary>Return information about all children specifications and child processes belonging to a supervisor.</fsummary> - <type> - <v>SupRef = Name | {Name,Node} | {global,Name} | pid()</v> - <v> Name = Node = atom()</v> - <v>Id = term() | undefined</v> - <v>Child = pid() | undefined</v> - <v>Type = worker | supervisor</v> - <v>Modules = [Module] | dynamic</v> - <v> Module = atom()</v> - </type> <desc> <p>Returns a newly created list with information about all child specifications and child processes belonging to - the supervisor <c>SupRef</c>.</p> + the supervisor <c><anno>SupRef</anno></c>.</p> <p>Note that calling this function when supervising a large number of children under low memory conditions can cause an out of memory exception.</p> - <p>See <c>start_child/2</c> for a description of <c>SupRef</c>.</p> + <p>See <seealso marker="#SupRef"><c>start_child/2</c></seealso> for a description of + <c>SupRef</c>.</p> <p>The information given for each child specification/process is:</p> <list type="bulleted"> <item> - <p><c>Id</c> - as defined in the child specification or + <p><c><anno>Id</anno></c> - as defined in the child specification or <c>undefined</c> in the case of a <c>simple_one_for_one</c> supervisor.</p> </item> <item> - <p><c>Child</c> - the pid of the corresponding child + <p><c><anno>Child</anno></c> - the pid of the corresponding child process, or <c>undefined</c> if there is no such process.</p> </item> <item> - <p><c>Type</c> - as defined in the child specification.</p> + <p><c><anno>Type</anno></c> - as defined in the child specification.</p> </item> <item> - <p><c>Modules</c> - as defined in the child specification.</p> + <p><c><anno>Modules</anno></c> - as defined in the child specification.</p> </item> </list> </desc> </func> <func> - <name>count_children(SupRef) -> PropListOfCounts</name> + <name name="count_children" arity="1"/> <fsummary>Return counts for the number of childspecs, active children, supervisors and workers.</fsummary> - <type> - <v>SupRef = Name | {Name,Node} | {global,Name} | pid()</v> - <v> Name = Node = atom()</v> - <v>PropListOfCounts = [{specs, ChildSpecCount}, {active, ActiveProcessCount}, {supervisors, ChildSupervisorCount}, {workers, ChildWorkerCount}]</v> - </type> <desc> <p>Returns a property list (see <c>proplists</c>) containing the counts for each of the following elements of the supervisor's @@ -464,17 +472,12 @@ child_spec() = {Id,StartFunc,Restart,Shutdown,Type,Modules} </desc> </func> <func> - <name>check_childspecs([ChildSpec]) -> Result</name> + <name name="check_childspecs" arity="1"/> <fsummary>Check if children specifications are syntactically correct.</fsummary> - <type> - <v>ChildSpec = child_spec()</v> - <v>Result = ok | {error,Error}</v> - <v> Error = term()</v> - </type> <desc> <p>This function takes a list of child specification as argument and returns <c>ok</c> if all of them are syntactically - correct, or <c>{error,Error}</c> otherwise.</p> + correct, or <c>{error,<anno>Error</anno>}</c> otherwise.</p> </desc> </func> </funcs> @@ -491,9 +494,9 @@ child_spec() = {Id,StartFunc,Restart,Shutdown,Type,Modules} <type> <v>Args = term()</v> <v>Result = {ok,{{RestartStrategy,MaxR,MaxT},[ChildSpec]}} | ignore</v> - <v> RestartStrategy = one_for_all | one_for_one | rest_for_one | simple_one_for_one</v> - <v> MaxR = MaxT = int()>=0</v> - <v> ChildSpec = child_spec()</v> + <v> RestartStrategy = <seealso marker="#type-strategy">strategy()</seealso></v> + <v> MaxR = MaxT = integer()>=0</v> + <v> ChildSpec = <seealso marker="#type-child_spec">child_spec()</seealso></v> </type> <desc> <p>Whenever a supervisor is started using diff --git a/lib/stdlib/doc/src/supervisor_bridge.xml b/lib/stdlib/doc/src/supervisor_bridge.xml index b334f57caf..c1a5e7947f 100644 --- a/lib/stdlib/doc/src/supervisor_bridge.xml +++ b/lib/stdlib/doc/src/supervisor_bridge.xml @@ -5,7 +5,7 @@ <header> <copyright> <year>1996</year> - <year>2007</year> + <year>2011</year> <holder>Ericsson AB, All Rights Reserved</holder> </copyright> <legalnotice> @@ -50,46 +50,37 @@ </description> <funcs> <func> - <name>start_link(Module, Args) -> Result</name> - <name>start_link(SupBridgeName, Module, Args) -> Result</name> + <name name="start_link" arity="2"/> + <name name="start_link" arity="3"/> <fsummary>Create a supervisor bridge process.</fsummary> - <type> - <v>SupBridgeName = {local,Name} | {global,Name}</v> - <v> Name = atom()</v> - <v>Module = atom()</v> - <v>Args = term()</v> - <v>Result = {ok,Pid} | ignore | {error,Error}</v> - <v> Pid = pid()</v> - <v> Error = {already_started,Pid} | term()</v> - </type> <desc> <p>Creates a supervisor_bridge process, linked to the calling - process, which calls <c>Module:init/1</c> to start the subsystem. + process, which calls <c><anno>Module</anno>:init/1</c> to start the subsystem. To ensure a synchronized start-up procedure, this function does - not return until <c>Module:init/1</c> has returned.</p> - <p>If <c>SupBridgeName={local,Name}</c> the supervisor_bridge is - registered locally as <c>Name</c> using <c>register/2</c>. - If <c>SupBridgeName={global,Name}</c> the supervisor_bridge is - registered globally as <c>Name</c> using + not return until <c><anno>Module</anno>:init/1</c> has returned.</p> + <p>If <c><anno>SupBridgeName</anno>={local,<anno>Name</anno>}</c> the supervisor_bridge is + registered locally as <c><anno>Name</anno></c> using <c>register/2</c>. + If <c><anno>SupBridgeName</anno>={global,<anno>Name</anno>}</c> the supervisor_bridge is + registered globally as <c><anno>Name</anno></c> using <c>global:register_name/2</c>. If no name is provided, the supervisor_bridge is not registered. If there already exists a process with the specified - <c>SupBridgeName</c> the function returns - <c>{error,{already_started,Pid}}</c>, where <c>Pid</c> is the pid + <c><anno>SupBridgeName</anno></c> the function returns + <c>{error,{already_started,<anno>Pid</anno>}}</c>, where <c><anno>Pid</anno></c> is the pid of that process.</p> - <p><c>Module</c> is the name of the callback module.</p> - <p><c>Args</c> is an arbitrary term which is passed as the argument - to <c>Module:init/1</c>.</p> + <p><c><anno>Module</anno></c> is the name of the callback module.</p> + <p><c><anno>Args</anno></c> is an arbitrary term which is passed as the argument + to <c><anno>Module</anno>:init/1</c>.</p> <p>If the supervisor_bridge and the subsystem are successfully - started the function returns <c>{ok,Pid}</c>, where <c>Pid</c> is + started the function returns <c>{ok,<anno>Pid</anno>}</c>, where <c><anno>Pid</anno></c> is is the pid of the supervisor_bridge.</p> - <p>If <c>Module:init/1</c> returns <c>ignore</c>, this function + <p>If <c><anno>Module</anno>:init/1</c> returns <c>ignore</c>, this function returns <c>ignore</c> as well and the supervisor_bridge terminates with reason <c>normal</c>. - If <c>Module:init/1</c> fails or returns an error tuple or an - incorrect value, this function returns <c>{error,Term}</c> where - <c>Term</c> is a term with information about the error, and - the supervisor_bridge terminates with reason <c>Term</c>.</p> + If <c><anno>Module</anno>:init/1</c> fails or returns an error tuple or an + incorrect value, this function returns <c>{error,<anno>Error</anno>r}</c> where + <c><anno>Error</anno></c> is a term with information about the error, and + the supervisor_bridge terminates with reason <c><anno>Error</anno></c>.</p> </desc> </func> </funcs> diff --git a/lib/stdlib/doc/src/sys.xml b/lib/stdlib/doc/src/sys.xml index 10ead62073..073faf2df2 100644 --- a/lib/stdlib/doc/src/sys.xml +++ b/lib/stdlib/doc/src/sys.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2009</year> + <year>1996</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -34,29 +34,17 @@ <module>sys</module> <modulesummary>A Functional Interface to System Messages</modulesummary> <description> - <p>This module contains functions for sending system messages used by programs, and messaged used for debugging purposes. + <p>This module contains functions for sending system messages used by programs, and messages used for debugging purposes. </p> <p>Functions used for implementation of processes should also understand system messages such as debugging messages and code change. These functions must be used to implement the use of system messages for a process; either directly, or through standard behaviours, such as <c>gen_server</c>.</p> - <p>The following types are used in the functions defined below:</p> - <list type="bulleted"> - <item> - <p><c>Name = pid() | atom() | {global, atom()}</c></p> - </item> - <item> - <p><c>Timeout = int() >= 0 | infinity</c></p> - </item> - <item> - <p><c>system_event() = {in, Msg} | {in, Msg, From} | {out, Msg, To} | term()</c></p> - </item> - </list> <p>The default timeout is 5000 ms, unless otherwise specified. The <c>timeout</c> defines the time period to wait for the process to respond to a request. If the process does not respond, the function evaluates <c>exit({timeout, {M, F, A}})</c>. </p> - <p>The functions make reference to a debug structure. + <p><marker id="dbg_opt"/>The functions make reference to a debug structure. The debug structure is a list of <c>dbg_opt()</c>. <c>dbg_opt()</c> is an internal data type used by the <c>handle_system_msg/6</c> function. No debugging is performed if it is an empty list. @@ -113,20 +101,31 @@ own system events. It is always up to the process itself to format these events.</p> </section> + <datatypes> + <datatype> + <name name="name"/> + </datatype> + <datatype> + <name name="system_event"/> + </datatype> + <datatype> + <name name="dbg_opt"/> + <desc><p>See <seealso marker="#dbg_opt">above</seealso>.</p></desc> + </datatype> + <datatype> + <name name="dbg_fun"/> + </datatype> + </datatypes> <funcs> <func> - <name>log(Name,Flag)</name> - <name>log(Name,Flag,Timeout) -> ok | {ok, [system_event()]}</name> + <name name="log" arity="2"/> + <name name="log" arity="3"/> <fsummary>Log system events in memory</fsummary> - <type> - <v>Flag = true | {true, N} | false | get | print</v> - <v>N = integer() > 0</v> - </type> <desc> <p>Turns the logging of system events On or Off. If On, a - maximum of <c>N</c> events are kept in the - debug structure (the default is 10). If <c>Flag</c> is <c>get</c>, a list of all - logged events is returned. If <c>Flag</c> is <c>print</c>, the + maximum of <c><anno>N</anno></c> events are kept in the + debug structure (the default is 10). If <c><anno>Flag</anno></c> is <c>get</c>, a list of all + logged events is returned. If <c><anno>Flag</anno></c> is <c>print</c>, the logged events are printed to <c>standard_io</c>. The events are formatted with a function that is defined by the process that generated the event (with a call to @@ -134,13 +133,9 @@ </desc> </func> <func> - <name>log_to_file(Name,Flag)</name> - <name>log_to_file(Name,Flag,Timeout) -> ok | {error, open_file}</name> + <name name="log_to_file" arity="2"/> + <name name="log_to_file" arity="3"/> <fsummary>Log system events to the specified file</fsummary> - <type> - <v>Flag = FileName | false</v> - <v>FileName = string()</v> - </type> <desc> <p>Enables or disables the logging of all system events in textual format to the file. The events are formatted with a function that is @@ -149,27 +144,18 @@ </desc> </func> <func> - <name>statistics(Name,Flag)</name> - <name>statistics(Name,Flag,Timeout) -> ok | {ok, Statistics} </name> + <name name="statistics" arity="2"/> + <name name="statistics" arity="3"/> <fsummary>Enable or disable the collections of statistics</fsummary> - <type> - <v>Flag = true | false | get</v> - <v>Statistics = [{start_time, {Date1, Time1}}, {current_time, {Date, Time2}}, {reductions, integer()}, {messages_in, integer()}, {messages_out, integer()}]</v> - <v>Date1 = Date2 = {Year, Month, Day}</v> - <v>Time1 = Time2 = {Hour, Min, Sec}</v> - </type> <desc> - <p>Enables or disables the collection of statistics. If <c>Flag</c> is + <p>Enables or disables the collection of statistics. If <c><anno>Flag</anno></c> is <c>get</c>, the statistical collection is returned.</p> </desc> </func> <func> - <name>trace(Name,Flag)</name> - <name>trace(Name,Flag,Timeout) -> void()</name> + <name name="trace" arity="2"/> + <name name="trace" arity="3"/> <fsummary>Print all system events on <c>standard_io</c></fsummary> - <type> - <v>Flag = boolean()</v> - </type> <desc> <p>Prints all system events on <c>standard_io</c>. The events are formatted with a function that is defined by the process that @@ -178,8 +164,8 @@ </desc> </func> <func> - <name>no_debug(Name)</name> - <name>no_debug(Name,Timeout) -> void()</name> + <name name="no_debug" arity="1"/> + <name name="no_debug" arity="2"/> <fsummary>Turn off debugging</fsummary> <desc> <p>Turns off all debugging for the process. This includes @@ -188,8 +174,8 @@ </desc> </func> <func> - <name>suspend(Name)</name> - <name>suspend(Name,Timeout) -> void()</name> + <name name="suspend" arity="1"/> + <name name="suspend" arity="2"/> <fsummary>Suspend the process</fsummary> <desc> <p>Suspends the process. When the process is suspended, it @@ -198,68 +184,48 @@ </desc> </func> <func> - <name>resume(Name)</name> - <name>resume(Name,Timeout) -> void()</name> + <name name="resume" arity="1"/> + <name name="resume" arity="2"/> <fsummary>Resume a suspended process</fsummary> <desc> <p>Resumes a suspended process.</p> </desc> </func> <func> - <name>change_code(Name, Module, OldVsn, Extra)</name> - <name>change_code(Name, Module, OldVsn, Extra, Timeout) -> ok | {error, Reason}</name> + <name name="change_code" arity="4"/> + <name name="change_code" arity="5"/> <fsummary>Send the code change system message to the process</fsummary> - <type> - <v>OldVsn = undefined | term()</v> - <v>Module = atom()</v> - <v>Extra = term()</v> - </type> <desc> <p>Tells the process to change code. The process must be - suspended to handle this message. The <c>Extra</c> argument is + suspended to handle this message. The <c><anno>Extra</anno></c> argument is reserved for each process to use as its own. The function - <c>Mod:system_code_change/4</c> is called. <c>OldVsn</c> is - the old version of the <c>Module</c>.</p> + <c><anno>Module</anno>:system_code_change/4</c> is called. <c><anno>OldVsn</anno></c> is + the old version of the <c><anno>Module</anno></c>.</p> </desc> </func> <func> - <name>get_status(Name)</name> - <name>get_status(Name,Timeout) -> {status, Pid, {module, Mod}, [PDict, SysState, Parent, Dbg, Misc]}</name> + <name name="get_status" arity="1"/> + <name name="get_status" arity="2"/> <fsummary>Get the status of the process</fsummary> - <type> - <v>PDict = [{Key, Value}]</v> - <v>SysState = running | suspended</v> - <v>Parent = pid()</v> - <v>Dbg = [dbg_opt()]</v> - <v>Misc = term()</v> - </type> <desc> <p>Gets the status of the process.</p> - <p>The value of <c>Misc</c> varies for different types of + <p>The value of <c><anno>Misc</anno></c> varies for different types of processes. For example, a <c>gen_server</c> process returns the callback module's state, and a <c>gen_fsm</c> process returns information such as its current state name. Callback modules for <c>gen_server</c> and <c>gen_fsm</c> can also - customise the value of <c>Misc</c> by exporting + customise the value of <c><anno>Misc</anno></c> by exporting a <c>format_status/2</c> function that contributes module-specific information; - see <seealso marker="gen_server#format_status/2">gen_server:format_status/2</seealso> - and <seealso marker="gen_fsm#format_status/2">gen_fsm:format_status/2</seealso> + see <seealso marker="gen_server#Module:format_status/2">gen_server:format_status/2</seealso> + and <seealso marker="gen_fsm#Module:format_status/2">gen_fsm:format_status/2</seealso> for more details.</p> </desc> </func> <func> - <name>install(Name,{Func,FuncState})</name> - <name>install(Name,{Func,FuncState},Timeout)</name> + <name name="install" arity="2"/> + <name name="install" arity="3"/> <fsummary>Install a debug function in the process</fsummary> - <type> - <v>Func = dbg_fun()</v> - <v>dbg_fun() = fun(FuncState, Event, ProcState) -> done | NewFuncState</v> - <v>FuncState = term()</v> - <v>Event = system_event()</v> - <v>ProcState = term()</v> - <v>NewFuncState = term()</v> - </type> <desc> <p>This function makes it possible to install other debug functions than the ones defined above. An example of such a @@ -267,22 +233,19 @@ special event and performs some action when the event is generated. This could, for example, be turning on low level tracing. </p> - <p><c>Func</c> is called whenever a system event is + <p><c><anno>Func</anno></c> is called whenever a system event is generated. This function should return <c>done</c>, or a new func state. In the first case, the function is removed. It is removed if the function fails.</p> </desc> </func> <func> - <name>remove(Name,Func)</name> - <name>remove(Name,Func,Timeout) -> void()</name> + <name name="remove" arity="2"/> + <name name="remove" arity="3"/> <fsummary>Remove a debug function from the process</fsummary> - <type> - <v>Func = dbg_fun()</v> - </type> <desc> <p>Removes a previously installed debug function from the - process. <c>Func</c> must be the same as previously + process. <c><anno>Func</anno></c> must be the same as previously installed.</p> </desc> </func> @@ -296,86 +259,65 @@ </section> <funcs> <func> - <name>debug_options(Options) -> [dbg_opt()]</name> + <name name="debug_options" arity="1"/> <fsummary>Convert a list of options to a debug structure</fsummary> - <type> - <v>Options = [Opt]</v> - <v>Opt = trace | log | statistics | {log_to_file, FileName} | {install, {Func, FuncState}}</v> - <v>Func = dbg_fun()</v> - <v>FuncState = term()</v> - </type> <desc> <p>This function can be used by a process that initiates a debug structure from a list of options. The values of the - <c>Opt</c> argument are the same as the corresponding + <c><anno>Opt</anno></c> argument are the same as the corresponding functions.</p> </desc> </func> <func> - <name>get_debug(Item,Debug,Default) -> term()</name> + <name name="get_debug" arity="3"/> <fsummary>Get the data associated with a debug option</fsummary> - <type> - <v>Item = log | statistics</v> - <v>Debug = [dbg_opt()]</v> - <v>Default = term()</v> - </type> <desc> - <p>This function gets the data associated with a debug option. <c>Default</c> is returned if the - <c>Item</c> is not found. Can be + <p>This function gets the data associated with a debug option. <c><anno>Default</anno></c> is returned if the + <c><anno>Item</anno></c> is not found. Can be used by the process to retrieve debug data for printing before it terminates.</p> </desc> </func> <func> - <name>handle_debug([dbg_opt()],FormFunc,Extra,Event) -> [dbg_opt()]</name> + <name name="handle_debug" arity="4"/> <fsummary>Generate a system event</fsummary> - <type> - <v>FormFunc = dbg_fun()</v> - <v>Extra = term()</v> - <v>Event = system_event()</v> - </type> <desc> - <p>This function is called by a process when it generates a system event. <c>FormFunc</c> is a formatting function which is called as <c>FormFunc(Device, Event, Extra)</c> in order to print the events, which is necessary if tracing is activated. <c>Extra</c> is any - extra information which the process needs in the format function, for example the name of the process.</p> + <p>This function is called by a process when it generates a + system event. <c><anno>FormFunc</anno></c> is a formatting + function which is called as <c><anno>FormFunc</anno>(Device, + <anno>Event</anno>, <anno>Extra</anno>)</c> in order to print + the events, which is necessary if tracing is activated. + <c><anno>Extra</anno></c> is any extra information which the + process needs in the format function, for example the name + of the process.</p> </desc> </func> <func> - <name>handle_system_msg(Msg,From,Parent,Module,Debug,Misc)</name> + <name name="handle_system_msg" arity="6"/> <fsummary>Take care of system messages</fsummary> - <type> - <v>Msg = term()</v> - <v>From = pid()</v> - <v>Parent = pid()</v> - <v>Module = atom()</v> - <v>Debug = [dbg_opt()]</v> - <v>Misc = term()</v> - </type> <desc> <p>This function is used by a process module that wishes to take care of system - messages. The process receives a <c>{system, From, Msg}</c> - message and passes the <c>Msg</c> and <c>From</c> to this + messages. The process receives a <c>{system, <anno>From</anno>, <anno>Msg</anno>}</c> + message and passes the <c><anno>Msg</anno></c> and <c><anno>From</anno></c> to this function. </p> <p>This function <em>never</em> returns. It calls the function - <c>Module:system_continue(Parent, NDebug, Misc)</c> where the + <c><anno>Module</anno>:system_continue(<anno>Parent</anno>, NDebug, <anno>Misc</anno>)</c> where the process continues the execution, or - <c>Module:system_terminate(Reason, Parent, Debug, Misc)</c> if - the process should terminate. The <c>Module</c> must export + <c><anno>Module</anno>:system_terminate(Reason, <anno>Parent</anno>, <anno>Debug</anno>, <anno>Misc</anno>)</c> if + the process should terminate. The <c><anno>Module</anno></c> must export <c>system_continue/3</c>, <c>system_terminate/4</c>, and <c>system_code_change/4</c> (see below). </p> - <p>The <c>Misc</c> argument can be used to save internal data + <p>The <c><anno>Misc</anno></c> argument can be used to save internal data in a process, for example its state. It is sent to - <c>Module:system_continue/3</c> or - <c>Module:system_terminate/4</c></p> + <c><anno>Module</anno>:system_continue/3</c> or + <c><anno>Module</anno>:system_terminate/4</c></p> </desc> </func> <func> - <name>print_log(Debug) -> void()</name> + <name name="print_log" arity="1"/> <fsummary>Print the logged events in the debug structure</fsummary> - <type> - <v>Debug = [dbg_opt()]</v> - </type> <desc> <p>Prints the logged system events in the debug structure using <c>FormFunc</c> as defined when the event was @@ -383,11 +325,11 @@ </desc> </func> <func> - <name>Mod:system_continue(Parent, Debug, Misc)</name> + <name>Mod:system_continue(Parent, Debug, Misc) -> none()</name> <fsummary>Called when the process should continue its execution</fsummary> <type> <v>Parent = pid()</v> - <v>Debug = [dbg_opt()]</v> + <v>Debug = [<seealso marker="#type-dbg_opt">dbg_opt()</seealso>]</v> <v>Misc = term()</v> </type> <desc> @@ -397,12 +339,12 @@ </desc> </func> <func> - <name>Mod:system_terminate(Reason, Parent, Debug, Misc)</name> + <name>Mod:system_terminate(Reason, Parent, Debug, Misc) -> none()</name> <fsummary>Called when the process should terminate</fsummary> <type> <v>Reason = term()</v> <v>Parent = pid()</v> - <v>Debug = [dbg_opt()]</v> + <v>Debug = [<seealso marker="#type-dbg_opt">dbg_opt()</seealso>]</v> <v>Misc = term()</v> </type> <desc> diff --git a/lib/stdlib/doc/src/timer.xml b/lib/stdlib/doc/src/timer.xml index 0b6807dd6c..0c1e398dc4 100644 --- a/lib/stdlib/doc/src/timer.xml +++ b/lib/stdlib/doc/src/timer.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2009</year> + <year>1996</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -49,9 +49,19 @@ as requested. </p> </description> + <datatypes> + <datatype> + <name name="time"/> + <desc><p>Time in milliseconds.</p></desc> + </datatype> + <datatype> + <name name="tref"/> + <desc><p>A timer reference.</p></desc> + </datatype> + </datatypes> <funcs> <func> - <name>start() -> ok</name> + <name name="start" arity="0"/> <fsummary>Start a global timer server (named <c>timer_server</c>).</fsummary> <desc> <p>Starts the timer server. Normally, the server does not need @@ -62,199 +72,185 @@ </desc> </func> <func> - <name>apply_after(Time, Module, Function, Arguments) -> {ok, Tref} | {error, Reason}</name> + <name name="apply_after" arity="4"/> <fsummary>Apply <c>Module:Function(Arguments)</c>after a specified <c>Time</c>.</fsummary> - <type> - <v>Time = integer() in Milliseconds</v> - <v>Module = Function = atom()</v> - <v>Arguments = [term()]</v> - </type> <desc> - <p>Evaluates <c>apply(M, F, A)</c> after <c>Time</c> amount of time - has elapsed. Returns <c>{ok, TRef}</c>, or <c>{error, Reason}</c>.</p> + <p>Evaluates <c>apply(<anno>Module</anno>, <anno>Function</anno>, <anno>Arguments</anno>)</c> after <c><anno>Time</anno></c> amount of time + has elapsed. Returns <c>{ok, <anno>TRef</anno>}</c>, or <c>{error, <anno>Reason</anno>}</c>.</p> </desc> </func> <func> - <name>send_after(Time, Pid, Message) -> {ok, TRef} | {error,Reason}</name> - <name>send_after(Time, Message) -> {ok, TRef} | {error,Reason}</name> + <name name="send_after" arity="2"/> + <name name="send_after" arity="3"/> <fsummary>Send <c>Message</c>to <c>Pid</c>after a specified <c>Time</c>.</fsummary> - <type> - <v>Time = integer() in Milliseconds</v> - <v>Pid = pid() | atom()</v> - <v>Message = term()</v> - <v>Result = {ok, TRef} | {error, Reason}</v> - </type> <desc> - <p></p> + <p> <taglist> <tag><c>send_after/3</c></tag> <item> - <p>Evaluates <c>Pid ! Message</c> after <c>Time</c> amount - of time has elapsed. (<c>Pid</c> can also be an atom of a - registered name.) Returns <c>{ok, TRef}</c>, or - <c>{error, Reason}</c>.</p> + <p>Evaluates <c><anno>Pid</anno> ! <anno>Message</anno></c> after <c><anno>Time</anno></c> amount + of time has elapsed. (<c><anno>Pid</anno></c> can also be an atom of a + registered name.) Returns <c>{ok, <anno>TRef</anno>}</c>, or + <c>{error, <anno>Reason</anno>}</c>.</p> </item> <tag><c>send_after/2</c></tag> <item> - <p>Same as <c>send_after(Time, self(), Message)</c>.</p> + <p>Same as <c>send_after(<anno>Time</anno>, self(), <anno>Message</anno>)</c>.</p> </item> </taglist> + </p> </desc> </func> <func> - <name>exit_after(Time, Pid, Reason1) -> {ok, TRef} | {error,Reason2}</name> - <name>exit_after(Time, Reason1) -> {ok, TRef} | {error,Reason2}</name> - <name>kill_after(Time, Pid)-> {ok, TRef} | {error,Reason2}</name> - <name>kill_after(Time) -> {ok, TRef} | {error,Reason2}</name> + <name name="kill_after" arity="1"/> + <name name="kill_after" arity="2"/> + <name name="exit_after" arity="2"/> + <name name="exit_after" arity="3"/> <fsummary>Send an exit signal with <c>Reason</c>after a specified <c>Time</c>.</fsummary> - <type> - <v>Time = integer() in milliseconds</v> - <v>Pid = pid() | atom()</v> - <v>Reason1 = Reason2 = term()</v> - </type> <desc> - <p></p> + <p> <taglist> <tag><c>exit_after/3</c></tag> <item> - <p>Send an exit signal with reason <c>Reason1</c> to Pid - <c>Pid</c>. Returns <c>{ok, TRef}</c>, or - <c>{error, Reason2}</c>.</p> + <p>Send an exit signal with reason <c><anno>Reason1</anno></c> to Pid + <c><anno>Pid</anno></c>. Returns <c>{ok, <anno>TRef</anno>}</c>, or + <c>{error, <anno>Reason2</anno>}</c>.</p> </item> <tag><c>exit_after/2</c></tag> <item> - <p>Same as <c>exit_after(Time, self(), Reason1)</c>. </p> + <p>Same as <c>exit_after(<anno>Time</anno>, self(), <anno>Reason1</anno>)</c>. </p> </item> <tag><c>kill_after/2</c></tag> <item> - <p>Same as <c>exit_after(Time, Pid, kill)</c>. </p> + <p>Same as <c>exit_after(<anno>Time</anno>, <anno>Pid</anno>, kill)</c>. </p> </item> <tag><c>kill_after/1</c></tag> <item> - <p>Same as <c>exit_after(Time, self(), kill)</c>. </p> + <p>Same as <c>exit_after(<anno>Time</anno>, self(), kill)</c>. </p> </item> </taglist> + </p> </desc> </func> <func> - <name>apply_interval(Time, Module, Function, Arguments) -> {ok, TRef} | {error, Reason}</name> + <name name="apply_interval" arity="4"/> <fsummary>Evaluate <c>Module:Function(Arguments)</c>repeatedly at intervals of <c>Time</c>.</fsummary> - <type> - <v>Time = integer() in milliseconds</v> - <v>Module = Function = atom()</v> - <v>Arguments = [term()]</v> - </type> <desc> - <p>Evaluates <c>apply(Module, Function, Arguments)</c> repeatedly at - intervals of <c>Time</c>. Returns <c>{ok, TRef}</c>, or - <c>{error, Reason}</c>.</p> + <p>Evaluates <c>apply(<anno>Module</anno>, <anno>Function</anno>, <anno>Arguments</anno>)</c> repeatedly at + intervals of <c><anno>Time</anno></c>. Returns <c>{ok, <anno>TRef</anno>}</c>, or + <c>{error, <anno>Reason</anno>}</c>.</p> </desc> </func> <func> - <name>send_interval(Time, Pid, Message) -> {ok, TRef} | {error, Reason}</name> - <name>send_interval(Time, Message) -> {ok, TRef} | {error, Reason}</name> + <name name="send_interval" arity="2"/> + <name name="send_interval" arity="3"/> <fsummary>Send <c>Message</c>repeatedly at intervals of <c>Time</c>.</fsummary> - <type> - <v>Time = integer() in milliseconds</v> - <v>Pid = pid() | atom()</v> - <v>Message = term()</v> - <v>Reason = term()</v> - </type> <desc> - <p></p> + <p> <taglist> <tag><c>send_interval/3</c></tag> <item> - <p>Evaluates <c>Pid ! Message</c> repeatedly after <c>Time</c> - amount of time has elapsed. (<c>Pid</c> can also be an atom of - a registered name.) Returns <c>{ok, TRef}</c> or - <c>{error, Reason}</c>.</p> + <p>Evaluates <c><anno>Pid</anno> ! <anno>Message</anno></c> repeatedly after <c><anno>Time</anno></c> + amount of time has elapsed. (<c><anno>Pid</anno></c> can also be an atom of + a registered name.) Returns <c>{ok, <anno>TRef</anno>}</c> or + <c>{error, <anno>Reason</anno>}</c>.</p> </item> <tag><c>send_interval/2</c></tag> <item> - <p>Same as <c>send_interval(Time, self(), Message)</c>.</p> + <p>Same as <c>send_interval(<anno>Time</anno>, self(), <anno>Message</anno>)</c>.</p> </item> </taglist> + </p> </desc> </func> <func> - <name>cancel(TRef) -> {ok, cancel} | {error, Reason}</name> + <name name="cancel" arity="1"/> <fsummary>Cancel a previously requested timeout identified by <c>TRef</c>.</fsummary> <desc> - <p>Cancels a previously requested timeout. <c>TRef</c> is a unique + <p>Cancels a previously requested timeout. <c><anno>TRef</anno></c> is a unique timer reference returned by the timer function in question. Returns - <c>{ok, cancel}</c>, or <c>{error, Reason}</c> when <c>TRef</c> + <c>{ok, cancel}</c>, or <c>{error, <anno>Reason</anno>}</c> when <c><anno>TRef</anno></c> is not a timer reference.</p> </desc> </func> <func> - <name>sleep(Time) -> ok</name> + <name name="sleep" arity="1"/> <fsummary>Suspend the calling process for <c>Time</c>amount of milliseconds.</fsummary> - <type> - <v>Time = integer() in milliseconds or the atom infinity</v> - </type> <desc> - <p>Suspends the process calling this function for <c>Time</c> amount + <p>Suspends the process calling this function for <c><anno>Time</anno></c> amount of milliseconds and then returns <c>ok</c>, or suspend the process - forever if <c>Time</c> is the atom <c>infinity</c>. Naturally, this + forever if <c><anno>Time</anno></c> is the atom <c>infinity</c>. Naturally, this function does <em>not</em> return immediately.</p> </desc> </func> <func> - <name>tc(Module, Function, Arguments) -> {Time, Value}</name> - <fsummary>Measure the real time it takes to evaluate <c>apply(Module, Function, Arguments)</c></fsummary> - <type> - <v>Module = Function = atom()</v> - <v>Arguments = [term()]</v> - <v>Time = integer() in microseconds</v> - <v>Value = term()</v> - </type> + <name name="tc" arity="1"/> + <name name="tc" arity="2"/> + <name name="tc" arity="3"/> + <fsummary>Measure the real time it takes to evaluate <c>apply(Module, + Function, Arguments)</c> or <c>apply(Fun, Arguments)</c></fsummary> + <type_desc variable="Time">In microseconds</type_desc> <desc> - <p>Evaluates <c>apply(Module, Function, Arguments)</c> and measures - the elapsed real time. Returns <c>{Time, Value}</c>, where - <c>Time</c> is the elapsed real time in <em>microseconds</em>, - and <c>Value</c> is what is returned from the apply.</p> + <p> + <taglist> + <tag><c>tc/3</c></tag> + <item> + <p>Evaluates <c>apply(<anno>Module</anno>, <anno>Function</anno>, <anno>Arguments</anno>)</c> and measures + the elapsed real time as reported by <c>os:timestamp/0</c>. + Returns <c>{<anno>Time</anno>, <anno>Value</anno>}</c>, where + <c><anno>Time</anno></c> is the elapsed real time in <em>microseconds</em>, + and <c><anno>Value</anno></c> is what is returned from the apply.</p> + </item> + <tag><c>tc/2</c></tag> + <item> + <p>Evaluates <c>apply(<anno>Fun</anno>, <anno>Arguments</anno>)</c>. Otherwise works + like <c>tc/3</c>.</p> + </item> + <tag><c>tc/1</c></tag> + <item> + <p>Evaluates <c><anno>Fun</anno>()</c>. Otherwise works like <c>tc/2</c>.</p> + </item> + + </taglist> + </p> </desc> </func> <func> - <name>now_diff(T2, T1) -> Tdiff</name> + <name name="now_diff" arity="2"/> <fsummary>Calculate time difference between <c>now/0</c>timestamps</fsummary> - <type> - <v>T1 = T2 = {MegaSecs, Secs, MicroSecs}</v> - <v>Tdiff = MegaSecs = Secs = MicroSecs = integer()</v> - </type> + <type_desc variable="Tdiff">In microseconds</type_desc> <desc> - <p>Calculates the time difference <c>Tdiff = T2 - T1</c> in - <em>microseconds</em>, where <c>T1</c> and <c>T2</c> probably + <p>Calculates the time difference <c><anno>Tdiff</anno> = <anno>T2</anno> - <anno>T1</anno></c> in + <em>microseconds</em>, where <c><anno>T1</anno></c> and <c><anno>T2</anno></c> probably are timestamp tuples returned from <c>erlang:now/0</c>.</p> </desc> </func> <func> - <name>seconds(Seconds) -> Milliseconds</name> + <name name="seconds" arity="1"/> <fsummary>Convert <c>Seconds</c>to <c>Milliseconds</c>.</fsummary> <desc> - <p>Returns the number of milliseconds in <c>Seconds</c>.</p> + <p>Returns the number of milliseconds in <c><anno>Seconds</anno></c>.</p> </desc> </func> <func> - <name>minutes(Minutes) -> Milliseconds</name> + <name name="minutes" arity="1"/> <fsummary>Converts <c>Minutes</c>to <c>Milliseconds</c>.</fsummary> <desc> - <p>Return the number of milliseconds in <c>Minutes</c>.</p> + <p>Return the number of milliseconds in <c><anno>Minutes</anno></c>.</p> </desc> </func> <func> - <name>hours(Hours) -> Milliseconds</name> + <name name="hours" arity="1"/> <fsummary>Convert <c>Hours</c>to <c>Milliseconds</c>.</fsummary> <desc> - <p>Returns the number of milliseconds in <c>Hours</c>.</p> + <p>Returns the number of milliseconds in <c><anno>Hours</anno></c>.</p> </desc> </func> <func> - <name>hms(Hours, Minutes, Seconds) -> Milliseconds</name> + <name name="hms" arity="3"/> <fsummary>Convert <c>Hours</c>+<c>Minutes</c>+<c>Seconds</c>to <c>Milliseconds</c>.</fsummary> <desc> - <p>Returns the number of milliseconds in <c>Hours + Minutes + Seconds</c>.</p> + <p>Returns the number of milliseconds in <c><anno>Hours</anno> + <anno>Minutes</anno> + <anno>Seconds</anno></c>.</p> </desc> </func> </funcs> @@ -262,7 +258,6 @@ <section> <title>Examples</title> <p>This example illustrates how to print out "Hello World!" in 5 seconds:</p> - <p></p> <pre> 1> <input>timer:apply_after(5000, io, format, ["~nHello World!~n", []]).</input> {ok,TRef} diff --git a/lib/stdlib/doc/src/unicode.xml b/lib/stdlib/doc/src/unicode.xml index 60edd8ade9..d02763f75c 100644 --- a/lib/stdlib/doc/src/unicode.xml +++ b/lib/stdlib/doc/src/unicode.xml @@ -5,7 +5,7 @@ <header> <copyright> <year>1996</year> - <year>2009</year> + <year>2011</year> <holder>Ericsson AB, All Rights Reserved</holder> </copyright> <legalnotice> @@ -38,50 +38,83 @@ <p>It is recommended to only use external encodings for communication with external entities where this is required. When working inside the Erlang/OTP environment, it is recommended to keep binaries in UTF-8 when representing Unicode characters. Latin1 encoding is supported both for backward compatibility and for communication with external entities not supporting Unicode character sets.</p> </description> - <section> - <title>DATA TYPES</title> - <marker id="charlist_definition"></marker> - <code type="none"> -unicode_binary() = binary() with characters encoded in UTF-8 coding standard -unicode_char() = integer() representing valid unicode codepoint - -chardata() = charlist() | unicode_binary() - -charlist() = [unicode_char() | unicode_binary() | charlist()] - a unicode_binary is allowed as the tail of the list</code> - - <code type="none"> -external_unicode_binary() = binary() - with characters coded in a user specified Unicode encoding other - than UTF-8 (UTF-16 or UTF-32) - -external_chardata() = external_charlist() | external_unicode_binary() - -external_charlist() = [unicode_char() | external_unicode_binary() | external_charlist()] - an external_unicode_binary is allowed as the tail of the list</code> - - <code type="none"> -latin1_binary() = binary() with characters coded in iso-latin-1 -latin1_char() = integer() representing valid latin1 character (0-255) - -latin1_chardata() = latin1_charlist() | latin1_binary() + <datatypes> + <datatype> + <name name="encoding"/> + </datatype> + <datatype> + <name name="endian"/> + </datatype> + <datatype> + <name name="unicode_binary"/> + <desc> + <p>A binary() with characters encoded in the UTF-8 coding standard.</p> + </desc> + </datatype> + <datatype> + <name name="unicode_char"/> + <desc> + <p>An integer() representing a valid unicode codepoint.</p> + </desc> + </datatype> + <datatype> + <name name="chardata"/> + </datatype> + <datatype> + <name name="charlist"/> + <desc> + <p>A unicode_binary is allowed as the tail of the list.</p> + </desc> + </datatype> + <datatype> + <name name="external_unicode_binary"/> + <desc> + <p>A <c>binary()</c> with characters coded in a user specified Unicode + encoding other than UTF-8 (UTF-16 or UTF-32).</p> + </desc> + </datatype> + <datatype> + <name name="external_chardata"/> + </datatype> + <datatype> + <name name="external_charlist"/> + <desc> + <p>An <c>external_unicode_binary()</c> is allowed as the tail + of the list.</p> + </desc> + </datatype> + <datatype> + <name name="latin1_binary"/> + <desc><p>A <c>binary()</c> with characters coded in iso-latin-1.</p> + </desc> + </datatype> + <datatype> + <name name="latin1_char"/> + <desc><p>An <c>integer()</c> representing valid latin1 + character (0-255).</p> + </desc> + </datatype> + <datatype> + <name name="latin1_chardata"/> + </datatype> + <datatype> + <name name="latin1_charlist"/> + <desc><p>A <c>latin1_binary()</c> is allowed as the tail of + the list.</p> + </desc> + </datatype> + </datatypes> -latin1_charlist() = [latin1_char() | latin1_binary() | latin1_charlist()] - a latin1_binary is allowed as the tail of the list</code> - </section> <funcs> <func> - <name>bom_to_encoding(Bin) -> {Encoding,Length}</name> + <name name="bom_to_encoding" arity="1"/> <fsummary>Identify UTF byte order marks in a binary.</fsummary> - <type> - <v>Bin = binary() of byte_size 4 or more</v> - <v>Encoding = latin1 | utf8 | {utf16,little} | {utf16,big} | {utf32,little} | {utf32,big}</v> - <v>Length = int()</v> - </type> + <type name="endian"/> + <type_desc variable="Bin">A binary() of byte_size 4 or more.</type_desc> <desc> <p>Check for a UTF byte order mark (BOM) in the beginning of a - binary. If the supplied binary <c>Bin</c> begins with a valid + binary. If the supplied binary <c><anno>Bin</anno></c> begins with a valid byte order mark for either UTF-8, UTF-16 or UTF-32, the function returns the encoding identified along with the length of the BOM in bytes.</p> @@ -90,23 +123,24 @@ latin1_charlist() = [latin1_char() | latin1_binary() | latin1_charlist()] </desc> </func> <func> - <name>characters_to_list(Data) -> list() | {error, list(), RestData} | {incomplete, list(), binary()} </name> + <name name="characters_to_list" arity="1"/> <fsummary>Convert a collection of characters to list of Unicode characters</fsummary> - <type> - <v>Data = latin1_chardata() | chardata() | external_chardata()</v> - <v>RestData = latin1_chardata() | chardata() | external_chardata()</v> - </type> <desc> - <p>Same as characters_to_list(Data,unicode).</p> + <p>Same as characters_to_list(<anno>Data</anno>,unicode).</p> </desc> </func> <func> - <name>characters_to_list(Data, InEncoding) -> list() | {error, list(), RestData} | {incomplete, list(), binary()} </name> + <name>characters_to_list(Data, InEncoding) -> Result</name> <fsummary>Convert a collection of characters to list of Unicode characters</fsummary> <type> - <v>Data = latin1_chardata() | chardata() | external_chardata()</v> - <v>RestData = latin1_chardata() | chardata() | external_chardata()</v> - <v>InEncoding = latin1 | unicode | utf8 | utf16 | utf32 | {utf16,little} | {utf16,big} | {utf32,little} | {utf32,big}</v> + <v>Data = <seealso marker="#type-latin1_chardata">latin1_chardata()</seealso> + | <seealso marker="#type-chardata">chardata()</seealso> + | <seealso marker="#type-external_chardata">external_chardata()</seealso></v> + <v>Result = list() | {error, list(), RestData} | {incomplete, list(), binary()}</v> + <v>RestData = <seealso marker="#type-latin1_chardata">latin1_chardata()</seealso> + | <seealso marker="#type-chardata">chardata()</seealso> + | <seealso marker="#type-external_chardata">external_chardata()</seealso></v> + <v>InEncoding = <seealso marker="#type-encoding">encoding()</seealso></v> </type> <desc> @@ -164,10 +198,16 @@ latin1_charlist() = [latin1_char() | latin1_binary() | latin1_charlist()] <item>Integers out of range - If <c>InEncoding</c> is <c>latin1</c>, an error occurs whenever an integer greater than 255 is found in the lists. If <c>InEncoding</c> is - of a Unicode type, error occurs whenever an integer greater than - <c>16#10FFFF</c> (the maximum unicode character) or in the - range <c>16#D800</c> to <c>16#DFFF</c> (invalid unicode - range) is found.</item> + of a Unicode type, an error occurs whenever an integer + <list type="bulleted"> + <item>greater than <c>16#10FFFF</c> + (the maximum unicode character),</item> + <item>in the range <c>16#D800</c> to <c>16#DFFF</c> + (invalid unicode range)</item> + <item>or equal to 16#FFFE or 16#FFFF (non characters)</item> + </list> + is found. + </item> <item>UTF encoding incorrect - If <c>InEncoding</c> is one of the UTF types, the bytes in any binaries have to be valid @@ -228,44 +268,42 @@ latin1_charlist() = [latin1_char() | latin1_binary() | latin1_charlist()] </desc> </func> <func> - <name>characters_to_binary(Data) -> binary() | {error, binary(), RestData} | {incomplete, binary(), binary()} </name> - <fsummary>Convert a collection of characters to an UTF-8 binary</fsummary> <type> - <v>Data = latin1_chardata() | chardata() | external_chardata()</v> - <v>RestData = latin1_chardata() | chardata() | external_chardata()</v> - </type> + <name name="characters_to_binary" arity="1"/> + <fsummary>Convert a collection of characters to an UTF-8 binary</fsummary> <desc> <p>Same as characters_to_binary(Data, unicode, unicode).</p> </desc> </func> <func> - <name>characters_to_binary(Data,InEncoding) -> binary() | {error, binary(), RestData} | {incomplete, binary(), binary()} </name> - <fsummary>Convert a collection of characters to an UTF-8 binary</fsummary> <type> - <v>Data = latin1_chardata() | chardata() | external_chardata()</v> - <v>RestData = latin1_chardata() | chardata() | external_chardata()</v> - <v>InEncoding = latin1 | unicode | utf8 | utf16 | utf32 | {utf16,little} | {utf16,big} | {utf32,little} | {utf32,big}</v> + <name>characters_to_binary(Data,InEncoding) -> Result</name> + <fsummary>Convert a collection of characters to an UTF-8 binary</fsummary> + + <type> + <v>Data = <seealso marker="#type-latin1_chardata">latin1_chardata()</seealso> + | <seealso marker="#type-chardata">chardata()</seealso> + | <seealso marker="#type-external_chardata">external_chardata()</seealso></v> + <v>Result = binary() | {error, binary(), RestData} | {incomplete, binary(), binary()}</v> + <v>RestData = <seealso marker="#type-latin1_chardata">latin1_chardata()</seealso> + | <seealso marker="#type-chardata">chardata()</seealso> + | <seealso marker="#type-external_chardata">external_chardata()</seealso></v> + <v>InEncoding = <seealso marker="#type-encoding">encoding()</seealso></v> </type> <desc> <p>Same as characters_to_binary(Data, InEncoding, unicode).</p> </desc> </func> <func> - <name>characters_to_binary(Data, InEncoding, OutEncoding) -> binary() | {error, binary(), RestData} | {incomplete, binary(), binary()} </name> + <name name="characters_to_binary" arity="3"/> <fsummary>Convert a collection of characters to an UTF-8 binary</fsummary> - <type> - <v>Data = latin1_chardata() | chardata() | external_chardata()</v> - <v>RestData = latin1_chardata() | chardata() | external_chardata()</v> - <v>InEncoding = latin1 | unicode | utf8 | utf16 | utf32 | {utf16,little} | {utf16,big} | {utf32,little} | {utf32,big}</v> - <v>OutEncoding = latin1 | unicode | utf8 | utf16 | utf32| {utf16,little} | {utf16,big} | {utf32,little} | {utf32,big}</v> - </type> <desc> <p>This function behaves as <seealso marker="#characters_to_list/2"> characters_to_list/2</seealso>, but produces an binary instead of a unicode list. The - <c>InEncoding</c> defines how input is to be interpreted if + <c><anno>InEncoding</anno></c> defines how input is to be interpreted if binaries are present in the <c>Data</c>, while - <c>OutEncoding</c> defines in what format output is to be + <c><anno>OutEncoding</anno></c> defines in what format output is to be generated.</p> <p>The option <c>unicode</c> is an alias for <c>utf8</c>, as this is the @@ -285,17 +323,13 @@ latin1_charlist() = [latin1_char() | latin1_binary() | latin1_charlist()] </desc> </func> <func> - <name>encoding_to_bom(InEncoding) -> Bin</name> + <name name="encoding_to_bom" arity="1"/> <fsummary>Create a binary UTF byte order mark from encoding.</fsummary> - <type> - <v>Bin = binary() of byte_size 4 or less</v> - <v>InEncoding = latin1 | unicode | utf8 | utf16 | utf32 | {utf16,little} | {utf16,big} | {utf32,little} | {utf32,big}</v> - <v>Length = int()</v> - </type> + <type_desc variable="Bin">A binary() of byte_size 4 or more.</type_desc> <desc> <p>Create an UTF byte order mark (BOM) as a binary from the - supplied <c>InEncoding</c>. The BOM is, if supported at all, + supplied <c><anno>InEncoding</anno></c>. The BOM is, if supported at all, expected to be placed first in UTF encoded files or messages.</p> diff --git a/lib/stdlib/doc/src/unicode_usage.xml b/lib/stdlib/doc/src/unicode_usage.xml index c5bf10b63d..0fa7de0a5c 100644 --- a/lib/stdlib/doc/src/unicode_usage.xml +++ b/lib/stdlib/doc/src/unicode_usage.xml @@ -5,7 +5,7 @@ <header> <copyright> <year>1999</year> - <year>2009</year> + <year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -52,7 +52,7 @@ <tag>UCS-4</tag> <item>Basically the same as UTF-32, but without some Unicode semantics, defined by IEEE and has little use as a separate encoding standard. For all normal (and possibly abnormal) usages, UTF-32 and UCS-4 are interchangeable.</item> </taglist> -<p>Certain ranges of characters are left unused and certain ranges are even deemed invalid. The most notable invalid range is 16#D800 - 16#DFFF, as the UTF-16 encoding does not allow for encoding of these numbers. It can be speculated that the UTF-16 encoding standard was, from the beginning, expected to be able to hold all Unicode characters in one 16-bit entity, but then had to be extended, leaving a whole in the Unicode range to cope with backward compatibility.</p> +<p>Certain ranges of characters are left unused and certain ranges are even deemed invalid. The most notable invalid range is 16#D800 - 16#DFFF, as the UTF-16 encoding does not allow for encoding of these numbers. It can be speculated that the UTF-16 encoding standard was, from the beginning, expected to be able to hold all Unicode characters in one 16-bit entity, but then had to be extended, leaving a hole in the Unicode range to cope with backward compatibility.</p> <p>Additionally, the codepoint 16#FEFF is used for byte order marks (BOM's) and use of that character is not encouraged in other contexts than that. It actually is valid though, as the character "ZWNBS" (Zero Width Non Breaking Space). BOM's are used to identify encodings and byte order for programs where such parameters are not known in advance. Byte order marks are more seldom used than one could expect, put their use is becoming more widely spread as they provide the means for programs to make educated guesses about the Unicode format of a certain file.</p> </section> <section> @@ -143,7 +143,7 @@ en_US.UTF-8</pre> <pre> $ echo <input>$LC_CTYPE</input> en_US.UTF-8</pre> -<p>The LANG or LC_CTYPE setting should be consistent with what the terminal is capable of, there is no portable way for Erlang to ask the actual terminal about it's UTF-8 capacity, we have to rely on the language and character type settings.</p> +<p>The LANG or LC_CTYPE setting should be consistent with what the terminal is capable of, there is no portable way for Erlang to ask the actual terminal about its UTF-8 capacity, we have to rely on the language and character type settings.</p> <p>To investigate what Erlang thinks about the terminal, the <c>io:getopts()</c> call can be used when the shell is started:</p> <pre> $ <input>LC_CTYPE=en_US.ISO-8859-1 erl</input> @@ -168,6 +168,48 @@ Eshell V5.7 (abort with ^G) <image file="ushell2.gif"><icaption>Unicode characters in allowed and disallowed context</icaption></image> </section> <section> +<title>Unicode file names</title> +<p>Most modern operating systems support Unicode file names in some way or another. There are several different ways to do this and Erlang by default treats the different approaches differently:</p> +<taglist> +<tag>Mandatory Unicode file naming</tag> +<item> +<p>Windows and, for most common uses, MacOSX enforces Unicode support for file names. All files created in the filesystem have names that can consistently be interpreted. In MacOSX, all file names are retrieved in UTF-8 encoding, while Windows has selected an approach where each system call handling file names has a special Unicode aware variant, giving much the same effect. There are no file names on these systems that are not Unicode file names, why the default behavior of the Erlang VM is to work in "Unicode file name translation mode", meaning that a file name can be given as a Unicode list and that will be automatically translated to the proper name encoding for the underlying operating and file system.</p> +<p>Doing i.e. a <c>file:list_dir/1</c> on one of these systems may return Unicode lists with codepoints beyond 255, depending on the content of the actual filesystem.</p> +<p>As the feature is fairly new, you may still stumble upon non core applications that cannot handle being provided with file names containing characters with codepoints larger than 255, but the core Erlang system should have no problems with Unicode file names.</p> +</item> +<tag>Transparent file naming</tag> +<item> +<p>Most Unix operating systems have adopted a simpler approach, namely that Unicode file naming is not enforced, but by convention. Those systems usually use UTF-8 encoding for Unicode file names, but do not enforce it. On such a system, a file name containing characters having codepoints between 128 and 255 may be named either as plain ISO-latin-1 or using UTF-8 encoding. As no consistency is enforced, the Erlang VM can do no consistent translation of all file names. If the VM would automatically select encoding based on heuristics, one could get unexpected behavior on these systems, therefore file names not being encoded in UTF-8 are returned as "raw file names" if Unicode file naming support is turned on.</p> +<p>A raw file name is not a list, but a binary. Many non core applications still do not handle file names given as binaries, why such raw names are avoided by default. This means that systems having implemented Unicode file naming through transparent file systems and an UTF-8 convention, do not by default have Unicode file naming turned on. Explicitly turning Unicode file name handling on for these types of systems is considered experimental.</p> +</item> +</taglist> +<p>The Unicode file naming support was introduced with OTP release R14B01. A VM operating in Unicode file mode can work with files having names in any language or character set (as long as it's supported by the underlying OS and file system). The Unicode character list is used to denote file or directory names and if the file system content is listed, you will also be able to get Unicode lists as return value. The support lies in the kernel and stdlib modules, why most applications (that does not explicitly require the file names to be in the ISO-latin-1 range) will benefit from the Unicode support without change.</p> + +<p>On Operating systems with mandatory Unicode file names, this means that you more easily conform to the file names of other (non Erlang) applications, and you can also process file names that, at least on Windows, were completely inaccessible (due to having names that could not be represented in ISO-latin-1). Also you will avoid creating incomprehensible file names on MacOSX as the vfs layer of the OS will accept all your file names as UTF-8 and will not rewrite them.</p> + +<p>For most systems, turning on Unicode file name translation is no problem even if it uses transparent file naming. Very few systems have mixed file name encodings. A consistent UTF-8 named system will work perfectly in Unicode file name mode. It is still however considered experimental in R14B01. Unicode file name translation is turned on with the <c>+fnu</c> switch to the <c>erl</c> program. If the VM is started in Unicode file name translation mode, <c>file:native_name_encoding/0</c> will return the atom <c>utf8</c>.</p> + +<p>In Unicode file name mode, file names given to the BIF <c>open_port/2</c> with the option <c>{spawn_executable,...}</c> are also interpreted as Unicode. So is the parameter list given in the <c>args</c> option available when using <c>spawn_executable</c>. The UTF-8 translation of arguments can be avoided using binaries, see the discussion about raw file names below.</p> + +<p>It is worth noting that the file <c>encoding</c> options given when opening a file has nothing to do with the file <em>name</em> encoding convention. You can very well open files containing UTF-8 but having file names in ISO-latin-1 or vice versa.</p> + +<note>Erlang drivers and NIF shared objects still can not be named with names containing codepoints beyond 127. This is a known limitation to be removed in a future release. Erlang modules however can, but it is definitely not a good idea and is still considered experimental.</note> + +<section> +<title>Notes about raw file names and automatic file name conversion</title> +<p>Raw file names is introduced together with Unicode file name support in erts-5.8.2 (OTP R14B01). The reason "raw file names" is introduced in the system is to be able to consistently represent file names given in different encodings on the same system. Having the VM automatically translate a file name that is not in UTF-8 to a list of Unicode characters might seem practical, but this would open up for both duplicate file names and other inconsistent behavior. Consider a directory containing a file named "bj�rn" in ISO-latin-1, while the Erlang VM is operating in Unicode file name mode (and therefore expecting UTF-8 file naming). The ISO-latin-1 name is not valid UTF-8 and one could be tempted to think that automatic conversion in for example <c>file:list_dir/1</c> is a good idea. But what would happen if we later tried to open the file and have the name as a Unicode list (magically converted from the ISO-latin-1 file name)? The VM will convert the file name given to UTF-8, as this is the encoding expected. Effectively this means trying to open the file named <<"bj�rn"/utf8>>. This file does not exist, and even if it existed it would not be the same file as the one that was listed. We could even create two files named "bj�rn", one named in the UTF-8 encoding and one not. If <c>file:list_dir/1</c> would automatically convert the ISO-latin-1 file name to a list, we would get two identical file names as the result. To avoid this, we need to differentiate between file names being properly encoded according to the Unicode file naming convention (i.e. UTF-8) and file names being invalid under the encoding. This is done by representing invalid encoding as "raw" file names, i.e. as binaries.</p> +<p>The core system of Erlang (kernel and stdlib) accepts raw file names except for loadable drivers and executables invoked using <c>open_port({spawn, ...} ...)</c>. <c>open_port({spawn_executable, ...} ...)</c> however does accept them. As mentioned earlier, the arguments given in the option list to <c>open_port({spawn_executable, ...} ...)</c> undergo the same conversion as the file names, meaning that the executable will be provided with arguments in UTF-8 as well. This translation is avoided consistently with how the file names are treated, by giving the argument as a binary.</p> +<p>To force Unicode file name translation mode on systems where this is not the default is considered experimental in OTP R14B01 due to the raw file names possibly being a new experience to the programmer and that the non core applications of OTP are not tested for compliance with raw file names yet. Unicode file name translation is expected to be default in future releases.</p> +<p>If working with raw file names, one can still conform to the encoding convention of the Erlang VM by using the <c>file:native_name_encoding/0</c> function, which returns either the atom <c>latin1</c> or the atom <c>utf8</c> depending on the file name translation mode. On Linux, a VM started without explicitly stating the file name translation mode will default to <c>latin1</c> as the native file name encoding, why file names on the disk encoded as UTF-8 will be returned as a list of the names interpreted as ISO-latin-1. The "UTF-8 list" is not a practical type for displaying or operating on in Erlang, but it is backward compatible and usable in all functions requiring a file name. On Windows and MacOSX, the default behavior is that of file name translation, why the <c>file:native_name_encoding/0</c> by default returns <c>utf8</c> on those systems (the fact that Windows actually does not use UTF-8 on the file system level can safely be ignored by the Erlang programmer). The default behavior can be changed using the <c>+fnu</c> or <c>+fnl</c> options to the VM, see the <c>erl</c> command manual page.</p> +<p>Even if you are operating without Unicode file naming translation automatically done by the VM, you can access and create files with names in UTF-8 encoding by using raw file names encoded as UTF-8. Enforcing the UTF-8 encoding regardless of the mode the Erlang VM is started in might, in some circumstances be a good idea, as the convention of using UTF-8 file names is spreading.</p> +</section> +<section> +<title>Notes about MacOSX</title> +<p>MacOSXs vfs layer enforces UTF-8 file names in a quite aggressive way. Older versions did this by simply refusing to create non UTF-8 conforming file names, while newer versions replace offending bytes with the sequence "%HH", where HH is the original character in hexadecimal notation. As Unicode translation is enabled by default on MacOSX, the only way to come up against this is to either start the VM with the <c>+fnl</c> flag or to use a raw file name in <c>latin1</c> encoding. In that case, the file can not be opened with the same name as the one used to create this. The problem is by design in newer versions of MacOSX.</p> +<p>MacOSX also reorganizes the names of files so that the representation of accents etc is denormalized, i.e. the character <c>�</c> is represented as the codepoints [111,776], where 111 is the character <c>o</c> and 776 is a special accent character. This type of denormalized Unicode is otherwise very seldom used and Erlang normalizes those file names on retrieval, so that denormalized file names is not passed up to the Erlang application. In Erlang the file name "bj�rn" is retrieved as [98,106,246,114,110], not as [98,106,117,776,114,110], even though the file system might think differently.</p> +</section> +</section> +<section> <title>Unicode-aware modules</title> <p>Most of the modules in Erlang/OTP are of course Unicode-unaware in the sense that they have no notion of Unicode and really shouldn't have. Typically they handle non-textual or byte-oriented data (like <c>gen_tcp</c> etc).</p> <p>Modules that actually handle textual data (like <c>io_lib</c>, <c>string</c> etc) are sometimes subject to conversion or extension to be able to handle Unicode characters.</p> @@ -185,7 +227,7 @@ Eshell V5.7 (abort with ^G) <tag><c>file</c>, <c>group</c> and <c>user</c></tag> <item> <p>I/O-servers throughout the system are able both to handle Unicode data and has options for converting data upon actual output or input to/from the device. As shown earlier, the <seealso marker="stdlib:shell">shell</seealso> has support for Unicode terminals and the <seealso marker="kernel:file">file</seealso> module allows for translation to and from various Unicode formats on disk.</p> -<p>The actual reading and writing of files with Unicode data is however not best done with the <c>file</c> module as it's interface is byte oriented. A file opened with a Unicode encoding (like UTF-8), is then best read or written using the <seealso marker="stdlib:io">io</seealso> module.</p> +<p>The actual reading and writing of files with Unicode data is however not best done with the <c>file</c> module as its interface is byte oriented. A file opened with a Unicode encoding (like UTF-8), is then best read or written using the <seealso marker="stdlib:io">io</seealso> module.</p> </item> <tag><c>re</c></tag> <item> diff --git a/lib/stdlib/doc/src/win32reg.xml b/lib/stdlib/doc/src/win32reg.xml index 28960cd098..99fd7fdeb6 100644 --- a/lib/stdlib/doc/src/win32reg.xml +++ b/lib/stdlib/doc/src/win32reg.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>2000</year><year>2009</year> + <year>2000</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -85,14 +85,22 @@ hkdd HKEY_DYN_DATA</pre> <p>For additional information on the Windows registry consult the Win32 Programmer's Reference.</p> </description> + <datatypes> + <datatype> + <name name="reg_handle"/> + <desc><p>As returned by <seealso marker="#open/1">open/1</seealso>.</p></desc> + </datatype> + <datatype> + <name name="name"/> + </datatype> + <datatype> + <name name="value"/> + </datatype> + </datatypes> <funcs> <func> - <name>change_key(RegHandle, Key) -> ReturnValue</name> + <name name="change_key" arity="2"/> <fsummary>Move to a key in the registry</fsummary> - <type> - <v>RegHandle = term()</v> - <v>Key = string()</v> - </type> <desc> <p>Changes the current key to another key. Works like cd. The key can be specified as a relative path or as an @@ -100,12 +108,8 @@ hkdd HKEY_DYN_DATA</pre> </desc> </func> <func> - <name>change_key_create(RegHandle, Key) -> ReturnValue</name> + <name name="change_key_create" arity="2"/> <fsummary>Move to a key, create it if it is not there</fsummary> - <type> - <v>RegHandle = term()</v> - <v>Key = string()</v> - </type> <desc> <p>Creates a key, or just changes to it, if it is already there. Works like a combination of <c>mkdir</c> and <c>cd</c>. Calls the Win32 API function @@ -114,23 +118,16 @@ hkdd HKEY_DYN_DATA</pre> </desc> </func> <func> - <name>close(RegHandle)-> ReturnValue</name> + <name name="close" arity="1"/> <fsummary>Close the registry.</fsummary> - <type> - <v>RegHandle = term()</v> - </type> <desc> - <p>Closes the registry. After that, the <c>RegHandle</c> cannot + <p>Closes the registry. After that, the <c><anno>RegHandle</anno></c> cannot be used.</p> </desc> </func> <func> - <name>current_key(RegHandle) -> ReturnValue</name> + <name name="current_key" arity="1"/> <fsummary>Return the path to the current key.</fsummary> - <type> - <v>RegHandle = term()</v> - <v>ReturnValue = {ok, string()}</v> - </type> <desc> <p>Returns the path to the current key. This is the equivalent of <c>pwd</c>.</p> <p>Note that the current key is stored in the driver, and might be @@ -138,12 +135,8 @@ hkdd HKEY_DYN_DATA</pre> </desc> </func> <func> - <name>delete_key(RegHandle) -> ReturnValue</name> + <name name="delete_key" arity="1"/> <fsummary>Delete the current key</fsummary> - <type> - <v>RegHandle = term()</v> - <v>ReturnValue = ok | {error, ErrorId}</v> - </type> <desc> <p>Deletes the current key, if it is valid. Calls the Win32 API function <c>RegDeleteKey()</c>. Note that this call does not change the current key, @@ -152,12 +145,8 @@ hkdd HKEY_DYN_DATA</pre> </desc> </func> <func> - <name>delete_value(RegHandle, Name) -> ReturnValue</name> + <name name="delete_value" arity="2"/> <fsummary>Delete the named value on the current key.</fsummary> - <type> - <v>RegHandle = term()</v> - <v>ReturnValue = ok | {error, ErrorId}</v> - </type> <desc> <p>Deletes a named value on the current key. The atom <c>default</c> is used for the the default value.</p> @@ -165,12 +154,8 @@ hkdd HKEY_DYN_DATA</pre> </desc> </func> <func> - <name>expand(String) -> ExpandedString</name> + <name name="expand" arity="1"/> <fsummary>Expand a string with environment variables</fsummary> - <type> - <v>String = string()</v> - <v>ExpandedString = string()</v> - </type> <desc> <p>Expands a string containing environment variables between percent characters. Anything between two % is taken for a environment @@ -180,23 +165,15 @@ hkdd HKEY_DYN_DATA</pre> </desc> </func> <func> - <name>format_error(ErrorId) -> ErrorString</name> + <name name="format_error" arity="1"/> <fsummary>Convert an POSIX errorcode to a string</fsummary> - <type> - <v>ErrorId = atom()</v> - <v>ErrorString = string()</v> - </type> <desc> <p>Convert an POSIX errorcode to a string (by calling <c>erl_posix_msg:message</c>).</p> </desc> </func> <func> - <name>open(OpenModeList)-> ReturnValue</name> + <name name="open" arity="1"/> <fsummary>Open the registry for reading or writing</fsummary> - <type> - <v>OpenModeList = [OpenMode]</v> - <v>OpenMode = read | write</v> - </type> <desc> <p>Opens the registry for reading or writing. The current key will be the root (<c>HKEY_CLASSES_ROOT</c>). The <c>read</c> flag in the mode list can be omitted.</p> @@ -204,12 +181,8 @@ hkdd HKEY_DYN_DATA</pre> </desc> </func> <func> - <name>set_value(RegHandle, Name, Value) -> ReturnValue</name> + <name name="set_value" arity="3"/> <fsummary>Set value at the current registry key with specified name.</fsummary> - <type> - <v>Name = string() | default</v> - <v>Value = string() | integer() | binary()</v> - </type> <desc> <p>Sets the named (or default) value to value. Calls the Win32 API function <c>RegSetValueEx()</c>. The value can be of three types, and @@ -221,13 +194,8 @@ hkdd HKEY_DYN_DATA</pre> </desc> </func> <func> - <name>sub_keys(RegHandle) -> ReturnValue</name> + <name name="sub_keys" arity="1"/> <fsummary>Get subkeys to the current key.</fsummary> - <type> - <v>ReturnValue = {ok, SubKeys} | {error, ErrorId}</v> - <v>SubKeys = [SubKey]</v> - <v>SubKey = string()</v> - </type> <desc> <p>Returns a list of subkeys to the current key. Calls the Win32 API function <c>EnumRegKeysEx()</c>.</p> @@ -235,13 +203,8 @@ hkdd HKEY_DYN_DATA</pre> </desc> </func> <func> - <name>value(RegHandle, Name) -> ReturnValue</name> + <name name="value" arity="2"/> <fsummary>Get the named value on the current key.</fsummary> - <type> - <v>Name = string() | default</v> - <v>ReturnValue = {ok, Value}</v> - <v>Value = string() | integer() | binary()</v> - </type> <desc> <p>Retrieves the named value (or default) on the current key. Registry values of type <c>REG_SZ</c>, are returned as strings. Type <c>REG_DWORD</c> @@ -249,15 +212,8 @@ hkdd HKEY_DYN_DATA</pre> </desc> </func> <func> - <name>values(RegHandle) -> ReturnValue</name> + <name name="values" arity="1"/> <fsummary>Get all values on the current key.</fsummary> - <type> - <v>ReturnValue = {ok, ValuePairs} | {ok, ErrorId}</v> - <v>ValuePairs = [ValuePair]</v> - <v>ValuePair = {Name, Value}</v> - <v>Name = string | default</v> - <v>Value = string() | integer() | binary()</v> - </type> <desc> <p>Retrieves a list of all values on the current key. The values have types corresponding to the registry types, see <c>value</c>. diff --git a/lib/stdlib/doc/src/zip.xml b/lib/stdlib/doc/src/zip.xml index e2ecfec8f0..cf0d581352 100644 --- a/lib/stdlib/doc/src/zip.xml +++ b/lib/stdlib/doc/src/zip.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>2006</year><year>2009</year> + <year>2006</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>zip</title> @@ -34,24 +34,26 @@ <module>zip</module> <modulesummary>Utility for reading and creating 'zip' archives.</modulesummary> <description> - <p>The <c>zip</c> module archives and extract files to and from a zip + <p>The <c>zip</c> module archives and extracts files to and from a zip archive. The zip format is specified by the "ZIP Appnote.txt" file available on PKWare's website www.pkware.com.</p> <p>The zip module supports zip archive versions up to 6.1. However, - password-protection and Zip64 is not supported.</p> + password-protection and Zip64 are not supported.</p> <p>By convention, the name of a zip file should end in "<c>.zip</c>". To abide to the convention, you'll need to add "<c>.zip</c>" yourself to the name.</p> - <p>Zip archives are created with the - <seealso marker="#zip_2">zip/2</seealso> or the + <p>Zip archives are created with the + <seealso marker="#zip_2">zip/2</seealso> or the <seealso marker="#zip_2">zip/3</seealso> function. (They are also available as <c>create</c>, to resemble the <c>erl_tar</c> module.)</p> - <p>To extract files from a zip archive, use the - <seealso marker="#unzip_1">unzip/1</seealso> or the + <p>To extract files from a zip archive, use the + <seealso marker="#unzip_1">unzip/1</seealso> or the <seealso marker="#unzip_2">unzip/2</seealso> function. (They are also available as <c>extract</c>.)</p> - <p>To return a list of the files in a zip archive, use the + <p>To fold a function over all files in a zip archive, use the + <seealso marker="#foldl_3">foldl_3</seealso> function.</p> + <p>To return a list of the files in a zip archive, use the <seealso marker="#list_dir_1">list_dir/1</seealso> or the <seealso marker="#list_dir_2">list_dir/2</seealso> function. (They are also available as <c>table</c>.)</p> @@ -83,67 +85,55 @@ recreated.</p> </section> - <section> - <title>DATA TYPES</title> - <code type="none"> -zip_file() </code> - <p>The record <c>zip_file</c> contains the following fields.</p> - <taglist> - <tag><c>name = string()</c></tag> - <item> - <p>the name of the file</p> - </item> - <tag><c>info = file_info()</c></tag> - <item> - <p>file info as in - <seealso marker="erts:file#read_file_info/1">file:read_file_info/1</seealso></p> - </item> - <tag><c>comment = string()</c></tag> - <item> - <p>the comment for the file in the zip archive</p> - </item> - <tag><c>offset = integer()</c></tag> - <item> - <p>the offset of the file in the zip archive (used internally)</p> - </item> - <tag><c>comp_size = integer()</c></tag> - <item> - <p>the compressed size of the file (the uncompressed size is found - in <c>info</c>)</p> - </item> - </taglist> - <code type="none">zip_comment</code> - <p>The record <c>zip_comment</c> just contains the archive comment for - a zip archive</p> - <taglist> - <tag><c>comment = string()</c></tag> - <item> - <p>the comment for the zip archive</p> - </item> - </taglist> - </section> + <datatypes> + <datatype> + <name name="zip_comment"/> + <desc> + <p>The record <c>zip_comment</c> just contains the archive comment for + a zip archive</p> + </desc> + </datatype> + <datatype> + <name name="zip_file"/> + <desc> + <p>The record <c>zip_file</c> contains the following fields.</p> + <taglist> + <tag><c>name</c></tag> + <item> + <p>the name of the file</p> + </item> + <tag><c>info</c></tag> + <item> + <p>file info as in + <seealso marker="kernel:file#read_file_info/1">file:read_file_info/1</seealso></p> + </item> + <tag><c>comment</c></tag> + <item> + <p>the comment for the file in the zip archive</p> + </item> + <tag><c>offset</c></tag> + <item> + <p>the offset of the file in the zip archive (used internally)</p> + </item> + <tag><c>comp_size</c></tag> + <item> + <p>the compressed size of the file (the uncompressed size is found + in <c>info</c>)</p> + </item> + </taglist> + </desc> + </datatype> + </datatypes> <funcs> <func> - <name>zip(Name, FileList) -> RetValue</name> - <name>zip(Name, FileList, Options) -> RetValue</name> - <name>create(Name, FileList) -> RetValue</name> - <name>create(Name, FileList, Options) -> RetValue</name> + <name name="zip" arity="2"/> + <name name="zip" arity="3"/> + <name name="create" arity="2"/> + <name name="create" arity="3"/> <fsummary>Create a zip archive with options</fsummary> - <type> - <v>Name = filename()</v> - <v>FileList = [FileSpec]</v> - <v>FileSpec = filename() | {filename(), binary()}</v> - <v>Options = [Option]</v> - <v>Option = memory | cooked | verbose | {comment, Comment} | {cwd, CWD} | {compress, What} | {uncompress, What}</v> - <v>What = all | [Extension] | {add, [Extension]} | {del, [Extension]}</v> - <v>Extension = string()</v> - <v>Comment = CWD = string()</v> - <v>RetValue = {ok, Name} | {ok, {Name, binary()}} | {error, Reason}</v> - <v>Reason = term()</v> - </type> <desc> <p>The <marker id="zip_2"></marker><c>zip</c> function creates a - zip archive containing the files specified in <c>FileList</c>.</p> + zip archive containing the files specified in <c><anno>FileList</anno></c>.</p> <p>As synonyms, the functions <c>create/2</c> and <c>create/3</c> are provided, to make it resemble the <c>erl_tar</c> module.</p> <p>The file-list is a list of files, with paths relative to the @@ -153,15 +143,15 @@ zip_file() </code> <p>Files will be compressed using the DEFLATE compression, as described in the Appnote.txt file. However, files will be stored without compression if they already are compressed. - The <c>zip/2</c> and <c>zip/3</c> checks the file extension + The <c>zip/2</c> and <c>zip/3</c> functions check the file extension to see whether the file should be stored without compression. Files with the following extensions are not compressed: <c>.Z</c>, <c>.zip</c>, <c>.zoo</c>, <c>.arc</c>, <c>.lzh</c>, <c>.arj</c>.</p> <p>It is possible to override the default behavior and explicitly control what types of files that should be - compressed by using the <c>{compress, What}</c> and - <c>{uncompress, What}</c> options. It is possible to have + compressed by using the <c>{compress, <anno>What</anno>}</c> and + <c>{uncompress, <anno>What</anno>}</c> options. It is possible to have several <c>compress</c> and <c>uncompress</c> options. In order to trigger compression of a file, its extension must match with the @@ -189,108 +179,94 @@ zip_file() </code> <tag><c>memory</c></tag> <item> <p>The output will not be to a file, but instead as a tuple - <c>{FileName, binary()}</c>. The binary will be a full zip + <c>{<anno>FileName</anno>, binary()}</c>. The binary will be a full zip archive with header, and can be extracted with for instance <c>unzip/2</c>.</p> </item> - <tag><c>{comment, Comment}</c></tag> + <tag><c>{comment, <anno>Comment</anno>}</c></tag> <item> <p>Add a comment to the zip-archive.</p> </item> - <tag><c>{cwd, CWD}</c></tag> + <tag><c>{cwd, <anno>CWD</anno>}</c></tag> <item> <p>Use the given directory as current directory, it will be prepended to file names when adding them, although it will not be in the zip-archive. (Acting like a file:set_cwd/1, but without changing the global cwd property.)</p> </item> - <tag><c>{compress, What}</c></tag> + <tag><c>{compress, <anno>What</anno>}</c></tag> <item> - <p>Controls what types of files that will be + <p>Controls what types of files will be compressed. It is by default set to <c>all</c>. The following values of <c>What</c> are allowed:</p> <taglist> <tag><c>all</c></tag> <item><p> means that all files will be compressed (as long - as they pass the <c>uncompress</c> condition).</p></item> - <tag><c>[Extension]</c></tag> + as they pass the <c>uncompress</c> condition).</p></item> + <tag><c>[<anno>Extension</anno>]</c></tag> <item><p>means that only files with exactly these extensions - will be compressed.</p></item> - <tag><c>{add,[Extension]}</c></tag> + will be compressed.</p></item> + <tag><c>{add,[<anno>Extension</anno>]}</c></tag> <item><p>adds these extensions to the list of compress - extensions.</p></item> - <tag><c>{del,[Extension]}</c></tag> + extensions.</p></item> + <tag><c>{del,[<anno>Extension</anno>]}</c></tag> <item><p>deletes these extensions from the list of compress - extensions.</p></item> + extensions.</p></item> </taglist> </item> - <tag><c>{uncompress, What}</c></tag> + <tag><c>{uncompress, <anno>What</anno>}</c></tag> <item> - <p>Controls what types of files that will be uncompressed. It is by + <p>Controls what types of files will be uncompressed. It is by default set to <c>[".Z",".zip",".zoo",".arc",".lzh",".arj"]</c>. The following values of <c>What</c> are allowed:</p> <taglist> <tag><c>all</c></tag> - <item><p> means that no files will be compressed.</p></item> - <tag><c>[Extension]</c></tag> + <item><p> means that no files will be compressed.</p></item> + <tag><c>[<anno>Extension</anno>]</c></tag> <item><p>means that files with these extensions will be - uncompressed.</p></item> - <tag><c>{add,[Extension]}</c></tag> + uncompressed.</p></item> + <tag><c>{add,[<anno>Extension</anno>]}</c></tag> <item><p>adds these extensions to the list of uncompress - extensions.</p></item> - <tag><c>{del,[Extension]}</c></tag> + extensions.</p></item> + <tag><c>{del,[<anno>Extension</anno>]}</c></tag> <item><p>deletes these extensions from the list of uncompress - extensions.</p></item> + extensions.</p></item> </taglist> </item> </taglist> </desc> </func> <func> - <name>unzip(Archive) -> RetValue</name> - <name>unzip(Archive, Options) -> RetValue</name> - <name>extract(Archive) -> RetValue</name> - <name>extract(Archive, Options) -> RetValue</name> + <name name="unzip" arity="1"/> + <name name="unzip" arity="2"/> + <name name="extract" arity="1"/> + <name name="extract" arity="2"/> <fsummary>Extract files from a zip archive</fsummary> - <type> - <v>Archive = filename() | binary()</v> - <v>Options = [Option]</v> - <v>Option = {file_list, FileList} | keep_old_files | verbose | memory | {file_filter, FileFilter} | {cwd, CWD}</v> - <v>FileList = [filename()]</v> - <v>FileBinList = [{filename(),binary()}]</v> - <v>FileFilter = fun(ZipFile) -> true | false</v> - <v>CWD = string()</v> - <v>ZipFile = zip_file()</v> - <v>RetValue = {ok,FileList} | {ok,FileBinList} | {error, Reason} | {error, {Name, Reason}}</v> - <v>Reason = term()</v> - </type> <desc> - <p>The <marker id="unzip_1"></marker> -<c>unzip/1</c> function extracts - all files from a zip archive. The - <marker id="unzip_2"></marker> -<c>unzip/2</c> function provides options - to extract some files, and more.</p> - <p>If the <c>Archive</c> argument is given as a binary, + <p>The <marker id="unzip_1"></marker><c>unzip/1</c> function extracts + all files from a zip archive. + The <marker id="unzip_2"></marker><c>unzip/2</c> function provides + options to extract some files, and more.</p> + <p>If the <c><anno>Archive</anno></c> argument is given as a binary, the contents of the binary is assumed to be a zip archive, otherwise it should be a filename.</p> <p>The following options are available:</p> <taglist> - <tag><c>{file_list, FileList}</c></tag> + <tag><c>{file_list, <anno>FileList</anno>}</c></tag> <item> <p>By default, all files will be extracted from the zip - archive. With the <c>{file_list,FileList}</c> option, + archive. With the <c>{file_list, <anno>FileList</anno>}</c> option, the <c>unzip/2</c> function will only extract the files - whose names are included in <c>FileList</c>. The full + whose names are included in <c><anno>FileList</anno></c>. The full paths, including the names of all sub directories within - the zip archive, must be specified.</p> + the zip archive, must be specified.</p> </item> <tag><c>cooked</c></tag> <item> <p>By default, the <c>open/2</c> function will open the zip file in <c>raw</c> mode, which is faster but does not allow a remote (erlang) file server to be used. Adding <c>cooked</c> - to the mode list will override the default and open zip file + to the mode list will override the default and open the zip file without the <c>raw</c> option. The same goes for the files extracted.</p> </item> @@ -299,7 +275,7 @@ zip_file() </code> <p>By default, all existing files with the same name as file in the zip archive will be overwritten. With the <c>keep_old_files</c> option, the <c>unzip/2</c> function will not overwrite any existing - files. Not that even with the <c>memory</c> option given, which + files. Note that even with the <c>memory</c> option given, which means that no files will be overwritten, files existing will be excluded from the result.</p> </item> @@ -327,26 +303,74 @@ zip_file() </code> </desc> </func> <func> - <name>list_dir(Archive) -> RetValue</name> - <name>list_dir(Archive, Options)</name> - <name>table(Archive) -> RetValue</name> - <name>table(Archive, Options)</name> + <name name="foldl" arity="3"/> + <fsummary>Fold a function over all files in a zip archive</fsummary> + <desc> + <p>The <marker id="foldl_3"></marker> <c>foldl/3</c> function + calls <c><anno>Fun</anno>(<anno>FileInArchive</anno>, <anno>GetInfo + </anno>, <anno>GetBin</anno>, <anno>AccIn</anno>)</c> on + successive files in the <c>Archive</c>, starting with + <c><anno>AccIn</anno> + == <anno>Acc0</anno></c>. <c><anno>FileInArchive</anno></c> is + the name that the file + has in the archive. <c><anno>GetInfo</anno></c> is a fun that + returns info + about the the file. <c><anno>GetBin</anno></c> returns the contents + of the + file. Both <c><anno>GetInfo</anno></c> and <c><anno>GetBin</anno></c> + must be called + within the <c><anno>Fun</anno></c>. Their behavior is undefined if + they are + called outside the context of the <c><anno>Fun</anno></c>. + The <c><anno>Fun</anno></c> + must return a new accumulator which is passed to the next + call. <c>foldl/3</c> returns the final value of the + accumulator. <c><anno>Acc0</anno></c> is returned if the archive is + empty. It is not necessary to iterate over all files in the + archive. The iteration may be ended prematurely in a + controlled manner by throwing an exception.</p> + + <p>For example:</p> + <pre> +> <input>Name = "dummy.zip".</input> +"dummy.zip" +> <input>{ok, {Name, Bin}} = zip:create(Name, [{"foo", <<"FOO">>}, {"bar", <<"BAR">>}], [memory]).</input> +{ok,{"dummy.zip", + <<80,75,3,4,20,0,0,0,0,0,74,152,97,60,171,39,212,26,3,0, + 0,0,3,0,0,...>>}} +> <input>{ok, FileSpec} = zip:foldl(fun(N, I, B, Acc) -> [{N, B(), I()} | Acc] end, [], {Name, Bin}).</input> +{ok,[{"bar",<<"BAR">>, + {file_info,3,regular,read_write, + {{2010,3,1},{19,2,10}}, + {{2010,3,1},{19,2,10}}, + {{2010,3,1},{19,2,10}}, + 54,1,0,0,0,0,0}}, + {"foo",<<"FOO">>, + {file_info,3,regular,read_write, + {{2010,3,1},{19,2,10}}, + {{2010,3,1},{19,2,10}}, + {{2010,3,1},{19,2,10}}, + 54,1,0,0,0,0,0}}]} +> <input>{ok, {Name, Bin}} = zip:create(Name, lists:reverse(FileSpec), [memory]).</input> +{ok,{"dummy.zip", + <<80,75,3,4,20,0,0,0,0,0,74,152,97,60,171,39,212,26,3,0, + 0,0,3,0,0,...>>}} +> <input>catch zip:foldl(fun("foo", _, B, _) -> throw(B()); (_, _, _, Acc) -> Acc end, [], {Name, Bin}). </input> +<<"FOO">> +</pre> + </desc> + </func> + <func> + <name name="list_dir" arity="1"/> + <name name="list_dir" arity="2"/> + <name name="table" arity="1" /> + <name name="table" arity="2"/> <fsummary>Retrieve the name of all files in a zip archive</fsummary> - <type> - <v>Archive = filename() | binary()</v> - <v>RetValue = {ok, [Comment, Files]} | {error, Reason}</v> - <v>Comment = zip_comment()</v> - <v>Files = [zip_file()]</v> - <v>Options = [Option]</v> - <v>Option = cooked</v> - <v>Reason = term()</v> - </type> <desc> - <p>The <marker id="list_dir_1"></marker> -<c>list_dir/1</c> function retrieves - the names of all files in the zip archive <c>Archive</c>. The - <marker id="list_dir_2"></marker> -<c>list_dir/2</c> function provides options.</p> + <p>The <marker id="list_dir_1"></marker><c>list_dir/1</c> + function retrieves the names of all files in the zip archive + <c><anno>Archive</anno></c>. The <marker id="list_dir_2"></marker> + <c>list_dir/2</c> function provides options.</p> <p>As synonyms, the functions <c>table/2</c> and <c>table/3</c> are provided, to make it resemble the <c>erl_tar</c> module.</p> <p>The result value is the tuple <c>{ok, List}</c>, where <c>List</c> @@ -358,53 +382,37 @@ zip_file() </code> <p>By default, the <c>open/2</c> function will open the zip file in <c>raw</c> mode, which is faster but does not allow a remote (erlang) file server to be used. Adding <c>cooked</c> - to the mode list will override the default and open zip file + to the mode list will override the default and open the zip file without the <c>raw</c> option.</p> </item> </taglist> </desc> </func> <func> - <name>t(Archive)</name> + <name name="t" arity="1"/> <fsummary>Print the name of each file in a zip archive</fsummary> - <type> - <v>Archive = filename() | binary() | ZipHandle</v> - <v>ZipHandle = pid()</v> - </type> <desc> - <p>The <marker id="t_1"></marker> -<c>t/1</c> function prints the names - of all files in the zip archive <c>Archive</c> to the Erlang shell. + <p>The <marker id="t_1"></marker><c>t/1</c> function prints the names + of all files in the zip archive <c><anno>Archive</anno></c> to the Erlang shell. (Similar to "<c>tar t</c>".)</p> </desc> </func> <func> - <name>tt(Archive)</name> + <name name="tt" arity="1"/> <fsummary>Print name and information for each file in a zip archive</fsummary> - <type> - <v>Archive = filename() | binary()</v> - </type> <desc> - <p>The <marker id="tt_1"></marker> -<c>tt/1</c> function prints names and - information about all files in the zip archive <c>Archive</c> to + <p>The <marker id="tt_1"></marker><c>tt/1</c> function prints names and + information about all files in the zip archive <c><anno>Archive</anno></c> to the Erlang shell. (Similar to "<c>tar tv</c>".)</p> </desc> </func> <func> - <name>zip_open(Archive) -> {ok, ZipHandle} | {error, Reason}</name> - <name>zip_open(Archive, Options) -> {ok, ZipHandle} | {error, Reason}</name> + <name name="zip_open" arity="1"/> + <name name="zip_open" arity="2"/> <fsummary>Open an archive and return a handle to it</fsummary> - <type> - <v>Archive = filename() | binary()</v> - <v>Options = [Option]</v> - <v>Options = cooked | memory | {cwd, CWD}</v> - <v>CWD = string()</v> - <v>ZipHandle = pid()</v> - </type> <desc> - <p>The <marker id="zip_open"></marker> -<c>zip_open</c> function opens a + <p>The <marker id="zip_open"></marker><c>zip_open</c> function + opens a zip archive, and reads and saves its directory. This means that subsequently reading files from the archive will be faster than unzipping files one at a time with <c>unzip</c>.</p> @@ -412,32 +420,21 @@ zip_file() </code> </desc> </func> <func> - <name>zip_list_dir(ZipHandle) -> Result | {error, Reason}</name> + <name name="zip_list_dir" arity="1"/> <fsummary>Return a table of files in open zip archive</fsummary> - <type> - <v>Result = [ZipComment, ZipFile...]</v> - <v>ZipComment = #zip_comment{}</v> - <v>ZipFile = #zip_file{}</v> - <v>ZipHandle = pid()</v> - </type> <desc> - <p>The <marker id="zip_list_dir"></marker> -<c>zip_list_dir/1</c> function - returns the file list of an open zip archive.</p> + <p>The <marker id="zip_list_dir"></marker> + <c>zip_list_dir/1</c> function + returns the file list of an open zip archive. The first returned + element is the zip archive comment.</p> </desc> </func> <func> - <name>zip_get(ZipHandle) -> {ok, [Result]} | {error, Reason}</name> - <name>zip_get(FileName, ZipHandle) -> {ok, Result} | {error, Reason}</name> + <name name="zip_get" arity="1"/> + <name name="zip_get" arity="2"/> <fsummary>Extract files from an open archive</fsummary> - <type> - <v>FileName = filename()</v> - <v>ZipHandle = pid()</v> - <v>Result = filename() | {filename(), binary()}</v> - </type> <desc> - <p>The <marker id="zip_get"></marker> -<c>zip_get</c> function extracts + <p>The <marker id="zip_get"></marker><c>zip_get</c> function extracts one or all files from an open archive.</p> <p>The files will be unzipped to memory or to file, depending on the options given to the <c>zip_open</c> function when the @@ -445,15 +442,11 @@ zip_file() </code> </desc> </func> <func> - <name>zip_close(ZipHandle) -> ok | {error, einval}</name> + <name name="zip_close" arity="1"/> <fsummary>Close an open archive</fsummary> - <type> - <v>ZipHandle = pid()</v> - </type> <desc> - <p>The <marker id="zip_close"></marker> -<c>zip_close/1</c> function closes - a zip archive, previously opened with <c>zip_open</c>. All + <p>The <marker id="zip_close"></marker><c>zip_close/1</c> function + closes a zip archive, previously opened with <c>zip_open</c>. All resources are closed, and the handle should not be used after closing.</p> </desc> |