Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: Private/Public attributes

From: jan:skibinski:sympatico:ca at: 15-Nov-2002 23:51

Hi, This is probably too far off topic, but since Joel said <<where there's a "won't" there's a "will"! >>, I'd like to share this bit about information hiding. The only concept I know of that provides theoretical support for true privacy is ADT (Abstract Data Type) and a related to it existential quantification. Existentially quantified types were first described by Mitchell & Plotkin. There are some good papers by Luca Cardelli explaining the basic idea. In essence, objects described by abstract data types display some abstract behaviour that is independent of the representation type. Users should not be allowed to break the abstraction via the abstract data type interface. Once an abstract object is made, its representation type can never be rediscovered. There are many existential types that are too general to be useful. The only useful kind of existential objects are those packaged as pairs (cartesian products) made of an unknown value and a function from that value to something specific, such as integer. The corresponding signature of such an object 'x would be something like this: x :: Exists. a (a, a -> integer) which loosely means "The object 'x is a pair made of a value of unknown type 'a, and of a function from type 'a to integer". The type 'a is not universal - as it would be the case with FORALL 'a quantification, the above only means that there EXISTS SOME type a' taken from a universe supported by a language under consideration. We do not know what this type is, and we do not know how to discover the real structure of this packed object 'x (is it a tree, or an array or a stack?). But we can take advantage of its cartesian type to calculate the value of the integer, by applying the second part of 'x to the first one: second x first x == 43, say A programmer packaging such an object knew exactly what the first element was, say integer 5. But once packaged, its value remains a secret for the receiving party. Existential types have been introduced to Haskell quite recently, as one of the extensions. I played with them a bit and they seem quite convenient for certain kind of applications. Functional languages Clean and Caml and the functional-logical language Mercury also support existential types. Regards, Jan