diff options
Diffstat (limited to 'system/doc')
20 files changed, 598 insertions, 544 deletions
diff --git a/system/doc/efficiency_guide/advanced.xml b/system/doc/efficiency_guide/advanced.xml index 0ec3afbd59..2383e3cf3d 100644 --- a/system/doc/efficiency_guide/advanced.xml +++ b/system/doc/efficiency_guide/advanced.xml @@ -4,7 +4,7 @@ <chapter> <header> <copyright> - <year>2001</year><year>2009</year> + <year>2001</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>Advanced</title> @@ -47,11 +47,13 @@ <cell align="center" valign="middle">Memory size</cell> </row> <row> - <cell align="left" valign="middle">Integer (-16#7FFFFFF < i <16#7FFFFFF)</cell> - <cell align="left" valign="middle">1 word</cell> + <cell align="left" valign="middle">Small integer</cell> + <cell align="left" valign="middle">1 word<br></br> +On 32-bit architectures: -134217729 < i < 134217728 (28 bits)<br></br> +On 64-bit architectures: -576460752303423489 < i < 576460752303423488 (60 bits)</cell> </row> <row> - <cell align="left" valign="middle">Integer (big numbers)</cell> + <cell align="left" valign="middle">Big integer</cell> <cell align="left" valign="middle">3..N words</cell> </row> <row> @@ -72,11 +74,11 @@ On 64-bit architectures: 3 words</cell> </row> <row> <cell align="left" valign="middle">List</cell> - <cell align="left" valign="middle">1 word per element + the size of each element</cell> + <cell align="left" valign="middle">1 word + 1 word per element + the size of each element</cell> </row> <row> <cell align="left" valign="middle">String (is the same as a list of integers)</cell> - <cell align="left" valign="middle">2 words per character</cell> + <cell align="left" valign="middle">1 word + 2 words per character</cell> </row> <row> <cell align="left" valign="middle">Tuple</cell> @@ -154,7 +156,8 @@ On 64-bit architectures: 4 words for a reference from the current local node, an <item>255</item> <tag><em>Atoms </em></tag> <item> <marker id="atoms"></marker> -The maximum number of atoms is 1048576. </item> + By default, the maximum number of atoms is 1048576. + This limit can be raised or lowered using the <c>+t</c> option.</item> <tag><em>Ets-tables</em></tag> <item>The default is 1400, can be changed with the environment variable <c>ERL_MAX_ETS_TABLES</c>.</item> <tag><em>Elements in a tuple</em></tag> @@ -175,7 +178,7 @@ The maximum number of atoms is 1048576. </item> <tag><em>Total amount of data allocated by an Erlang node</em></tag> <item>The Erlang runtime system can use the complete 32 (or 64) bit address space, but the operating system often limits a single process to use less than that.</item> - <tag><em>length of a node name</em></tag> + <tag><em>Length of a node name</em></tag> <item>An Erlang node name has the form host@shortname or host@longname. The node name is used as an atom within the system so the maximum size of 255 holds for the node name too.</item> <tag><em>Open ports</em></tag> diff --git a/system/doc/efficiency_guide/commoncaveats.xml b/system/doc/efficiency_guide/commoncaveats.xml index e18e5aa510..61d13636c0 100644 --- a/system/doc/efficiency_guide/commoncaveats.xml +++ b/system/doc/efficiency_guide/commoncaveats.xml @@ -4,7 +4,7 @@ <chapter> <header> <copyright> - <year>2001</year><year>2009</year> + <year>2001</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>Common Caveats</title> @@ -69,7 +69,7 @@ <p>Atoms are not garbage-collected. Once an atom is created, it will never be removed. The emulator will terminate if the limit for the number - of atoms (1048576) is reached.</p> + of atoms (1048576 by default) is reached.</p> <p>Therefore, converting arbitrary input strings to atoms could be dangerous in a system that will run continuously. diff --git a/system/doc/efficiency_guide/functions.xml b/system/doc/efficiency_guide/functions.xml index d55b60e39c..fe14a4f000 100644 --- a/system/doc/efficiency_guide/functions.xml +++ b/system/doc/efficiency_guide/functions.xml @@ -4,7 +4,7 @@ <chapter> <header> <copyright> - <year>2001</year><year>2009</year> + <year>2001</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>Functions</title> @@ -179,7 +179,9 @@ explicit_map_pairs(Map, Xs0, Ys0) -> A "tuple fun", <c>{Module,Function}</c>, is not a fun. The cost for calling a "tuple fun" is similar to that of <c>apply/3</c> or worse. Using "tuple funs" is <em>strongly discouraged</em>, - as they may not be supported in a future release.</p></warning> + as they may not be supported in a future release, + and because there exists a superior alternative since the R10B + release, namely the <c>fun Module:Function/Arity</c> syntax.</p></warning> <p><c>apply/3</c> must look up the code for the function to execute in a hash table. Therefore, it will always be slower than a diff --git a/system/doc/efficiency_guide/myths.xml b/system/doc/efficiency_guide/myths.xml index 76a72368bb..65113c9372 100644 --- a/system/doc/efficiency_guide/myths.xml +++ b/system/doc/efficiency_guide/myths.xml @@ -168,8 +168,8 @@ vanilla_reverse([], Acc) -> <p>Actually, string handling could be slow if done improperly. In Erlang, you'll have to think a little more about how the strings are used and choose an appropriate representation and use - the <seealso marker="stdlib:re">re</seealso> instead of the obsolete - <c>regexp</c> module if you are going to use regualr expressions.</p> + the <seealso marker="stdlib:re">re</seealso> module instead of the obsolete + <c>regexp</c> module if you are going to use regular expressions.</p> </section> <section> diff --git a/system/doc/getting_started/robustness.xml b/system/doc/getting_started/robustness.xml index 227da4c027..c141530fe0 100644 --- a/system/doc/getting_started/robustness.xml +++ b/system/doc/getting_started/robustness.xml @@ -4,7 +4,7 @@ <chapter> <header> <copyright> - <year>2003</year><year>2009</year> + <year>2003</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>Robustness</title> @@ -146,7 +146,7 @@ after pong_timeout() -></code> a process calls <seealso marker="erts:erlang#link/1">link(Other_Pid)</seealso> it sets up a bidirectional link between itself and the process - called <c>Other_Pid</c>. When a process terminates its sends + called <c>Other_Pid</c>. When a process terminates, it sends something called a <em>signal</em> to all the processes it has links to.</p> <p>The signal carries information about the pid it was sent from and diff --git a/system/doc/installation_guide/Makefile b/system/doc/installation_guide/Makefile index 854025765c..a47d77604d 100644 --- a/system/doc/installation_guide/Makefile +++ b/system/doc/installation_guide/Makefile @@ -31,6 +31,7 @@ APPLICATION=otp-system-documentation # Release directory specification # ---------------------------------------------------- RELSYSDIR = $(RELEASE_PATH)/doc/installation_guide +REDIRECT_HTML_RELSYSDIR = $(RELSYSDIR)/source # ---------------------------------------------------- # Target Specs @@ -54,14 +55,11 @@ XML_FILES = \ $(XML_PART_FILES) # ---------------------------------------------------- -# Install readme files -# ---------------------------------------------------- -SOURCE_INSTALL_READMES = \ - $(ERL_TOP)/INSTALL.html \ - $(ERL_TOP)/INSTALL-CROSS.html \ - $(ERL_TOP)/INSTALL-WIN32.html +GENERATED_XML_FILES = \ + INSTALL.xml \ + INSTALL-CROSS.xml \ + INSTALL-WIN32.xml -SOURCE_RELSYSDIR = $(RELSYSDIR)/source # ---------------------------------------------------- HTML_FILES = \ @@ -71,6 +69,12 @@ HTMLDIR = ../html/installation_guide HTML_UG_FILE = $(HTMLDIR)/users_guide.html +REDIRECT_HTML_DIR = $(HTMLDIR)/source +REDIRECT_HTML_FILES = \ + $(REDIRECT_HTML_DIR)/INSTALL.html \ + $(REDIRECT_HTML_DIR)/INSTALL-CROSS.html \ + $(REDIRECT_HTML_DIR)/INSTALL-WIN32.html + # ---------------------------------------------------- # FLAGS # ---------------------------------------------------- @@ -80,15 +84,32 @@ DVIPS_FLAGS += # ---------------------------------------------------- # Targets # ---------------------------------------------------- -docs: html + +%.xml: $(ERL_TOP)/%.md $(ERL_TOP)/make/emd2exml + $(ERL_TOP)/make/emd2exml $< $@ + +$(REDIRECT_HTML_DIR)/%.html: Makefile + test -d $(REDIRECT_HTML_DIR) || $(INSTALL_DIR) $(REDIRECT_HTML_DIR) + echo "<html><head><meta HTTP-EQUIV=\"REFRESH\"" > $@ + echo " content=\"5; url=../"$(notdir $@)"\">" >> $@ + echo "<title>This page has moved</title></head><body>" >> $@ + echo "<h1>This page has moved</h1>" >> $@ + echo "<p>You will be automatically redirected to its new" >> $@ + echo "location in 5 seconds." >> $@ + echo "This <a href=\"../"$(notdir $@)"\">link</a> will" >> $@ + echo "take you there immediately.</p></body></html>" >> $@ + +docs: $(GENERATED_XML_FILES) html local_docs: PDFDIR=../../pdf +local_docs: $(GENERATED_XML_FILES) -html: $(GIF_FILES) $(HTML_UG_FILE) +html: $(REDIRECT_HTML_FILES) $(GENERATED_XML_FILES) $(GIF_FILES) $(HTML_UG_FILE) -debug opt: +debug opt: clean clean_docs: + rm -f $(GENERATED_XML_FILES) rm -rf $(HTMLDIR) rm -f $(TOP_PDF_FILE) $(TOP_PDF_FILE:%.pdf=%.fo) rm -f errs core *~ @@ -102,8 +123,8 @@ include $(ERL_TOP)/make/otp_release_targets.mk release_docs_spec: docs $(INSTALL_DIR) $(RELSYSDIR) $(INSTALL_DATA) $(GIF_FILES) $(HTMLDIR)/*.html $(RELSYSDIR) - $(INSTALL_DIR) $(SOURCE_RELSYSDIR) - $(INSTALL_DATA) $(SOURCE_INSTALL_READMES) $(SOURCE_RELSYSDIR) + $(INSTALL_DIR) $(REDIRECT_HTML_RELSYSDIR) + $(INSTALL_DATA) $(REDIRECT_HTML_FILES) $(REDIRECT_HTML_RELSYSDIR) release_spec: diff --git a/system/doc/installation_guide/install.xml b/system/doc/installation_guide/install-binary.xml index c1b930a4bd..ac4192586d 100644 --- a/system/doc/installation_guide/install.xml +++ b/system/doc/installation_guide/install-binary.xml @@ -21,7 +21,7 @@ </legalnotice> - <title>Installation</title> + <title>Installing the Binary Release</title> <prepared>Peter Högfeldt</prepared> <responsible>Peter Högfeldt</responsible> <docno></docno> @@ -29,27 +29,10 @@ <checked></checked> <date>1997-05-26</date> <rev>C</rev> - <file>install.xml</file> + <file>install-binary.xml</file> </header> <section> - <title>Source</title> - <p>This document describes installation procedures for - binary releases. Documentation of build and installation - procedures for the source release can be found in the source - tree at the following locations:</p> - <taglist> - <tag>Building and Installing Erlang/OTP</tag> - <item><url href="source/INSTALL.html"><c>$ERL_TOP/INSTALL.md</c></url></item> - <tag>Cross Compiling Erlang/OTP</tag> - <item><url href="source/INSTALL-CROSS.html"><c>$ERL_TOP/INSTALL-CROSS.md</c></url></item> - <tag>How to Build Erlang/OTP on Windows</tag> - <item><url href="source/INSTALL-WIN32.html"><c>$ERL_TOP/INSTALL-WIN32.md</c></url></item> - </taglist> - <p>Where <c>$ERL_TOP</c> is the top directory in the source tree.</p> - </section> - - <section> <title>UNIX</title> <section> @@ -73,7 +56,7 @@ which is <c><![CDATA[<PREFIX>.tar.gz]]></c>, where <c><![CDATA[<PREFIX>]]></c> is a string denoting the particular Erlang/OTP release, e.g. <c>otp_LXA_11930_sunos5_R9B</c>.</p> - <p>Wherever the string <c><![CDATA[<PREFIX>]]></c> is used below, it should + <p>Wherever the string <c><![CDATA[<PREFIX>]]></c> is used below, it should be replaced by the actual name prefix of the compressed tar file.</p> <p>The tape archive file does not have one single directory in which all other files are rooted. Therefore the tape archive file must be @@ -162,4 +145,3 @@ ln -s /usr/local/erlang/otp_r7b/bin/erl /usr/local/bin/erl </pre> </section> </section> </chapter> - diff --git a/system/doc/installation_guide/make.dep b/system/doc/installation_guide/make.dep index 3d1477935d..3878f4ac9d 100644 --- a/system/doc/installation_guide/make.dep +++ b/system/doc/installation_guide/make.dep @@ -9,5 +9,5 @@ # TeX files that the DVI file depend on # ---------------------------------------------------- -book.dvi: book.tex install.tex part.tex verification.tex +book.dvi: book.tex install-binary.tex part.tex verification.tex diff --git a/system/doc/installation_guide/part.xml b/system/doc/installation_guide/part.xml index 3019d2e118..fceacdd8f6 100644 --- a/system/doc/installation_guide/part.xml +++ b/system/doc/installation_guide/part.xml @@ -4,7 +4,7 @@ <part xmlns:xi="http://www.w3.org/2001/XInclude"> <header> <copyright> - <year>2000</year><year>2009</year> + <year>2000</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>Installation Guide</title> @@ -31,7 +31,10 @@ <description> <p>How to install Erlang/OTP on UNIX or Windows.</p> </description> - <xi:include href="install.xml"/> + <xi:include href="install-binary.xml"/> <xi:include href="verification.xml"/> + <xi:include href="INSTALL.xml"/> + <xi:include href="INSTALL-CROSS.xml"/> + <xi:include href="INSTALL-WIN32.xml"/> </part> diff --git a/system/doc/installation_guide/xmlfiles.mk b/system/doc/installation_guide/xmlfiles.mk index 7e1235b64d..dee67b3c70 100644 --- a/system/doc/installation_guide/xmlfiles.mk +++ b/system/doc/installation_guide/xmlfiles.mk @@ -1,21 +1,24 @@ # # %CopyrightBegin% -# -# Copyright Ericsson AB 2009. All Rights Reserved. -# +# +# Copyright Ericsson AB 2009-2010. 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% # INST_GUIDE_CHAPTER_FILES = \ - install.xml \ - verification.xml + install-binary.xml \ + verification.xml \ + INSTALL.xml \ + INSTALL-CROSS.xml \ + INSTALL-WIN32.xml diff --git a/system/doc/reference_manual/expressions.xml b/system/doc/reference_manual/expressions.xml index fa7870d96c..714ecccaf6 100644 --- a/system/doc/reference_manual/expressions.xml +++ b/system/doc/reference_manual/expressions.xml @@ -4,7 +4,7 @@ <chapter> <header> <copyright> - <year>2003</year><year>2009</year> + <year>2003</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>Expressions</title> @@ -217,12 +217,16 @@ lists:keysearch(Name, 1, List)</code> <p>In the second form of function calls, <c>ExprF(Expr1,...,ExprN)</c>, <c>ExprF</c> must be an atom or evaluate to a fun.</p> + <p>If <c>ExprF</c> is an atom the function is said to be called by - using the <em>implicitly qualified function name</em>. If - <c>ExprF/N</c> is the name of a function explicitly or - automatically imported from module <c>M</c>, then the call is - short for <c>M:ExprF(Expr1,...,ExprN)</c>. Otherwise, - <c>ExprF/N</c> must be a locally defined function. Examples:</p> + using the <em>implicitly qualified function name</em>. If the + function <c>ExprF</c> is locally defined, it is called. + Alternatively if <c>ExprF</c> is explicitly imported from module + <c>M</c>, <c>M:ExprF(Expr1,...,ExprN)</c> is called. If + <c>ExprF</c> is neither declared locally nor explicitly + imported, <c>ExprF</c> must be the name of an automatically + imported BIF. Examples:</p> + <code type="none"> handle(Msg, State) spawn(m, init, [])</code> @@ -238,16 +242,85 @@ Fun2([1,2], [3,4]) fun lists:append/2([1,2], [3,4]) => [1,2,3,4]</code> - <p>To avoid possible ambiguities, the fully qualified function - name must be used when calling a function with the same name as - a BIF, and the compiler does not allow defining a function with - the same name as an explicitly imported function.</p> + <p>Note that when calling a local function, there is a difference - between using the implicitly or fully qualified function name, as - the latter always refers to the latest version of the module. See - <seealso marker="code_loading">Compilation and Code Loading</seealso>.</p> + between using the implicitly or fully qualified function name, as + the latter always refers to the latest version of the module. See + <seealso marker="code_loading">Compilation and Code Loading</seealso>.</p> + <p>See also the chapter about <seealso marker="functions#eval">Function Evaluation</seealso>.</p> + + <section> + <title>Local Function Names Clashing With Auto-imported BIFs</title> + <p>If a local function has the same name as an auto-imported BIF, + the semantics is that implicitly qualified function calls are + directed to the locally defined function, not to the BIF. To avoid + confusion, there is a compiler directive available, + <c>-compile({no_auto_import,[F/A]})</c>, that makes a BIF not + being auto-imported. In certain situations, such a compile-directive + is mandatory.</p> + + <warning><p>Before OTP R14A (ERTS version 5.8), an implicitly + qualified function call to a function having the same name as an + auto-imported BIF always resulted in the BIF being called. In + newer versions of the compiler the local function is instead + called. The change is there to avoid that future additions to the + set of auto-imported BIFs does not silently change the behavior + of old code.</p> + + <p>However, to avoid that old (pre R14) code changed it's + behavior when compiled with OTP version R14A or later, the + following restriction applies: If you override the name of a BIF + that was auto-imported in OTP versions prior to R14A (ERTS version + 5.8) and have an implicitly qualified call to that function in + your code, you either need to explicitly remove the auto-import + using a compiler directive, or replace the call with a fully + qualified function call, otherwise you will get a compilation + error. See example below:</p> </warning> + + <code type="none"> +-export([length/1,f/1]). + +-compile({no_auto_import,[length/1]}). % erlang:length/1 no longer autoimported + +length([]) -> + 0; +length([H|T]) -> + 1 + length(T). %% Calls the local funtion length/1 + +f(X) when erlang:length(X) > 3 -> %% Calls erlang:length/1, + %% which is allowed in guards + long.</code> + + <p>The same logic applies to explicitly imported functions from + other modules as to locally defined functions. To both import a + function from another module and have the function declared in the + module at the same time is not allowed.</p> + + <code type="none"> +-export([f/1]). + +-compile({no_auto_import,[length/1]}). % erlang:length/1 no longer autoimported + +-import(mod,[length/1]). + +f(X) when erlang:length(X) > 33 -> %% Calls erlang:lenght/1, + %% which is allowed in guards + + erlang:length(X); %% Explicit call to erlang:length in body + +f(X) -> + length(X). %% mod:length/1 is called</code> + + + <p>For auto-imported BIFs added to Erlang in release R14A and thereafter, + overriding the name with a local function or explicit import is always + allowed. However, if the <c>-compile({no_auto_import,[F/A])</c> + directive is not used, the compiler will issue a warning whenever + the function is called in the module using the implicitly qualified + function name.</p> + </section> </section> <section> @@ -1257,6 +1330,9 @@ end</pre> <cell align="left" valign="middle"><c>is_bitstring/1</c></cell> </row> <row> + <cell align="left" valign="middle"><c>is_boolean/1</c></cell> + </row> + <row> <cell align="left" valign="middle"><c>is_float/1</c></cell> </row> <row> diff --git a/system/doc/reference_manual/records.xml b/system/doc/reference_manual/records.xml index e2fe5fe8de..d01d883ef3 100644 --- a/system/doc/reference_manual/records.xml +++ b/system/doc/reference_manual/records.xml @@ -4,7 +4,7 @@ <chapter> <header> <copyright> - <year>2003</year><year>2009</year> + <year>2003</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>Records</title> @@ -145,6 +145,29 @@ is_person(_P) -> </section> <section> + <title>Nested records</title> + <p>Beginning with R14 parentheses when accessing or updating nested + records can be omitted. Assuming we have the following record + definitions:</p> + <pre> +-record(nrec0, {name = "nested0"}). +-record(nrec1, {name = "nested1", nrec0=#nrec0{}}). +-record(nrec2, {name = "nested2", nrec1=#nrec1{}}). + +N2 = #nrec2{}, + </pre> + <p>Before R14 you would have needed to use parentheses as following:</p> + <pre> +"nested0" = ((N2#nrec2.nrec1)#nrec1.nrec0)#nrec0.name, +N0n = ((N2#nrec2.nrec1)#nrec1.nrec0)#nrec0{name = "nested0a"}, + </pre> + <p>Since R14 you can also write:</p> + <pre> +"nested0" = N2#nrec2.nrec1#nrec1.nrec0#nrec0.name, +N0n = N2#nrec2.nrec1#nrec1.nrec0#nrec0{name = "nested0a"},</pre> + </section> + + <section> <title>Internal Representation of Records</title> <p>Record expressions are translated to tuple expressions during compilation. A record defined as</p> diff --git a/system/doc/reference_manual/typespec.xml b/system/doc/reference_manual/typespec.xml index a3660713e4..52dc0c943e 100755 --- a/system/doc/reference_manual/typespec.xml +++ b/system/doc/reference_manual/typespec.xml @@ -96,7 +96,7 @@ Type :: any() %% The top type, the set of all Erlang terms. | none() %% The bottom type, contains no terms. | pid() | port() - | ref() + | reference() | [] %% nil | Atom | Binary diff --git a/system/doc/top/highlights.xml b/system/doc/top/highlights.xml index a30742aed6..251bb1a47d 100644 --- a/system/doc/top/highlights.xml +++ b/system/doc/top/highlights.xml @@ -4,7 +4,7 @@ <chapter> <header> <copyright> - <year>2006</year><year>2009</year> + <year>2006</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>Highlights</title> @@ -28,133 +28,53 @@ <rev>A</rev> <file>highlights.xml</file> </header> - <p>This document lists some highlights of Erlang 5.7/OTP R13A - (unpatched), compared to the previous version Erlang 5.6/OTP R12B, - with focus on things not already released as R12B patches.</p> - <p>Note: This document was compiled at the time when R13A was released - and does not list any features introduced in R13 patches.</p> + <p>This document lists some highlights of Erlang 5.8/OTP R14A + (unpatched), compared to the previous version Erlang 5.7.1/OTP R13B, + with focus on things not already released as R13B patches.</p> + <p>Note: This document was compiled at the time when R14A was released + and does not list any features introduced in R14 patches.</p> <section> <title>Erlang Language and Run-time System</title> <section> - <title>Multi-core and SMP performance improvements</title> - <p> - There SMP performance is significantly improved and will - allow most applications to scale much better on systems with many - cores or processors. Listed below are some of the most important improvements: - </p> - <list type="bulleted"> - <item> - <p> - The runtime system with SMP support now uses <em>multiple, - scheduler specific run queues</em>, instead of one globally shared - run queue. - </p> - <p> - The lock protecting the shared run queue was heavily - contended, and the shared run queue also caused Erlang - processes to randomly migrate between schedulers with - negative cache effects as a result. - </p> - <p> - With the current scheduler specific run queue solution, lock - contention due to run queue protection has been reduced, and - Erlang processes are only migrated when needed to balance the - load between the schedulers. The reduced amount of migration - also reduce lock contention on locks protecting the scheduler - specific instances of the erts internal memory allocators. - </p> - <p> - The scheduler specific run queues are also a necessity for a - lot of future planned NUMA (Non-Uniform Memory Access) - specific optimizations. - </p> - </item> - <item> - <p> - Message passing has been further optimized for parallell execution. - This makes parallell sending to one common receiver much more efficient. - </p> - </item> - <item> - <p> - Scheduler threads can now be bound to logical processors on newer - Linux ans Solaris systems. - </p> - </item> - </list> - </section> - <section> - <title>Unicode support</title> - <p> - Support for Unicode is implemented as described in EEP10. - Formatting and reading of unicode data both from terminals - and files is supported by the <c>io</c> and <c>io_lib</c> modules. - Files - can be opened in modes with automatic translation to and from - different unicode formats. The module 'unicode' contains - functions for conversion between external and internal - unicode formats and the re module has support for unicode - data. There is also language syntax for specifying string and - character data beyond the ISO-latin-1 range. - </p> - </section> + <title>New NIF features</title> + <list type="bulleted"> + <item><p>Send messages from a NIF, or from thread created by NIF, to + any local process (enif_send)</p></item> - <section> - <title>New BIF's</title> - <p> - The BIFs <c>atom_to_binary/2</c>, <c>binary_to_atom/2</c> and - <c>binary_to_existing_atom/2</c> have been added. - </p> - </section> - - <section> - <title>Independent Erlang clusters on the same host</title> - <p> - Nodes belonging to different independent clusters can now - co-exist on the same host with the help of a new - environment variable setting <c>ERL_EPMD_PORT</c>. - The environment variable is used by Erl_interface and J_interface - as well. - </p> - </section> - </section> + <item><p>Store terms between NIF calls (enif_alloc_env, + enif_make_copy)</p></item> - <section> - <title>New Applications</title> + <item><p>Create binary terms with user defined memory management + (enif_make_resource_binary)</p></item> + <item><p>Some incompatible changes made to the API. For more + information see the warning text in erl_nif(3).</p></item> + </list> + </section> <section> - <title>Reltool</title> - - <p> - Reltool is a release management tool. - It analyses a given Erlang/OTP installation and determines - various dependencies between applications. - The graphical frontend depicts the dependencies and enables - interactive customization of a target system. - The backend provides a batch interface for generation of - customized target systems. - The application is still somewhat limited and should be regarded - as experimental in this release. The intention is that this - application will be a valuable tool for making both traditional - Erlang target systems as well as standalone components in Erlang. - </p> + <title>Receive optimizations</title> + <p>Receive 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 gen_server:call(). (See gen:do_call/4 for an example + of a receive statement that will be optimized.)</p> </section> - <section> - <title>WxErlang</title> - <p> - wxErlang is an Erlang binding to the WxWidgets GUI library which - provides support for cross platform GUI applications. - wxErlang is still in beta status and the intention is that it shall - replace GS in a later stage. The Erlang debugger is also shipped in - a wxErlang version. - </p> + <title>Improved eprof</title> + <p>eprof has been reimplemented with support in the Erlang + virtual machine and is now both faster (i.e. slows down the + code being measured less) and scales much better. In + measurements we saw speed-ups compared to the old eprof + ranging from 6 times (for sequential code that only uses one + scheduler/core) up to 84 times (for parallel code that uses 8 + cores).</p> + + <p>Note: The API for the eprof has been cleaned up and extended. + See the documentation.</p> </section> - - </section> - <section> <title>New features in Existing Applications</title> @@ -162,77 +82,29 @@ <title>Common_test</title> <p> - A support client module for SSH and SFTP, <c>ct_ssh</c>, has - been introduced. - </p> - <p> - Test case groups have been introduced. With this feature - it's possible to execute groups (possibly nested) - of test cases. + It is now possible for the user to provide specific callback + modules that handle test configuration data, so that data on + arbitray form can be accessed (e.g. by reading files or by + communicating with a configuration server process). Two + default callback modules have been introduced in Common Test: + ct_config_plain and ct_config_xml. The former is used to + handle the traditional Common Test configuration files (with + terms on key-value tuple form) and the latter to handle + configuration data on XML representation. </p> <p> - A group definition contains a name tag, a list of - properties and a list of test cases (including possible - nested group definitions). The properties make it possible - to execute test cases in parallel, in sequence and in - shuffled order. It is also possible to repeat test cases - according to different criteria. + The run_test script has been replaced by a program (with the + same name) which can be executed without explicit + installation. The start flags are the same as for the legacy + start script. </p> </section> - - <section> - <title>Dialyzer</title> - <p> - The analysis now accepts <em>opaque type declarations</em> and - detects - violations of opaqueness of terms of such types. Starting - with R13, many Erlang/OTP standard libraries (array, dict, - digraph, ets, gb_sets, gb_trees, queue, and sets) contain - opaque type declarations of their main data types. Dialyzer - will spit out warnings in code that explicitly depends on the - structure of these terms. - </p> - <p> - Added support for handling UTF segments in bitstreams and for - detecting obvious type errors in these segments. Warning: - This code is not terribly tested though since there are very - few Erlang programs which use Unicode-based binaries - not - surprising since this is a new language feature of R13. - </p> - <p> - Strengthened the discrepancy identification when testing for - equality and matching between terms of different types. This - detects more bugs in code. - </p> - <p> - See the Dialyzer documentation and release notes for even more - enhancements. - </p> - </section> - - <section> - <title>SSL</title> - <p> - The "new_ssl" implementation is significantly improved and should be - near product status now. - The new SSL is implemented in pure Erlang except for - the crypto routines that are implemented in the crypto driver which - is an interface to libcrypto from OpenSSL. - </p> - </section> - - <section> <title>STDLIB</title> - - <p>The Erlang scanner has been augmented as to return white-space, - comments and exact location of tokens. - This means that the scanner can easily be used in tools such as editors, - pretty printers, syntax highlighters etc. - where it is important to be able recreate the original source document. + <p> + The module binary from EEP31 (and EEP9) is implemented. </p> </section> - </section> </chapter> diff --git a/system/doc/top/incompatible.xml b/system/doc/top/incompatible.xml index ce9522725b..e09fa7272f 100644 --- a/system/doc/top/incompatible.xml +++ b/system/doc/top/incompatible.xml @@ -4,7 +4,7 @@ <chapter> <header> <copyright> - <year>2006</year><year>2009</year> + <year>2006</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>Potential Incompatibilities</title> @@ -29,353 +29,241 @@ <file>incompatible.xml</file> </header> <p>This document contains a list of potential incompatibilities - between Erlang 5.7/OTP R12A and Erl 5.6.5/OTP R12B-5, + between Erlang 5.8/OTP R14A and Erl 5.7.5/OTP R13B04, and is an extract from the release notes for the respective applications.</p> <section> - <title>compiler</title> + <title>Tools</title> <list type="bulleted"> <item> <p> - The undocumented, unsupported, and deprecated guard BIF - <c>is_constant/1</c> has been removed.</p> - <p> - *** INCOMPATIBILITY with R12B ***</p> - <p> - Own Id: OTP-7673</p> - </item> - <item> - <p>The short-circuit operators <c>andalso</c> and - <c>orelse</c> no longer guarantees that their second - argument is either <c>true</c> or <c>false</c>. As a - consequence, <c>andalso</c>/<c>orelse</c> are now - tail-recursive.</p> - <p> - *** POTENTIAL INCOMPATIBILITY ***</p> + Xref has been updated to use the re module instead of the + deprecated regexp module.</p> + <p>*** INCOMPATIBILITY with R12B ***</p> <p> - Own Id: OTP-7748</p> + Own Id: OTP-8472</p> </item> <item> - <p>The compiler will refuse to a compile file where the - module name in the file differs from the output file - name.</p> - <p>When compiling using <c>erlc</c>, the current working - directory will no be included in the code path (unless - explicitly added using "-pa .").</p> - <p> - *** POTENTIAL INCOMPATIBILITY ***</p> - <p> - Own Id: OTP-7793</p> - </item> - <item> - <p>If a module contains an exported function with the - same name as an auto-imported BIF (such as - <c>length/1</c>), any calls to the BIF must have an - explicit <c>erlang:</c> prefix, or there will be a - compilation error (such calls would only generate a - warning in previous releases).</p> - <p>(The reason for the change is to avoid breaking code - in a future major release, R14 or R15, in which we plan - to make calls without a module prefix always call the - local function in the same module even if there is an - auto-imported BIF with the same name.)</p> + <p>eprof has been reimplemented with support in the Erlang + virtual machine and is now both faster (i.e. slows down the + code being measured less) and scales much better. In + measurements we saw speed-ups compared to the old eprof + ranging from 6 times (for sequential code that only uses one + scheduler/core) up to 84 times (for parallel code that uses 8 + cores).</p> + + <p>Note: The API for the eprof has been cleaned up and extended. + See the documentation.</p> <p> *** POTENTIAL INCOMPATIBILITY ***</p> <p> - Own Id: OTP-7873</p> + Own Id: OTP-8706</p> </item> </list> </section> <section> - <title>Erts</title> + <title>Odbc</title> <list type="bulleted"> <item> - <p>Support for Unicode is implemented as described in - EEP10. Formatting and reading of unicode data both from - terminals and files is supported by the io and io_lib - modules. Files can be opened in modes with automatic - translation to and from different unicode formats. The - module 'unicode' contains functions for conversion - between external and internal unicode formats and the re - module has support for unicode data. There is also - language syntax for specifying string and character data - beyond the ISO-latin-1 range.</p> - <p>The interactive shell will support input and output of - unicode characters when the terminal and operating system - supports it.</p> - <p>Please see the EEP and the io/io_lib manual pages as - well as the stdlib users guide for details.</p> - <p><em>I/O-protocol incompatibilities:</em></p> - <p>The io_protocol between io_Server and client is - updated to handle protocol data in unicode formats. The - updated protocol is now documented. The specification - resides in the stdlib <em>users manual</em>, which is a - new part of the manual.</p> - <p><em>io module incompatibilities:</em></p> - <p>The io:put_chars, io:get_chars and io:get_line all - handle and return unicode data. In the case where - binaries can be provided (as to io:put_chars), they shall - be encoded in UTF-8. When binaries are returned (as by - io:get_line/get_chars when the io_server is set in - <em>binary mode</em>) the returned data is also - <em>always</em> encoded as UTF-8. The file module however - still returns byte-oriented data, why file:read can be - used instead of io:get_chars to read binary data in - ISO-latin-1.</p> - <p><em>io_lib module incompatibilities:</em></p> - <p>io_lib:format can, given new format directives (i.e - "~ts" and "~tc"), return lists containing integers larger - than 255. </p> - <p> - *** POTENTIAL INCOMPATIBILITY ***</p> - <p> - Own Id: OTP-7648 Aux Id: OTP-7580 OTP-7514 OTP-7494 - OTP-7443 OTP-7181 EEP10 EEP11 </p> - </item> - <item> - <p> - The undocumented, unsupported, and deprecated guard BIF - <c>is_constant/1</c> has been removed.</p> - <p> - *** INCOMPATIBILITY with R12B ***</p> - <p> - Own Id: OTP-7673</p> - </item> - <item> - <p>The short-circuit operators <c>andalso</c> and - <c>orelse</c> no longer guarantees that their second - argument is either <c>true</c> or <c>false</c>. As a - consequence, <c>andalso</c>/<c>orelse</c> are now - tail-recursive.</p> + <p> + Now supports SQL_TYPE_TIMESTAMP on the format {{YY, MM, DD}, + {HH, MM, SS}}. Thanks to Juhani Ränkimies. + </p> <p> *** POTENTIAL INCOMPATIBILITY ***</p> <p> - Own Id: OTP-7748</p> + Own Id: OTP-8511</p> </item> - <item> - <p>The compiler will refuse to a compile file where the - module name in the file differs from the output file - name.</p> - <p>When compiling using <c>erlc</c>, the current working - directory will no be included in the code path (unless - explicitly added using "-pa .").</p> + </list> + </section> + + <section> + <title>Ssh</title> + <list type="bulleted"> + <item> <p> - *** POTENTIAL INCOMPATIBILITY ***</p> + The configuration parameter ip_v6_disabled is now available, + which makes it possible for the user to alter the IP version + SSH shall use.</p> <p> - Own Id: OTP-7793</p> - </item> - <item> - <p>The deprecated functions <c>erlang:fault/1</c>, - <c>erlang:fault/2</c>, and <c>file:rawopen/2</c> have - been removed.</p> + *** POTENTIAL INCOMPATIBILITY ***</p> <p> - *** POTENTIAL INCOMPATIBILITY ***</p> + Own Id: OTP-8535</p> + </item> + <item> <p> - Own Id: OTP-7812</p> - </item> - <item> - <p>The escape sequences <c>\x</c> and <c>\{</c> have been - assigned new interpretations (they used to return the - ASCII code for <c>x</c> and <c>{</c> respectively). One - or more octal characters inside curly brackets after a - leading backslash is from now on an alternative to the - existing syntax <c>\NNN</c>, but can also be used for - codes greater than 255. In a similar fashion, one or more - hexadecimal characters can be put inside curly brackets - after a leading <c>\x</c>. Furthermore, the escape - sequences <c>\xH</c> and <c>\xHH</c>, where N is a - hexadecimal character, can be used for codes less than - 256.</p> - <p>NOTE: These new escape sequences are still considered - experimental and may be changed in the R13B release.</p> + Removed deprecated modules (ssh_ssh, ssh_sshd and ssh_cm) and + functions (ssh_sftp:connect and ssh_sftp:stop).</p> <p> - *** POTENTIAL INCOMPATIBILITY ***</p> + *** POTENTIAL INCOMPATIBILITY ***</p> <p> - Own Id: OTP-7855</p> - </item> - </list> - </section> - - <section> - <title>Inets</title> - <list type="bulleted"> + Own Id: OTP-8596</p> + </item> <item> <p> - [httpc] - The inets http client will now use persistent - connections without pipelining as default and if a - pipeline timeout is set it will pipeline the requests on - the persistent connections.</p> + Aligned error message with used version (SSH_FX_FAILURE vs + SSH_FX_NOT_A_DIRECTORY, the latter introduced in version 6).</p> <p> *** POTENTIAL INCOMPATIBILITY ***</p> <p> - Own Id: OTP-7463</p> - </item> + Own Id: OTP-8644</p> + </item> </list> </section> <section> - <title>Jinterface</title> + <title>ERTS</title> <list> <item> - <p> - A number of fixes and improvements from the ErlIDE group; - Vlad Dumitrescu and Jakob Cederlund: JDK 1.5 is now a - minimal requirement for building Jinterface. New method: - OtpEpmd.lookupNames. OtpErlangList is now iterable. - Non-proper lists are now allowed - you have to test if a - list is proper or not. Non-proper lists can also be - created. New methods: isProper, getHead, getTail and - getNthTail. The get tail methods creates a sublist object - that re-uses the original list. OtpErlangPid is now - Comparable. Empty atoms can now be constructed, a missing - feature pointed out by Sebastien Boisgerault on - erlang-questions.</p> + <p>Some incompatible changes made to the NIF API. For more + information see the warning text in erl_nif(3).</p> <p> *** POTENTIAL INCOMPATIBILITY ***</p> <p> - Own Id: OTP-7832</p> + Own Id: OTP-8555</p> </item> </list> </section> <section> - <title>Kernel</title> + <title>STDLIB</title> <list type="bulleted"> <item> - <p>The deprecated functions <c>erlang:fault/1</c>, - <c>erlang:fault/2</c>, and <c>file:rawopen/2</c> have - been removed.</p> + <p>When defining macros the closing right parenthesis before the + dot is now mandatory.</p> <p> *** POTENTIAL INCOMPATIBILITY ***</p> <p> - Own Id: OTP-7812</p> + Own Id: OTP-8562</p> </item> </list> </section> <section> - <title>SSH</title> + <title>Compiler and STDLIB</title> <list type="bulleted"> <item> <p> - Ssh timeouts will now behave as expected i.e. defaults to - infinity. Only the user of the ssh application can know of - a reasonable timeout value for their application.</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 type="bulleted"> + <item>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</item> + + <item>Explicitly importing a function having a name clashing with + the name of an autoimported BIF that was present (and + autoimported) before OTP R14A</item> + + <item>Using any form of the old compiler directive nowarn_bif_clash</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 erlang to call the BIF, or you can remove the + auto-import of that specific BIF by using the new compiler + directive -compile({no_auto_import,[F/A]})., 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 nowarn_bif_clash compiler directive, might + need changing to be accepted by the compiler.</p> <p> *** POTENTIAL INCOMPATIBILITY ***</p> <p> - Own Id: OTP-7807</p> + Own Id: OTP-8579</p> </item> <item> <p> - Added the message {ssh_channel_up, ChannelId, - ConnectionManager} that shall be handled by the channel - callback handle_msg/2. This makes the function - handle_msg/2 a mandatory function for ssh channels - implementations which it was not in ssh-1.1.</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-7828</p> + Own Id: OTP-8669</p> </item> - </list> - </section> - - <section> - <title>STDLIB</title> - <list type="bulleted"> <item> - <p>The functions <c>lists:seq/1,2</c> return the empty - list in a few cases when they used to generate an - exception, for example <c>lists:seq(1, 0)</c>. See - lists(3) for details. (Thanks to Richard O'Keefe.)</p> <p> - *** POTENTIAL INCOMPATIBILITY ***</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> - Own Id: OTP-7230</p> - </item> - <item> - <p>Support for Unicode is implemented as described in - EEP10. Formatting and reading of unicode data both from - terminals and files is supported by the io and io_lib - modules. Files can be opened in modes with automatic - translation to and from different unicode formats. The - module 'unicode' contains functions for conversion - between external and internal unicode formats and the re - module has support for unicode data. There is also - language syntax for specifying string and character data - beyond the ISO-latin-1 range.</p> - <p>The interactive shell will support input and output of - unicode characters when the terminal and operating system - supports it.</p> - <p>Please see the EEP and the io/io_lib manual pages as - well as the stdlib users guide for details.</p> - <p><em>I/O-protocol incompatibilities:</em></p> - <p>The io_protocol between io_Server and client is - updated to handle protocol data in unicode formats. The - updated protocol is now documented. The specification - resides in the stdlib <em>users manual</em>, which is a - new part of the manual.</p> - <p><em>io module incompatibilities:</em></p> - <p>The io:put_chars, io:get_chars and io:get_line all - handle and return unicode data. In the case where - binaries can be provided (as to io:put_chars), they shall - be encoded in UTF-8. When binaries are returned (as by - io:get_line/get_chars when the io_server is set in - <em>binary mode</em>) the returned data is also - <em>always</em> encoded as UTF-8. The file module however - still returns byte-oriented data, why file:read can be - used instead of io:get_chars to read binary data in - ISO-latin-1.</p> - <p><em>io_lib module incompatibilities:</em></p> - <p>io_lib:format can, given new format directives (i.e - "~ts" and "~tc"), return lists containing integers larger - than 255. </p> - <p> - *** POTENTIAL INCOMPATIBILITY ***</p> - <p> - Own Id: OTP-7648 Aux Id: OTP-7580 OTP-7514 OTP-7494 - OTP-7443 OTP-7181 EEP10 EEP11 </p> - </item> - <item> - <p> - <c>filelib:fold_files/5</c> now uses the <c>re</c> module - instead of the <c>regexp</c> module for regular - expression matching. In practice, this change will not be - a problem for most regular expressions used for - <c>filelib:fold_files/5</c>. (The major difference in - regular expression is that parenthesis and curly brackets - is treated as literal characters by <c>regexp</c> but as - special characters by <c>re</c>; fortunately, those - characters are rarely used in filenames.)</p> - <p> - *** POTENTIAL INCOMPATIBILITY ***</p> + *** POTENTIAL INCOMPATIBILITY ***</p> <p> - Own Id: OTP-7819</p> + Own Id: OTP-8671</p> </item> + </list> + </section> + + <section> + <title>Erl_interface</title> + <list type="bulleted"> <item> - <p> - <c>digraph:new(Type)</c> will now cause a <c>badarg</c> - exception if <c>Type</c> is not a valid type. Similarly, - <c>digraph_utils:subgraph/2,3</c> will now cause a - <c>badarg</c> if the arguments are invalid. (Those - functions used to return error tuples if something was - wrong.)</p> + <p>Compact IEEE 754 double encoding in external binary format + for ei</p> + + <p>Implement the compact IEEE 754 double encoding in external + binary format for ei. Encoding for ei now always produces the + NEW_FLOAT_EXT format. Decoding and term printing handle both + the old ERL_FLOAT_EXT encoding and the new NEW_FLOAT_EXT + encoding.</p> + + <p>Legacy erl_interface code also handles the new encoding, but + still produces the ERL_FLOAT_EXT encoding by default.</p> + + <p>Also enable the DFLAG_NEW_FLOATS distribution flag.</p> + + <p>ei_get_type() will return ERL_FLOAT_EXT regardless if the + external format is encoded with ERL_FLOAT_EXT or + NEW_FLOAT_EXT for doubles.</p> + + <p>Reduce the number of copies of the code for encoding and + decoding doubles throughout ei and erl_interface by instead + calling the ei encoding and decoding functions wherever + possible.</p> + + <p>Restore commented-out float tests in ei_decode_SUITE and + ei_encode_SUITE in lib/erl_interface/test. Modify them to + make them match the style of other tests in the same suites.</p> + + <p>These changes are based on an ei float patch from Serge + Aleynikov originally submitted against R12B-2 in July 2008 + and reworked by Steve Vinoski May 2010.</p> <p> *** POTENTIAL INCOMPATIBILITY ***</p> <p> - Own Id: OTP-7824</p> + Own Id: OTP-8684</p> </item> + </list> + </section> + <section> + <title>Debugger and STDLIB</title> + <list type="bulleted"> <item> - <p>The argument passed to <c>random:uniform/1</c> must - now be an integer (as stated in the documentation). In - previous releases, a floating point number was also - allowed.</p> + <p> The predefined builtin type tid() has been removed. Instead, + ets:tid() should be used.</p> <p> *** POTENTIAL INCOMPATIBILITY ***</p> <p> - Own Id: OTP-7827</p> + Own Id: OTP-8687</p> </item> </list> </section> diff --git a/system/doc/tutorial/complex6.erl b/system/doc/tutorial/complex6.erl new file mode 100644 index 0000000000..a5f51886c8 --- /dev/null +++ b/system/doc/tutorial/complex6.erl @@ -0,0 +1,11 @@ +-module(complex6). +-export([foo/1, bar/1]). +-on_load(init/0). + +init() -> + ok = erlang:load_nif("./complex6_nif", 0). + +foo(_X) -> + exit(nif_library_not_loaded). +bar(_Y) -> + exit(nif_library_not_loaded). diff --git a/system/doc/tutorial/complex6_nif.c b/system/doc/tutorial/complex6_nif.c new file mode 100644 index 0000000000..b656ed43ce --- /dev/null +++ b/system/doc/tutorial/complex6_nif.c @@ -0,0 +1,32 @@ +#include "erl_nif.h" + +extern int foo(int x); +extern int bar(int y); + +static ERL_NIF_TERM foo_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) +{ + int x, ret; + if (!enif_get_int(env, argv[0], &x)) { + return enif_make_badarg(env); + } + ret = foo(x); + return enif_make_int(env, ret); +} + +static ERL_NIF_TERM bar_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) +{ + int y, ret; + if (!enif_get_int(env, argv[0], &y)) { + return enif_make_badarg(env); + } + ret = bar(y); + return enif_make_int(env, ret); +} + +static ErlNifFunc nif_funcs[] = { + {"foo", 1, foo_nif}, + {"bar", 1, bar_nif} +}; + +ERL_NIF_INIT(complex6, nif_funcs, NULL, NULL, NULL, NULL) + diff --git a/system/doc/tutorial/nif.xmlsrc b/system/doc/tutorial/nif.xmlsrc new file mode 100644 index 0000000000..f9197c69dd --- /dev/null +++ b/system/doc/tutorial/nif.xmlsrc @@ -0,0 +1,136 @@ +<?xml version="1.0" encoding="latin1" ?> +<!DOCTYPE chapter SYSTEM "chapter.dtd"> + +<chapter> + <header> + <copyright> + <year>2000</year><year>2009</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 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>NIFs</title> + <prepared></prepared> + <docno></docno> + <date></date> + <rev></rev> + <file>nif.xml</file> + </header> + <p>This is an example of how to solve the <seealso marker="example">example problem</seealso> + by using NIFs. NIFs where introduced in R13B03 as an experimental + feature. It is a simpler and more efficient way of calling C-code + than using port drivers. NIFs are most suitable for synchronous functions like + <c>foo</c> and <c>bar</c> in the example, that does some + relatively short calculations without side effects and return the result.</p> + <section> + <title>NIFs</title> + <p>A NIF (Native Implemented Function) is a function that is + implemented in C instead of Erlang. NIFs appear as any other functions to + the callers. They belong to a module and are called like any other Erlang + functions. The NIFs of a module are compiled and linked into a dynamic + loadable shared library (SO in Unix, DLL in Windows). The NIF library must + be loaded in runtime by the Erlang code of the module.</p> + <p>Since a NIF library is dynamically linked into the emulator + process, this is the fastest way of calling C-code from Erlang (alongside + port drivers). Calling NIFs requires no context switches. But it is also + the least safe, because a crash in a NIF will bring the emulator down + too.</p> + </section> + + <section> + <title>Erlang Program</title> + <p>Even if all functions of a module will be NIFs, you still need an Erlang + module for two reasons. First, the NIF library must be explicitly loaded + by Erlang code in the same module. Second, all NIFs of a module must have + an Erlang implementation as well. Normally these are minimal stub + implementations that throw an exception. But it can also be used as + fallback implementations for functions that do not have native + implemenations on some architectures.</p> + <p>NIF libraries are loaded by calling <c>erlang:load_nif/2</c>, with the + name of the shared library as argument. The second argument can be any + term that will be passed on to the library and used for + initialization.</p> + + <codeinclude file="complex6.erl" tag="" type="none"></codeinclude> + + <p>We use the directive <c>on_load</c> to get function <c>init</c> to be + automatically called when the module is loaded. If <c>init</c> + returns anything other than <c>ok</c>, such when the loading of + the NIF library fails in this example, the module will be + unloaded and calls to functions within it will fail.</p> + <p>Loading the NIF library will override the stub implementations + and cause calls to <c>foo</c> and <c>bar</c> to be dispatched to + the NIF implementations instead.</p> + </section> + <section> + <title>NIF library code</title> + <p>The NIFs of the module are compiled and linked into a + shared library. Each NIF is implemented as a normal C function. The macro + <c>ERL_NIF_INIT</c> together with an array of structures defines the names, + arity and function pointers of all the NIFs in the module. The header + file <c>erl_nif.h</c> must be included. Since the library is a shared + module, not a program, no main function should be present.</p> + <p>The function arguments passed to a NIF appears in an array <c>argv</c>, + with <c>argc</c> as the length of the array and thus the arity of the + function. The Nth argument of the function can be accessed as + <c>argv[N-1]</c>. NIFs also takes an environment argument that + serves as an opaque handle that is needed to be passed on to + most API functions. The environment contains information about + the calling Erlang process.</p> + + <codeinclude file="complex6_nif.c" tag="" type="none"></codeinclude> + + <p>The first argument to <c>ERL_NIF_INIT</c> must be the name of the + Erlang module as a C-identifier. It will be stringified by the + macro. The second argument is the array of <c>ErlNifFunc</c> + structures containing name, arity and function pointer of + each NIF. The other arguments are pointers to callback functions + that can be used to initialize the library. We do not use them + is this simple example so we set them all to <c>NULL</c>.</p> + <p>Function arguments and return values are represented as values + of type <c>ERL_NIF_TERM</c>. We use functions like <c>enif_get_int</c> + and <c>enif_make_int</c> to convert between Erlang term and C-type. + If the function argument <c>argv[0]</c> is not an integer then + <c>enif_get_int</c> will return false, in which case we return + by throwing a <c>badarg</c>-exception with <c>enif_make_badarg</c>.</p> + </section> + + <section> + <title>Running the Example</title> + <p>1. Compile the C code.</p> + <pre> +unix> <input>gcc -o complex6_nif.so -fpic -shared complex.c complex6_nif.c</input> +windows> <input>cl -LD -MD -Fe complex6_nif.dll complex.c complex6_nif.c</input></pre> + <p>2. Start Erlang and compile the Erlang code.</p> + <pre> +> <input>erl</input> +Erlang R13B04 (erts-5.7.5) [64-bit] [smp:4:4] [rq:4] [async-threads:0] [kernel-poll:false] + +Eshell V5.7.5 (abort with ^G) +1> <input>c(complex6).</input> +{ok,complex6}</pre> + <p>3. Run the example.</p> +<pre> +3> <input>complex6:foo(3).</input> +4 +4> <input>complex6:bar(5).</input> +10 +5> <input>complex6:foo("not an integer").</input> +** exception error: bad argument + in function complex6:foo/1 + called as comlpex6:foo("not an integer") +</pre> +</section> +</chapter> diff --git a/system/doc/tutorial/part.xml b/system/doc/tutorial/part.xml index 1a8a873242..ff73b668c0 100644 --- a/system/doc/tutorial/part.xml +++ b/system/doc/tutorial/part.xml @@ -4,7 +4,7 @@ <part xmlns:xi="http://www.w3.org/2001/XInclude"> <header> <copyright> - <year>2000</year><year>2009</year> + <year>2000</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,19 +13,19 @@ 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>Interoperability Tutorial</title> <prepared>Gunilla Hugosson</prepared> <docno></docno> <date>2000-01-18</date> - <rev>R7B</rev> + <rev>R14A</rev> </header> <xi:include href="introduction.xml"/> <xi:include href="overview.xml"/> @@ -34,5 +34,6 @@ <xi:include href="erl_interface.xml"/> <xi:include href="c_portdriver.xml"/> <xi:include href="cnode.xml"/> + <xi:include href="nif.xml"/> </part> diff --git a/system/doc/tutorial/xmlfiles.mk b/system/doc/tutorial/xmlfiles.mk index 794ef49774..95562bec60 100644 --- a/system/doc/tutorial/xmlfiles.mk +++ b/system/doc/tutorial/xmlfiles.mk @@ -1,19 +1,19 @@ # # %CopyrightBegin% -# -# Copyright Ericsson AB 2009. All Rights Reserved. -# +# +# Copyright Ericsson AB 2009-2010. 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% # TUTORIAL_CHAPTER_FILES = \ @@ -23,7 +23,8 @@ TUTORIAL_CHAPTER_FILES = \ erl_interface.xml \ c_portdriver.xml \ example.xml\ - overview.xml + overview.xml\ + nif.xml # appendix.xml # distribution.xml (to be part of tutorial later) |