[Types-sig] New syntax?

Tim Peters tim_one@email.msn.com
Sun, 19 Dec 1999 19:59:37 -0500


[Tim]
> Yes, Any is good.

[GregS]
> I've listed this in my proposal as an open question. I'm leaning
> to "formally endorsing" it. My only real opposition is whether
> it must be a new keyword, or we can find some other way to deal
> with it.
>
> For example:
>
> import types
> Int = types.IntType
> String = types.StringType
> Any = None
>
> decl foo: Any
> decl bar: String
>
> The compiler isn't going to have recognized names for the types.

I pushed almost everything into "decl" stmts so that type specification
really was a sublanguage distinct from current Python, and specifically a
declarative  (no control flow of its own & no side-effects) sublanguage,
fully evaluable at compile-time via simple means.  To the extent that that's
true, it can enjoy its own "compile time" namespace distinct from the
runtime namespaces, and Int, Any, String, Boolean ... can be decreed to
"just be there", by magic, *in* declarations, for purposes of compile-time
type checking.  If instead we have to interpret imports and binding stmts
and attribute dereferences and ... to get at names for types, we pretty much
have to *execute* the code -- and Guido won't go for that.  Or, if he does,
he shouldn't <wink>.  The "static" in "static typing" has implications.

> ...
> Funny note: looking at the grammar, I've found the following is legal:
>
>   def foo(bar, *args, * *kw):
>     ...
>
> In my typedecl syntax, I punted the ability to use "* *" ... you must
> use "**". So there :-)

Good!  It's little-known that e.g.

    x = 2and 3

is legit Python but

    x = 2 and3

isn't, and I'm sure Guido would like to suppress that secret too.

or-if-he-wouldn't-he-should<wink>-ly y'rs  - tim