[Types-sig] Static typing: Towards closure?

scott scott@chronis.pobox.com
Thu, 20 Jan 2000 21:27:30 -0500


On Thu, Jan 20, 2000 at 01:49:06PM -0500, Guido van Rossum wrote:
> > From: scott <scott@chronis.pobox.com>
> 
[...]
> > 
> > datatype FIRSTNAME -> FIRSTNAME = string
> > datatype LASTNAME -> LASTNAME = string
> > datatype NICKNAME -> NICKNAME = string
> > 
> > def get_nickname_from_firstname(n: FIRSTNAME) -> NICKNAME:
> >     # do stuff
> > 
> > def get_nickname_from_lastname(n: LASTNAME) -> NICKNAME:
> >     # do stuff
> > 
> > 
> > # To use this, you need a constructor in order to produce objects
> > # with the new datatypes:
> > 
> > decl a: FIRSTNAME
> > a = FIRSTNAME("scott")
> > print get_nickname_from_lastname(a) # ERROR
> > 
> > By requiring the casts, there is also a good argument that it makes
> > code more readable.

[.. agreement that this kind of type checking wouldn't be used
in the common case for python...]

> 
> What do you call a user defined cast?

Just the line FIRSTNAME("scott") in the above example.

scott