[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: What's so cool about Scheme?



>> I think of OO as being the ability to provide user-defined types with
>invariants
>
>I'm not sure what "invariants" are (but I do know that use-defined types
>are). Is it possible to have "user-defined types with invariants" in a
>language that would not be considered object-oriented (Modula, Pascal, C,
>ML)?

	An invariant is merely a guarantee: if I create a "prime number" object, my construction / destruction / etc. code will ensure that it will invariably be a prime, even though it is represented as a general int, because only my code will be allowed to touch the representation.  Perhaps this is insufficient but that's the most minimal definition of OO I can think of.  By that definition you can't really provide invariants, at least not easily, generally, and elegantly, in the non-OO languages you mentioned.  I could in C use the "struct myObject;" syntax to hide the implementation of a struct from all but the "method" code but it's not as nice.