[Types-sig] A challenge

Christian Tismer tismer@appliedbiometrics.com
Fri, 17 Dec 1999 18:36:21 +0100


Tim Peters wrote:
> 
> [Christian Tismer]
> > ...
> > Just a question, please:
> >
> >> import fnmatch
> >> import os
> >>
> >> decl _debug: Int  # but Boolean makes more sense; see below
> >
> > Is this meant to be lexically true in the globals scope from
> > here on?
> 
> I'm not sure I grasp the question.  The implicit model is the "global" stmt:
> a type declaration applies to the entire compilation unit in which it
> appears (module, class or def), and referencing a declared name before the
> declaration should be verboten.  "global" currently allows redundant
> declarations, and you get a Fabulous Prize for later noticing the instance
> of redundant type declarations that I snuck into one of the examples <wink>.

Understood. There is always just one possible type in a scope,
and if defined again, it has to match.

[name equivalence]
That sounds very right, since it allows to create different
things even if they look the same from structure. You get more
strength in error checking, since using the parameter in the wrong
context can be detected even if a foo's components look like a bar's.

...
> >>     decl list, names: [String], name: String   # LINE1
> >>         decl name, fullname: String            # LINE2
> 
> > Same question: "name" is redefined from here on?
> 
> My intent was to illustrate redundant declaration.  I'm definitely not
> trying to invent new scoping rules!  The semantics would be exactly the same
> if "name" were absent from either LINE1 or LINE2; it would be an error if
> e.g. "decl name: Int" appeared in the "for" loop instead; and e.g. it would
> be illegal to reference fullname before LINE2.

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()
tot he variable which held the dict. Is this idea gone?

> 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.

Thanks for the good question - ciao - chris

-- 
Christian Tismer             :^)   <mailto:tismer@appliedbiometrics.com>
Applied Biometrics GmbH      :     Have a break! Take a ride on Python's
Kaiserin-Augusta-Allee 101   :    *Starship* http://starship.python.net
10553 Berlin                 :     PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint       E182 71C7 1A9D 66E9 9D15  D3CC D4D7 93E2 1FAE F6DF
     we're tired of banana software - shipped green, ripens at home