Pointer nature

zhaozj2021-02-11  209

I will talk about non-cautious exploration attitude to talk about some of the essential issues of programming languages, and there is a lost place to point out.

I think it can be divided into two kinds, one is a high-level language such as VB, Java, SmallTalk, and the other is open (or expandable), such as C, C , compilation (you It may have objection to this). The essence of the former and the latter is not that the former is a dynamic language, and the latter is a static language, but the latter has a "pointer" mechanism. Note that "pointer" I said here refers to a mechanism to be broad, and then the specific expression of "pointer" mechanism is in various languages.

The form of the pointer in assembly is unified, that is, the memory address. Whether it is code or data, the processing of content in the address is unified unrestricted, the same address is unrestricted, and the term is not limited, borrowing the terminology in software engineering, that is, the prototype of the pointer, ie the original form.

The pointer to C is the type difference. The operation of the fingered content of the pointer is also limited. The most basic pointer classification is the function pointer and data pointer, the former points to the code, the latter points to data, the operation mode is complete, and the same The pointer has different "interface" classification, such as the interface type of the function pointer, etc., but is not strict in C (which can be hidden in runtime), which is also the case that the behavior of the C language is difficult to touched.

In C , pointing to an object. I personally think it is called "handle" more suitable, so the representation of the pointer in the object-oriented language is the handle (handle is highly limited in dynamic language, difficult to expand). ). The handle is a high-level form of a pointer, with more stringent type detection, which has a strict principle or through an existing doctrine. So what is it in the handle? I think there should be only one thing in it - type, note that I am not a class but the type of interface is type (may lead the concept of an exhibition of the abstract algebra). So what is it specifically? I can say there are two things, 1. The address and type of data, 2. The address and type of the function of the function (ie the dummy address may be implemented in a pointer array). If the above content contained in a handle is in another type, then the latter can map to the former, and it will be "cut", which is discrete mathematics. So can you say that there is a virtual table address and a member data address in the pointer to the object and their type identity configuration?

There is a vocabulary that may represent the high-border programming technology. Recently, it has been mentioned more, this is the "design pattern", the design mode is so important, which can give the code powerful reuse ability, and powerful complex Use the sex from there? I think it is mainly the code-flexible runtime dynamic behavior, while the root of the active behavior is from what? I think it is a pointer mechanism, and the design mode implementation is the indirectity of the pointer mechanism. How does the pointer bring powerful flexibility? So what is the essence of a pointer? How to use popularity to explain the nature of the pointer (because the highest deep is often popular :))? I am thinking. . . . . .

In the future, I will continue to think about the essence of the pointer, I hope everyone will discuss it.

转载请注明原文地址:https://www.9cbs.com/read-3724.html

New Post(0)