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

Re: dynamic vs. static typing



"Matt Hellige" <matt@immute.net> wrote in message
20031121161000.P25194@metro.immute.net">news:20031121161000.P25194@metro.immute.net...
> [Mike Austin <mike_ekim@yahoo.com>]
> >
> > There are far more uses for heterogenious lists when the focus in not on
the
> > program, but on semantics: AI, MUDs, etc.
> >
> > > room objects = [Sword new, Rock new]
> > > room listObjects
> > ['sword', 'rock']
> > > eat: room.'rock'
> > Can't eat rock!
> > > eat: room.'sword'
> > Are you really sure you want to do that? :)
> >
>
> I believe that this is the point that some of us have been trying to
> make: you are still not talking about unconstrained heterogeneity. All
> of the things in the room have, even at the most abstractly semantic
> level, something in common: they are the kinds of things that can be
> in rooms. This means that certain operations can be performed on them,
> operations like:
>
>   "check to see if X is edible"
>   "check to see if I can pick X up"
>   "describe X"
>   ...

Why check?  Just do it. :)

It depends upon your design.  You could send an object the message "eat" and
that object would take care of everything... filling the players stomach,
and returning "Mmm, that was good" and a status 'successful'.  I know that's
a pattern, umm - strategy? visitor?

object rock    -- empty object
object apple
  method eat: person
    person hunger -= 5
    return 'Mmm, that was good', true

> eat: apple   -- calls apple eat: person
Mmm, that was good.
> eat: rock     -- calls rock eat: person
Can't eat rock.

Yes, I guess each object *would* have to describe itself, and that's an
interface.  And, every object seems to know about person.

 -- Mike

> One might reasonably expect that other kinds of things might not be
> allowed in such a list: other rooms, the entire game universe,
> operations on objects, other lists of other things, and so on, just to
> name a few. This is the kind of thing a type system could check.
>
> Type systems aren't, in principle, supposed to prevent you from
> noticing that a Sword and a Rock have something in common. They're
> just supposed to help you understand wha that something is, hopefully
> in an automatically verifiable way.
>
> The reason I don't think we're seeing any great examples of TRULY
> heterogeneous lists of completely abstract, unconstrained values is
> that, as has been amply pointed out, such a thing is literally,
> exactly and provably no more useful than (and, in fact, equivalent to)
> a natural number. I don't know how to make that more clear.
>
> MAtt
>
> --
> Matt Hellige                  matt@immute.net
> http://matt.immute.net
>