How a smart editor could make "Postfix type declarations PEP3117" inPython3000 more readable

A

aspineux

Hi

I read the PEP 3117 about the new "Postfix type declarations" in
Python3000.
THIS PEP as been REJECTED ! But ...

The notation in the PEP is very ugly ! This make python code more
difficult to read!

Anyway when I switched to python (from C, C++, ..), I suffered a lot
of the
untyped python variables. And I think this is a good idea to include
typing in python.

Then I get this idea: The editor could hide the typing notation, just
displaying hint !
It could also auto-complete the type of any variable having already a
type in
the current function, and underline untyped variable or variable
having multiple type inside the function.

Just an idea !


Alain Spineux

Happy new year.
 
J

John Nagle

aspineux said:
Hi

I read the PEP 3117 about the new "Postfix type declarations" in
Python3000.
THIS PEP as been REJECTED !

Of course. That was a joke.
> And I think this is a good idea to include typing in python.

Python doesn't really need explicit type declarations.
They're not needed for correctness, and they're not needed for
performance. Take a look at Shed Skin, which is able to hard-compile Python
using type inference without explicit type declarations.

(I'm writing as someone who's used and liked very strictly typed
languages like Ada and Modula. Python actually does unusually well
without declarations. Most languages that don't have declarations
run into difficulties. Consider Basic, TCL, and Matlab, to name
three rather diverse examples. Python managed to avoid the problems
those languages have.)

John Nagle
 
R

Russ P.

Of course. That was a joke.


Python doesn't really need explicit type declarations.
They're not needed for correctness, and they're not needed for
performance. Take a look at Shed Skin, which is able to hard-compile Python
using type inference without explicit type declarations.

(I'm writing as someone who's used and liked very strictly typed
languages like Ada and Modula. Python actually does unusually well
without declarations. Most languages that don't have declarations
run into difficulties. Consider Basic, TCL, and Matlab, to name
three rather diverse examples. Python managed to avoid the problems
those languages have.)

John Nagle

Interesting. And how did it do that?
 
A

aspineux

Hi

I read the PEP 3117 about the new "Postfix type declarations" in
Python3000.
THIS PEP as been REJECTED ! But ...

The notation in the PEP is very ugly ! This make python code more
difficult to read!

Anyway when I switched to python (from C, C++, ..), I suffered a lot
of the
untyped python variables. And I think this is a good idea to include
typing in python.

Then I get this idea: The editor could hide the typing notation, just
displaying hint !
It could also auto-complete the type of any variable having already a
type in
the current function, and underline untyped variable or variable
having multiple type inside the function.

Just an idea !

And to go further the editor could do all the job of type checking,
using formatted comment to specify type, like in some existing
embedded documentation.


But then we are losing the brevity provided by the PEP.


Pydev (and certainly other) already does some interesting work to find
mistyped
(typed like in "I made a typo") variable name.

TO ALL "NEW IDEA" RESISTANT :

Hopefully, in 1990 nobody said to someone that inventing a language
where bloc definition
is based on indentation was a s....


Regards
 
B

Ben Finney

John Nagle said:
(I'm writing as someone who's used and liked very strictly typed
languages like Ada and Modula.

Python is strictly typed (also known as "strongly typed"
<URL:http://en.wikipedia.org/wiki/Strongly-typed>), because its
objects know exactly what type they are and won't contort themselves
into another type unless there's an explicitly defined method for
doing so.

I think you mean you're accustomed to "statically-typed languages",
where names are restricted at compile-time in what values they can
refer to. This is as opposed to Python being a "dynamically-typed
language": names are not restricted in the type of object they can be
bound to, and the type of a value is determined when that value is
created said:
Python actually does unusually well without declarations. Most
languages that don't have declarations run into difficulties.
Consider Basic, TCL, and Matlab, to name three rather diverse
examples. Python managed to avoid the problems those languages
have.)

Those three diverse examples are all weakly typed languages. Since
Python is strongly-typed and dynamically-typed, this could largely
explain the difference you see in Python "doing unusually well without
declarations" compared to those languages.
 
R

Russ P.

Since
Python is strongly-typed and dynamically-typed, this
--

Hyphenating after "ly" is grammatically incorrect.
\ "It is the responsibility of intellectuals to tell the truth |
`\ and expose lies." -- Noam Chomsky

Never quote Noam Chomsky on "truth." He wouldn't know it if it bit
him.

Nice post otherwise. I'm just fooling around.
 
K

Kay Schluehr

Python doesn't really need explicit type declarations.
They're not needed for correctness, and they're not needed for
performance. Take a look at Shed Skin, which is able to hard-compile Python
using type inference without explicit type declarations.

ShedSkin is not Python.
 
B

Bruno Desthuilliers

aspineux a écrit :
Hi

I read the PEP 3117 about the new "Postfix type declarations" in
Python3000.
THIS PEP as been REJECTED !

Indeed - it's an april's fool joke !-)

And BTW, no need to scream, we hear you pretty well.
But ...

The notation in the PEP is very ugly ! This make python code more
difficult to read!

Anyway when I switched to python (from C, C++, ..), I suffered a lot
of the
untyped python variables.
And I think this is a good idea to include
typing in python.

The concept of "type" greatly differs between static typing and dynamic
typing. FWIW, it also somewhat differs between declarative static type
systems (C/C++/Java/etc) and inference-based static type systems (OCaml,
Haskell etc).

Anyway, Python is dynamically typed (FWIW, it's dynamic almost
everywhere), and this is probably not going to change in a foreseeable
future. So I guess you'd better learn to use dynamic typing instead of
trying to write C++ in Python - or, if you just can't get used to
dynamic typing, use another language.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top