[Types-sig] Type-checked code calling unchecked code
scott
scott@chronis.pobox.com
Mon, 24 Jan 2000 00:57:06 -0500
On Sun, Jan 23, 2000 at 08:33:59PM -0500, Guido van Rossum wrote:
> > Guido van Rossum wrote:
> > >
> > > When a checked module imports an unchecked module, all objects in the
> > > unchecked module (and the unchecked module itself) are assumed to be of
> > > type 'any', and the checked module is typechecked accordingly.
>
> [Paul Prescod]
> >
> > I think that there is a problem here.
> >
> > j = uncheckedmodule.j
> >
> > j()
> >
> > Do I really have to declare that j is a callable to allow this to be
> > type-safe? Shouldn't we sniff out "obvious" type information (perhaps
> > functions versus classes versus everything else?).
>
> Of course not -- 'any' is callable. However, if you wrote
>
> decl i: int
> i = j()
>
> You'd get a type error because the return type is any.
>
> With Greg, you could write
>
> i = j() ! int
>
Just wanted to point out that in the case of '!', you get a runtime
error if you are wrong. in the case of typecase, you get a compile
time error if it's wrong (typewise, of course). I feel like I'm
repeating myself re: the runtime errors associated with !, but I think
it's important that it be pointed out, since the goal as I understand
it is greater compile time safety, and since the issue hasn't really
been addressed at all.
scott
> or with typecase, you could write
>
> typecase j():
> int, ji: i = i
> else: ...
>
> --Guido van Rossum (home page: http://www.python.org/~guido/)
>
> _______________________________________________
> Types-SIG mailing list
> Types-SIG@python.org
> http://www.python.org/mailman/listinfo/types-sig