Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There have been other typed Python variants. RPython, in which PyPy was written, is sort of one. Shed Skin tried to do it entirely via type inference, which is really hard across functions.

It's clear now that you want at least enough type inference in a language that LHS types of assignments and variable creations are inferred when possible. When you have that, as in Go, Rust, and even C++ to some extent, most of the declarations are in function definitions. There, you want them for documentation purposes anyway.



MyPy is a pretty good typed Python variant. I believe the "optional type annotations" PEP used their style.

http://mypy-lang.org/


> even C++ to some extent

C++ can also infer return types, the following is a valid C++14 function definition

    auto foo() {
        auto curry = [](auto x) {
            return [=](auto y) { return x + y; };
        };
        auto add42 = curry(42);
        return add42(58);
    }
which incidentally gets compiled to this:

    0000000000000000 <foo()>:
       0:	mov    $0x64,%eax
       5:	retq




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: