[Types-sig] A challenge

Tim Peters tim_one@email.msn.com
Fri, 17 Dec 1999 21:11:00 -0500


[Christian Tismer]
> ...
> Isn't this in conflict with one of your earlier posts where you
> wanted the same variable to take different types in sequence?
> I found that example very clean. You assigned a dict's keys()
> to the variable which held the dict. Is this idea gone?

Not in *my* code it isn't, but I don't think a type system has to cater to
every abuse I can come up with <wink>.  Greg can handle this fine with
expression-based type operators, but when I look at my own code I think
name-based type declaration is overwhelmingly the less bothersome approach.

This leaves me with several choices; at least:

+ Don't ask for static typing on code that "cheats" this way.

+ Declare "result" as a union type; e.g.,

    decl typedef Set(_T) = {_T: Int}
    ...
    decl var result: Set(Int) | [Int]

+ Harass Guido to add a core dlict type <wink>.

+ Use Greg's form of dynamic cast (which appears to me to have
  real merit whether or not declaration stmts are introduced).

+ Kill any chance of adding declaration stmts by introducing a maze
  of bizarre new rules just to cater to line-by-line redeclaration.

Note that the last is trickier than it may appear, because the crucial line:

    result = result.keys()

uses result as an [Int] on the LHS but as a Set(Int) on the RHS.  So it's
wholly unnatural for name-based typing -- and that doesn't bother me a bit.

>> how-do-we-declare-the-type-of-a-continuation<wink>?-ly y'rs  - tim
>
> Let's see :-)
>
> PythonWin 1.5.42c1 (#0, Dec 15 1999, 01:48:37) [MSC 32 bit (Intel)] on
> win32
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> Portions Copyright 1994-1999 Mark Hammond (MHammond@skippinet.com.au)
> >>> import continuation
> >>> co = continuation.caller()
> >>> co
> <Continuation object of runcode() frame at 129a200>
> >>> type(co)
> <type 'Continuation'>
> >>> co.__doc__
> "I am a continuation object, Deleting 'link' kills me."
> >>> callable(co)
> 1
> >>>
>
> I think the type of a continuation is Continuation.

Hey -- makes *my* life easy <wink>.

will-spend-the-rest-of-the-night-wondering-where-"1"-
    came-from-ly y'rs  - tim