[Python-3000] Fwd: Conventions for annotation consumers

bmx007 bmx007 at gmail.com
Fri Aug 18 11:59:49 CEST 2006


Hi,
I haven't read all the thread because it's pretty long, but if I have
well understood
Paul and what is my opinion (and why I use docstring in my own
typecheker module)
is that it's a good idea to not mix function definition and its type.

I think the difference between langages is not what they allow to do,
but how it's easy to write something and easy to READ it (the
read-factor is why I switch from p... to python).
So separation of semantic and type is good thing because we don't
usualy need (as reader) to know both as the same time. So we can read
what we want.

As exemple, consider a function

def find(token, line):
    ...
with string as parameter a boolean as return value.

I allmost cases what we need to not is only the order or the parameter
so do I call find(token, line) or find(line, token) ?

In this case I shoud find easily the semantic of the parameters, and I
don't mind with their type (because I work in a context where I expect
them).
It obviously easiest to find if their is no extra-information so the old way
def find(token, line) is the best.

And it's the same for the type, when I care about the type is usually
a problem of consistency and I don't mind about semantic. This occurs
for exemple in "template" function as

def max(x, y):
   ...
where max could be
int, int -> int
float, float ->float
string, string -> string

and something like (or any equivalent)
def max(x, y):
   :: int, int -> int
   :: float, float -> float
   :: string, string -> string

is (I think) easy to read, write and we can skip easily the
information we don't mind.

Maxime


More information about the Python-3000 mailing list