What is the definition of pointer? [duplicate]

Conceptually a “pointer” is just something that “points” to something else;Is this definition is sufficient to tell exactly what a pointer is in programing languages?
Does it need to have any other features?

Programmers who come from specific language may have pre-conceived ideas of what constitutes a ‘pointer’ based on how it is used in the language So let say if he is from c/c++ language, he say’s pointers supports pointer arithmetic.Is pointer arithmetic an essential feature of a pointer?

Go has pointers and does not support pointer arithmetic. Is the ability to “dereference” the pointer essential to the concept of a pointer?

So what is the precise definition of a pointer that I can give as an answer, irrespective of any specific programming language?

1

I do not know of any general definition for “pointers”, or another related term, “references”. It’s fairly safe, however, to say that pointers and programming languages supporting pointers usually have several of the following characteristics:

  • At the very least, a pointer is a reference to other objects/values.

  • A pointer type may or may not be typed, i.e. pointers of that type may reference only a certain type of objects/values (e.g. int* vs. void* in C). Whether this characteristic is present or not may depend mostly on the nature of the supporting programming language’s type system.

  • A programming language that supports pointers may or may not have a pointer dereference operator, which resolves a pointer to the referenced object/value (e.g. unary * in C).

  • Such a programming language may or may not have an operator that creates a pointer for an object/value (e.g. unary & in C).

  • A pointer may or may not contain a null reference, i.e. not point at anything. (This feature was invented by Tony Hoare, which he now calls his Billion Dollar Mistake.) Such pointers may not be dereferenced, and cannot be the result of the pointer creation operator.

  • A pointer type may or may not support a limited form of arithmetic, e.g. incrementation/decrementation, adding/subtracting an integral value to a pointer value, subtracting two pointers of the same pointer type, etc.

  • A pointer, i.e. a reference to another object, may be implemented using memory addresses (linear, segmented, or otherwise).

5

What is the definition of pointer?

That completely, entirely depends on the language.

Both C and C++ (there’s no such language as “C/C++”!) have a solid, precise definition of pointers. For example, C99 says (§6.2.5.20):

A pointer type may be derived from a function type, an object type, or an incomplete type, called the referenced type. A pointer type describes an object whose value provides a reference to an entity of the referenced type. A pointer type derived from the referenced type T is sometimes called ‘‘pointer to T’’. The construction of a pointer type from a referenced type is called ‘‘pointer type derivation’’.

(emphasis mine)

later, when describing the & (address-of) operator (§6.5.3.2.3):

The unary & operator yields the address of its operand. If the operand
has type ‘‘type’’, the result has type ‘‘pointer to type’’.

This interpretation again suggests that a “pointer” is simply an address. (Well, not simply, but an address nevertheless.)

Is the ability to “dereference” the pointer essential to the concept of a pointer?

Again, that depends. Conceptually, Java has pointers, but you can’t dereference them. Objective-C objects are pointers too, but the compiler whines if you are trying to dereference such a pointer. (I suspect that these phenomena have a common origin – pointers are used in both languages to represent references to objects, and at an implementation level, they are also used for different clever things like polymorphism.)

So what is the precise definition of pointer i can answer irrespective of specific programming language?

Unfortunately, there’s no such thing. (Shameless self-promotion: but you can provide a link to this answer if you think it’s good enough :P)

1

What a pointer “is” is typically dependent on both the language, and the implementation of that language. e.g: Pointers in C/C++ are typically int’s which hold the memory address of the thing pointed at, however they dont necessarily have to be. Thats just how they’re usually implemented.

So, thinking about operations that can be performed on a pointer, anything other than a “deference” is really implementation dependent. Being able to do pointer arithmetic is often useful, but depends entirely on the underlying implementation.

Pointers also have a secondary role in c/c++ in that they often point at items allocated on the heap rather than the stack. This is differentiation is often not captured in other languages. Other languages tend to avoid the term “pointer” and use “reference” or “alias” instead.

Personally, I like to think, in a general sense, of pointers as a special type of alias. But when it comes to C/C++ I tend to envisage the entire language as being about memory, and pointers become just one subset of managing memory.

A pointer is a kind of variable whose value is a reference to a
point in the memory of the machine where the program is running.

Being variables they need to support operations (they would be useless otherwise), the operations supported may vary depending on the programming language.

Many new programming languages (such as Java) even go all the way to hiding pointers to the users (which we could probably say that in these languages pointers are variables supporting no operations).

I would say that any operation on pointers needs to be supported or not depending on the structure of the language. In some way al programming languages use pointers, but, the fact that not all languages give you access to them, is indicative that operations may be necessary or not depending on the structure of the language.

Here’s what I learned in CS:

  1. A variable is a named location of a value.

  2. A pointer is a variable whose value is the address of the location of a variable.

And yes, in my opinion pointers in general are dereferencable.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật