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

Re: dynamic vs. static typing




On Nov 18, 2003, at 1:46 PM, Ken Shan wrote:
> It seems that under #2 you meant to say that "variables or arguments
> are not assigned to types which contain methods which they [i.e., the
> variables or arguments] do not respond to" -- is that right?

Yes.

> Assuming that, what you said seems reasonable to me.  Two caveats,
> though.  First, I don't see any reason to distinguish between 
> variables,
> arguments, and return values.  I particularly don't see why your two
> items above restrict themselves to "variables" and "variables or
> arguments", respectively.

Call them all variables then.

Ok, now let's take a simple and common example such as a List that can 
hold any collection of objects (of different types). How do we 
implement such a thing in a statically typed system? For example, let's 
say our List object has an "at(index)" method which returns the object 
at the specified index. What would the return type for such a method 
be? - without being the equivalent of a void *, in which case, we can 
once again get "object does not respond to this message" errors, which 
is what the static type system was supposed to prevent.

-- Steve