On Wed, Aug 10, 2011 at 12:16 PM, Robert Fischer
<[email protected]> wrote:
> What does "subtyping" mean in a prototype language with structural
> types? There is no such thing as a "parent" or "child" type, so the
> type hierarchy context — the only context where "subtyping" means
> something to me — doesn't exist.
>
> Consider these two records:
>
> let x = [
> add: { a, b -> a + b },
> subtract: { a, b -> a - b }
> ]
> let y = [
> add: { a, b -> a + b },
> multiply: { a, b -> a * b }
> ]
>
> Which is the parent? Which is the child?
Neither, obviously. But both are subtypes of
let z = [
add: {a, b -> a + b}
]
Where there is subtyping, there is the possibility of covariance and
contravariance. This applies whether you are putting things into a
container and taking them out again, or passing arguments and
receiving results, or indeed writing and reading files with a
potentially different security classification from yours (the
Bell-LaPadula security model).
--
GMail doesn't have rotating .sigs, but you can see mine at
http://www.ccil.org/~cowan/signatures
--
You received this message because you are subscribed to the Google Groups "JVM
Languages" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jvm-languages?hl=en.