[Types-sig] lambdas, classes, tuples, default arguments, map

Tim Peters tim_one@email.msn.com
Sun, 23 Jan 2000 23:46:00 -0500


[Tim]
> Something's confused here, or the meanings of "|" and "&" got
> swapped when I wasn't looking <wink>.

[Tony Lownds]
> The decl is saying that the same map function can conform
> to map1 *and* map2 *and* map3. If it said map1 *or* map2 etc,
> then the programmer would have to check to make sure the
> current value of the map variable is the alternative that
> can handle the way its about to be called.

Let's make this more formal, so we stop stumbling over words.  My
understanding has been that, in the scope of

    decl var: T1 | T2

each static (textual) reference to var must have at least one of

    isinstance(var, T1)
    isinstance(var, T2)

be true at runtime.  But in the scope of

    decl var: T1 & T2

each static reference to var must have *both* of

    isinstance(var, T1)
    isinstance(var, T2)

be true at runtime.  The latter follows from Guido's "motivating example" of
multiple interfaces in Java; to say that something is "Readable & Writable"
is not to say that something *can* be Readable and (or) Writable, it's to
say that the thing must be both at the same time.

Having spelled that out, it is true that map satisfies all of

    isinstance(map, map1)
    isinstance(map, map2)
    ...

at each static site.  Hmm -- so I have to admit "&" is appropriate after
all.  Thanks!

> ...
> I wasn't using '&' as a intersection operator but as a
> combination operator.

Same thing -- if we take the set of all functions that conform to map1, and
the set of all that conform to map2, and ... map is in the intersection of
those sets.  That's (roughly, but not too roughly) what I meant by
"intersection" and "union".

educated!-ly y'rs  - tim