faq
flatforty
contribute
subscribe
configure
search
rdf
main
parent
thread
|
Re: What bindings in general need is:
by juanjo on Monday 20/Sep/2004, @12:52
|
I for one, having working for an entire year on a big commercial proyect 80% done in Python would welcome optional variable type declaration. Yes, pychecker helps a lot to catch sintantic errors that a compiler would catch in C++ (and a lot of other errors) or using not previously (auto)created vars and things like that, but it just can't catch:
var = 50
[...some hundreds locs here...]
vra = var + 1 # You'r fscked here
or...
myReallyMustBeAList = [var1, var2, 34]
[...bla...]
# Woop! I really mean to do "someOtherList.append(34)" but
# I've been working for 12 hours, you know...
someOtherList = 34 # Now someOtherList is an Int
myReallyMustBeAList = someOtherList
myReallyMustBeAList[4] # Fscked up you are!
I think Python 2.4 will allow you to declare the types of accepted/returned vars of functions and methods (using new python decorators); it's a start, but I would love to have _an option_ to enforce type declarations to avoid these kind of stupid but sometimes very hard to catch errors; it would help a lot in managing big proyects like mine. żDo you need some auto-declared var to do some dynamic magic or a function/method to act as a template? Just don't declare it (95% of vars aren't like these anyway). Declaring the type of vars, and not allowing them to change without explicit conversion, would also allow for some agresive optimizations, too.
On the other side, I love python, it's incredibly productive, the sintax is very clear and the libs are awesome. |
|
|
The Fine Print: The following comments
are owned by whomever posted them.
( Reply )
|
Re: What bindings in general need is:
by Philippe Fremy on Monday 20/Sep/2004, @13:26
|
I agree 100%. For every big python project, the dynamic typing becomes a problem. I enforce type arguments on all my functions but that's clearly not enough.
Actually, there are very few circumstances where I would change the type of my variable dynamically. I consider that bad programming style. So a static typing system would be ok and certainly remove lot of problems.
|
[
Reply To This | View ]
|
Re: What bindings in general need is:
by Corbin on Monday 20/Sep/2004, @14:06
|
What about at like the start of the Python script you some way declare that all variables must be declared. And then create a new 'dynamic' type so in case you want some variable to still be dynamic and all it could be. Also if in the start it isn't declared that all variables must be declared, it acts like it does now.
That way everyone wins! I think...
|
[
Reply To This | View ]
|
Re: What bindings in general need is:
by Philippe Fremy on Monday 20/Sep/2004, @14:16
|
Well, say that go Guido ! Next time I'll interview him, I'll ask for sure :-)
(shameless plug: http://www.freehackers.org/fosdem2002/guido.html)
|
[
Reply To This | View ]
|
Re: What bindings in general need is:
by Rayiner Hashem on Monday 20/Sep/2004, @17:14
|
That's not unlike what soft-typing languages do. In those languages (Common Lisp, many Schemes, Dylan), a type declaration is an optional constraint. If you put it in, it can help the compiler optimize the code, and check for errors. If you leave t out, you can still use full dynamicity. The usual development style with such languages is you write your "prototype" in a fully-dynamic, general manner, and then gradually convert that into your production code by adding declarations, refactoring, and optimizing.
|
[
Reply To This | View ]
|
Re: What bindings in general need is:
by Shulai on Monday 20/Sep/2004, @18:26
|
That's in my list of reasons I not really like python.
Also you can count the sloppy OO style, and even the tabbed blocks, even admitting it is nice to force people to write cleaner code).
I like more Pike, sadly it is soooo unknown and underused...
|
[
Reply To This | View ]
|
|
Re: What bindings in general need is:
by Ochoto on Monday 20/Sep/2004, @15:28
|
<BLOCKQUOTE>
"That is to say, if a program compiles in a strong, statically typed language, it just means that it has passed some tests. It means that the syntax is guaranteed to be correct (Python checks syntax at compile time, as well. It just doesn't have as many syntax contraints). But there's no guarantee of correctness just because the compiler passes your code. If your code seems to run, that's also no guarantee of correctness.
The only guarantee of correctness, regardless of whether your language is strongly or weakly typed, is whether it passes all the tests that define the correctness of your program."
</BLOCKQUOTE>
<a href="http://www.mindview.net/WebLog/log-0025">Bruce Eckel</a>
|
[
Reply To This | View ]
|
Re: What bindings in general need is:
by Jonas B. on Tuesday 21/Sep/2004, @02:19
|
Oh, you mean what Perl solved with 'use Strict'. Sorry, I couldn't help myself.. :) One other thing that could actually help which isn't really what you're looking for is design-by-contract. I believe Python has some implementation of it, but I've only played with the Perl one. It's a little bit invasive, but can solve errors similar to type errors in the dynamic language realm. Check it out, you might like it ...
|
[
Reply To This | View ]
|
The Fine Print: The previous
comments are owned by whomever posted them.
( Reply )
|
|