What is a reference type?
In programming language theory, a reference type is a data type that can only be accessed by references. Unlike objects of value types, objects of reference types cannot be directly embedded into composite objects and are always dynamically allocated. They are usually destroyed automatically after they become unreachable.
For immutable objects, the distinction between reference type to an immutable object type and value type is sometimes unclear, because a reference type variable to an immutable object behaves with the same semantics as a value type variable—for example, in both cases the "value" of the data the variable represents can only be changed by direct assignment to the variable (whereas for mutable objects, the data could be changed by modifying the object through another reference to the object).
This is a bit confusing. Too much information in one glob for me to handle.
So, the next question:
What is a reference?
Noun
- S: (n) mention, reference (a remark that calls attention to something or someone) "she made frequent mention of her promotion"; "there was no mention of it"; "the speaker made several references to his wife"
- S: (n) citation, cite, acknowledgment, credit, reference, mention, quotation (a short note recognizing a source of information or of a quoted passage) "the student's essay failed to list several important citations"; "the acknowledgments are usually printed at the front of a book"; "the article includes mention of similar clinical cases"
- S: (n) reference point, point of reference, reference (an indicator that orients you generally) "it is used as a reference for comparing the heating and the electrical energy involved"
- S: (n) reference book, reference, reference work, book of facts (a book to which you can refer for authoritative facts) "he contributed articles to the basic reference work on that topic"
- S: (n) character, reference, character reference (a formal recommendation by a former employer to a potential future employer describing the person's qualifications and dependability) "requests for character references are all too often answered evasively"
- S: (n) reference, denotation, extension (the most direct or specific meaning of a word or expression; the class of objects that an expression refers to) "the extension of `satellite of Mars' is the set containing only Demos and Phobos"
- S: (n) reference, consultation (the act of referring or consulting) "reference to an encyclopedia produced the answer"
- S: (n) reference, source (a publication (or a passage from a publication) that is referred to) "he carried an armful of references back to his desk"; "he spent hours looking for the source of that quotation"
- S: (n) address, computer address, reference ((computer science) the code that identifies where a piece of information is stored)
- S: (n) reference (the relation between a word or phrase and the object or idea it refers to) "he argued that reference is a consequence of conditioned reflexes"
Language and platform support
ReplyDelete* C++ has no built-in support for reference types.[dubious – discuss] However this behavior can be emulated by restricting access to a type's constructor.
* The .NET Framework makes a clear distinction between value and reference types, and allows creation of user-defined types for both kinds.
o In C#, the struct keyword defines a value type, while the class keyword defines a reference type.
o In C++/CLI, the keyword pairs value class and value struct define managed value types, while the ref class and ref struct pairs define managed reference types.
* On the Java platform, all composite and user-defined types are reference types. Only primitive types are value types.
* Windows COM objects are reference-counted reference types.
* In many scripting languages, including Python, Ruby, all types are reference types, including primitive types.
Stub icon This programming language-related article is a stub. You can help Wikipedia by expanding it.