Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 Uses in various languages  





2 See also  





3 References  














Opaque data type






Deutsch
Українська
 

Edit links
 









Article
Talk
 

















Read
Edit
View history
 








Tools
   


Actions  



Read
Edit
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Cite this page
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 
















Appearance
   

 






From Wikipedia, the free encyclopedia
 


Incomputer science, an opaque data type is a data type whose concrete data structure is not defined in an interface. This enforces information hiding, since its values can only be manipulated by calling subroutines that have access to the missing information. The concrete representation of the type is hidden from its users, and the visible implementation is incomplete. A data type whose representation is visible is called transparent.[1] Opaque data types are frequently used to implement abstract data types.

Typical examples of opaque data types include handles for resources provided by an operating systemtoapplication software. For example, the POSIX standard for threads defines an application programming interface based on a number of opaque types that represent threadsorsynchronization primitives like mutexesorcondition variables.[2]

Anopaque pointer is a special case of an opaque data type, a datatype that is declared to be a pointer to a recordordata structure of some unspecified data type. For example, the standard library that forms part of the specification of the C programming language provides functions for file input and output that return or take values of type "pointer to FILE" that represent file streams (see C file input/output), but the concrete implementation of the type FILE is not specified.[3]

Uses in various languages[edit]

Some languages, such as C, allow the declaration of opaque records (structs), whose size and fields are hidden from the client. The only thing that the client can do with an object of such a type is to take its memory address, to produce an opaque pointer.

If the information provided by the interface is sufficient to determine the type's size, then clients can declare variables, fields, and arrays of that type, assign their values, and possibly compare them for equality. This is usually the case for opaque pointers.

In some languages, such as Java, the only kind of opaque type provided is the opaque pointer. Indeed, in Java (and several other languages) records are always handled through pointers.

Some languages allow partially opaque types, e.g. a record which has some public fields, known and accessible to all clients, and some hidden fields which are not revealed in the interface. Such types play a fundamental role in object-oriented programming.

The information which is missing in the interface may be declared in its implementation, or in another "friends-only" interface. This second option allows the hidden information to be shared by two or more modules.

See also[edit]

References[edit]

  1. ^ Friedman, Daniel P.; Wand, Mitchell; Haynes, Christopher T. (2001). Essentials of Programming Languages (2nd ed.). MIT Press. p. 42. ISBN 978-0-262-06217-6.
  • ^ Butenhof, David R. (1997). Programming with POSIX Threads. Addison-Wesley. p. 31. ISBN 978-0-201-63392-4.
  • ^ Kernighan, Brian W.; Ritchie, Dennis M. (1988). The C Programming Language (2nd ed.). Prentice Hall. ISBN 0-13-110362-8.

  • t
  • e

  • Retrieved from "https://en.wikipedia.org/w/index.php?title=Opaque_data_type&oldid=1221884413"

    Categories: 
    Data types
    Object-oriented programming
    Computer science stubs
    Hidden categories: 
    Articles with short description
    Short description is different from Wikidata
    Articles needing additional references from December 2011
    All articles needing additional references
    Articles needing cleanup from November 2011
    All pages needing cleanup
    Cleanup tagged articles without a reason field from November 2011
    Wikipedia pages needing cleanup from November 2011
    Articles with multiple maintenance issues
    All stub articles
     



    This page was last edited on 2 May 2024, at 15:29 (UTC).

    Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



    Privacy policy

    About Wikipedia

    Disclaimers

    Contact Wikipedia

    Code of Conduct

    Developers

    Statistics

    Cookie statement

    Mobile view



    Wikimedia Foundation
    Powered by MediaWiki