[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: metatable transmission
- From: Javier Guerra <javier@...>
- Date: Mon, 21 Dec 2009 14:30:03 -0500
On Mon, Dec 21, 2009 at 2:09 PM, Mark Hamburg <firstname.lastname@example.org> wrote:
> It's probably best not to think in terms of inheritance.
the feature we want is polymorphism; but on static languages, the
compiler _has_ to check the type, if you want to allow several types,
then it asks, "at least make them related types"... and inheritance is
dynamic languages OTOH, don't care. put anything here, if it can work
great; if not, fail at runtime. therefore you don't need to create
any relationships between types, each one stands on it's own. in
fact, an object doesn't even have to belong to a type at all, it could
be a one-of-a-kind object that just happens to walk like a duck.
it's interesting to read the specifications of C++'s STL: most of the
requirements don't ask for "an object of class xxx (or subclass of)",
it only says things like: "an object that can be incremented and
compared". How come? well, you can think of C++'s template system
like a (mostly) dynamic language that runs at compile time, generating
all the static code ran by C++ itself.