Object-oriented Abstract special cases always have endless topics, even worse, many languages have mistakenly implemented object-oriented--class can be a variable type of what it is just let people write code is worse. Of course the third article on this topic has been said, and now to talk about people like to put the force of another topic-message sent.
It's customary to Han a digression first. When it comes to message sending, some people like to jump out and say, Objective-c's message is much more elegant, the code can be written in a sentence [Golang screw:you You:suck]. In fact, this has not been done thoroughly. A few years ago, the language used to be a fire, but why do people hate him so much? In fact, it is not because every token is a Chinese character, but because he does nothing like Chinese, who can speak with so many symbols ah. In fact, Objective-c is the same, no one would like to use a colon in an English sentence to separate the phrase.
While I was still in junior year, I was inspired by Apple Script (and Apple) to try to invent a language that he could write as if he was a natural language--and of course he was still a strict programming language. But this language because of its peculiar grammatical structure, I had to come up with a two times parse method. The first time parse out all the function headers, and then use these function headers to temporarily form a parser to use it to parse the part of the statement. The back of the whole also realized, and then I went to do a survey, found that people do not like, because there are too many things to input. But I am still here to paste how the original design:
phrase print (content) is external function "Writeln" end phrase phrase a (count) items of Fibonacci seq
Uence is if Count equals to 1 then of result are [1] else if Count equals to 2 then the result is [1,1] else let list is [1,1] repeat with I from 3 to count let list is list joins with item length of list-1 of List + item length of list-2 of list end, result is list-end phrase phrase (
Number) is odd be result is number mod 2 are 0 end phrase alias odd number phrase append (item) Let 0 element of of list from length of list was [item] phrase phrase ((item) is validated) in (list) are let fi ltered list to [] Repeat with item into list append item after filtered list if item are validated end RE Sult is filtered list End phrase phrase main are print odd number in A/Fibonacci sequence end Phra Se
The penultimate function declares that even the declaration of a function pointer is so elegant (as I think), the entire program is organized, we want to output the odd number of the first 10 digits in the Fibonacci sequence, and we write
Print odd number in the Fibonacci sequence
Looks more beautiful than objective-c. In fact, if you want to replace all things in Chinese, the algorithm does not need to change. Now use a space to separate a word, Chinese directly with the character is good, the rest are the same. There is no way to parse this program with the popular methods to parse. Of course, I know that you will not care about these particularly complex problems, so the digression is over here, the implementation of the language code you probably will never see, ah ha ha.
Why do you want to talk about this thing? I basically want to tell you, even if you are using object-oriented language, want to in the program to send a message to an object, this object does not have to write at the front. Why, then? Sometimes the object is more than one--this is called multiple dispatching, the famous question is how to give a bunch of object-oriented geometry classes to do their intersection function-with object-oriented practice will be particularly uncomfortable. But now let's take a look at what ordinary messaging is like.
For an object that we know what kind of person he is, sending a message is just like calling a function directly, because you don't need to resolve the function. For example, the following code:
Class Language
{public
:
void Yousuck () {...}}
;
Language Golang;
Golang. Yousuck ();