# The title may be confusing. In fact, I am not pleasing to the eye. "Color" refers to Beijing dialect, which is generally "unique. To say that one person is "a color", most of them are not praise, but negative loss. # Is an operator in Erlang syntax. Therefore, the title indicates the unique Erlang operator #. I noticed that # is the result of reading programming with Erlang: 2> X = # todo {}. # todo {status = reminder, WHO = Joe, text = undefined} 3> X1 = # todo {status = urgent, text = "Fix errata in Book "}. # todo {status = urgent, WHO = Joe, text = "Fix errata in Book"} 4> X2 = x1 # todo {status = Done }. # todo {status = Done, WHO = Joe, text = "Fix errata in Book"} At first, my opinion was as follows: the operators "#" in "2>" and "3>" are simple and easy to understand. The awkward syntax is "4> ". "X2 = x1 # todo {status = Done}" indicates here. It seems that the value constraint of X2 is that the record X1 of the todo type is retained (extracted) only) "status = done. This syntax is indeed obscure, and there is little practical value or even ambiguity. "3>" has determined that X1 is a todo type record, and there is a value that cannot be changed, but changing the value of X1 in "4>" is not self-contradictory? I think the syntax created by Erlang, instead of from PROLOG and list (FP), seems to be unsuccessful. However, after reading some information from the Internet, I got a new idea. 1. Operator # There are at least two types of four different meanings and usage. The first class is used to convert numbers of different base numbers into decimal numbers, the second type is operation record ). In the first usage, # is a binary operator that converts numbers of different base numbers into decimal numbers. For example, 1> 2 #111.% convert binary 111 to decimal 7 2> 8 #111.% octal number 111 to decimal number 73 3> 16 #111.% hexadecimal number 111 to decimal number 273 second usage, # is a single object operator, directly create a new record (record) without changing the initial value. For example: 2> X = # todo {}. # todo {status = reminder, WHO = Joe, text = undefined} third usage, # is a single object operator, directly create a new record and change the initial value. For example: 3> X1 = # todo {status = urgent, text = "Fix errata in Book "}. # todo {status = urgent, WHO = Joe, text = "Fix errata in Book"} fourth usage, # A binary operator, modeled based on the recorded variables, create record and change the initial value. For example: 4> X2 = x1 # todo {status = Done }. # todo {status = Done, WHO = Joe, text = "Fix errata in Book"} 2. Characteristics of Erlang records (1) records are special tuples (tuple ), (2) The original record is saved in the hard disk file, and the last name of the file is ". HRL ", has its own initial value. For example, file records. the content in HRL is-record (todo, {status = reminder, WHO = Joe, text }). 3. Features 1> RR ("records. HRL "). [todo] The RR/1 function returns a list with the member being atomic (constant) Todo, which represents a record. The record todo is in memory. 4. Operator # features used to create a record (1) # The operator must be associated with a record in the memory only. (2) When no variable name exists before # name, it indicates the name of the record in the memory; (3) var # name {}, which indicates the record in the variable VAR; (4) # name {status = Done}, the value of the member of the metagroup, used to replace the value of an existing member with the same name in the memory record. 5. Function programming of Erlang syntax features Erlang syntax, which features a brilliant appearance of PROLOG, but inside it is the backbone of FP. The essential feature of function programming is "value" oriented and "value" centered. Everything in function language is almost all "values". variables, strings, and even functions can be used as "values. In many aspects such as function calling and expression application, "value" is often seen or hidden. Operator # Its Application in processing records is a typical embodiment of Erlang's FP nature and deserves attention.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service