[Types-sig] New syntax?
Martijn Faassen
faassen@vet.uu.nl
Fri, 17 Dec 1999 18:41:40 +0100
Tim Peters wrote:
> [GregS]
> > ...
> > In fact, I don't even like Tim's notion of declaring a function since a
> > "def" is more than adequate for doing that.
>
> I thought it would be easier to get one new stmt than to modify existing
> stmts, and *much* easier to write a dirt-simple tool to strip them out again
> (vis a vis Guido's requirement).
>
> In real life I would certainly prefer annotating "def" stmts directly. I
> think a declaration statement needs the *ability* to specify full function
> signatures, though; e.g.,
>
> decl handlerMap: {String: def(Int, Int)->Int}
>
> handlerMap = {"+": lambda x, y: x+y,
> "*": lambda x, y: x*y,
> ...
> }
I think inline type declarations like def(Int, Int)->Int may not be necessary
if you allow typedefs. People often give the advice to avoid Lambdas in Python
anyway; why not avoid a lambda like construct in our type definition language
as well?
typedef Footype(int, int):
return int
var handlermap = {string: Footype}
> In either case, I'm not sure what to do about varargs (the "*rest" form of
> argument).
Me neither. Perhaps something like:
decldef foo(first=int, second=string, *[int]):
return int
i.e. all the extra arguments must be ints.
Note that I'm currently in the out-of-line camp with Paul. :)
Regards,
Martijn