Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Erlang (programming language)
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Data types== Erlang has eight primitive [[data type]]s: ;Integers: Integers are written as sequences of decimal digits, for example, 12, 12375 and -23427 are integers. Integer arithmetic is exact and only limited by available memory on the machine. (This is called [[arbitrary-precision arithmetic]].) ;Atoms: Atoms are used within a program to denote distinguished values. They are written as strings of consecutive alphanumeric characters, the first character being lowercase. Atoms can contain any character if they are enclosed within single quotes and an escape convention exists which allows any character to be used within an atom. Atoms are never garbage collected and should be used with caution, especially if using dynamic atom generation. ;Floats: Floating point numbers use the [[binary64|IEEE 754 64-bit representation]]. ;References: References are globally unique symbols whose only property is that they can be compared for equality. They are created by evaluating the Erlang primitive <code>make_ref()</code>. ;Binaries: A binary is a sequence of bytes. Binaries provide a space-efficient way of storing binary data. Erlang primitives exist for composing and decomposing binaries and for efficient input/output of binaries. ;Pids: Pid is short for ''process identifier''{{snd}}a Pid is created by the Erlang primitive <code>spawn(...)</code> Pids are references to Erlang processes. ;Ports: Ports are used to communicate with the external world. Ports are created with the built-in function <code>open_port</code>. Messages can be sent to and received from ports, but these messages must obey the so-called "port protocol." ;Funs: Funs are function [[Closure (computer programming)|closures]]. Funs are created by expressions of the form: <code>fun(...) -> ... end</code>. And three compound data types: ;Tuples: Tuples are containers for a fixed number of Erlang data types. The syntax <code>{D1,D2,...,Dn}</code> denotes a tuple whose arguments are <code>D1, D2, ... Dn.</code> The arguments can be primitive data types or compound data types. Any element of a tuple can be accessed in constant time. ;Lists: Lists are containers for a variable number of Erlang data types. The syntax <code>[Dh|Dt]</code> denotes a list whose first element is <code>Dh</code>, and whose remaining elements are the list <code>Dt</code>. The syntax <code>[]</code> denotes an empty list. The syntax <code>[D1,D2,..,Dn]</code> is short for <code>[D1|[D2|..|[Dn|[]]]]</code>. The first element of a list can be accessed in constant time. The first element of a list is called the ''head'' of the list. The remainder of a list when its head has been removed is called the ''tail'' of the list. ;Maps: Maps contain a variable number of key-value associations. The syntax is<code>#{Key1=>Value1,...,KeyN=>ValueN}</code>. Two forms of [[syntactic sugar]] are provided: ;Strings: Strings are written as doubly quoted lists of characters. This is syntactic sugar for a list of the integer [[Unicode]] code points for the characters in the string. Thus, for example, the string "cat" is shorthand for <code>[99,97,116]</code>.<ref>{{cite web |url=http://erlang.org/doc/apps/stdlib/unicode_usage.html#string-and-character-literals |title=String and Character Literals |access-date=2 May 2015}}</ref> ;Records: Records provide a convenient way for associating a tag with each of the elements in a tuple. This allows one to refer to an element of a tuple by name and not by position. A pre-compiler takes the record definition and replaces it with the appropriate tuple reference. Erlang has no method to define classes, although there are external [[Library (computing)|libraries]] available.<ref>{{cite web |url=https://code.google.com/p/ect/ |title=ect β Erlang Class Transformation β add object-oriented programming to Erlang β Google Project Hosting |access-date=2 May 2015}}</ref>
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Erlang (programming language)
(section)
Add topic