[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: What's so cool about Scheme?
> An invariant is merely a guarantee:
> [...]
> By that definition you can't really provide invariants,
> at least not easily, generally, and elegantly,
> in the non-OO languages you mentioned.
This sounds like encapsulation to me. Plenty of languages will allow you to
create data types and manipulate them only through an interface that makes
guarantees about the integrity of the data types. These are simply ADTs, and
languages that explicitly support this (through module systems) are ML (and
derivatives), Haskell, Modula, Ada.
> 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.
It's not as nice because C doesn't provide explicit support for
encapsulation in the object-oriented sense.
There is a collection of practices which various people/authors/gurus have
said are the defining characteristics of object oriented languages, yet
these practices are also supported by languages that most people would not
consider object oriented. (I suppose this becoming my point now.)
-----Original Message-----
From: Mike Newhall [mailto:mike@newhall.net]
Sent: 03 June 2003 19:13
To: Bayley, Alistair
Cc: ll1-discuss@ai.mit.edu
Subject: 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.
*****************************************************************
The information in this email and in any attachments is
confidential and intended solely for the attention and use
of the named addressee(s). This information may be
subject to legal professional or other privilege or may
otherwise be protected by work product immunity or other
legal rules. It must not be disclosed to any person without
our authority.
If you are not the intended recipient, or a person
responsible for delivering it to the intended recipient, you
are not authorised to and must not disclose, copy,
distribute, or retain this message or any part of it.
*****************************************************************