From b8d4bd38e343488b5e8539f913650b150cab3ade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Wed, 17 May 2017 06:24:02 +0200 Subject: Add a link to the Reference Manual from the example page When doing a Google search for "bit syntax", you could end up on the programming examples page about bit syntax. The example page has some reference material, but is far from complete. Therefore, add a link to the page about bit syntax in the Reference Manual. https://bugs.erlang.org/browse/ERL-387 --- system/doc/programming_examples/bit_syntax.xml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/system/doc/programming_examples/bit_syntax.xml b/system/doc/programming_examples/bit_syntax.xml index 0af295b7b7..03645bba1b 100644 --- a/system/doc/programming_examples/bit_syntax.xml +++ b/system/doc/programming_examples/bit_syntax.xml @@ -32,6 +32,8 @@
Introduction +

The complete specification for the bit syntax appears in the + Reference Manual.

In Erlang, a Bin is used for constructing binaries and matching binary patterns. A Bin is written with the following syntax:

separated by hyphens.

Type - The type can be integer, float, or - binary. + The most commonly used types are integer, float, and binary. + See Bit Syntax Expressions in the Reference Manual for a complete description. + Signedness The signedness specification can be either signed or unsigned. Notice that signedness only matters for -- cgit v1.2.3 From 96d9a00223aaaf1df7698395be17157a836461ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Wed, 17 May 2017 06:34:00 +0200 Subject: Don't mention R12B --- system/doc/programming_examples/bit_syntax.xml | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/system/doc/programming_examples/bit_syntax.xml b/system/doc/programming_examples/bit_syntax.xml index 03645bba1b..98ad2808cf 100644 --- a/system/doc/programming_examples/bit_syntax.xml +++ b/system/doc/programming_examples/bit_syntax.xml @@ -47,7 +47,7 @@ Bin = <>]]> <> = Bin ]]>

Here, Bin is bound and the elements are bound or unbound, as in any match.

-

Since Erlang R12B, a Bin does not need to consist of a whole number of bytes.

+

A Bin does not need to consist of a whole number of bytes.

A bitstring is a sequence of zero or more bits, where the number of bits does not need to be divisible by 8. If the number @@ -184,7 +184,7 @@ end.]]> The unit size is given as unit:IntegerLiteral. The allowed range is 1-256. It is multiplied by the Size specifier to give the effective size of - the segment. Since Erlang R12B, the unit size specifies the alignment + the segment. The unit size specifies the alignment for binary segments without size.

Example:

@@ -322,21 +322,15 @@ foo(<>) ->]]>
Appending to a Binary -

Since Erlang R12B, the following function for creating a binary out of - a list of triples of integers is efficient:

+

Appending to a binary in an efficient way can be done as follows:

triples_to_bin(T, <<>>). triples_to_bin([{X,Y,Z} | T], Acc) -> - triples_to_bin(T, <>); % inefficient before R12B + triples_to_bin(T, <>); triples_to_bin([], Acc) -> Acc.]]> -

In previous releases, this function was highly inefficient, because - the binary constructed so far (Acc) was copied in each recursion step. - That is no longer the case. For more information, see - - Efficiency Guide.

-- cgit v1.2.3