Decorators and static typing.

W

whisper

Well, the decorator war is over (Python lost IMO!) and now we've got the
static typing war to fight!

Both of these seem like syntax sugar to avoid writing good code! One has
already introduced ugly coding and the 2nd is likely to do the same!

Ok, so how do you do keywords and default values?
def myFunc(a=1: int, b="hi": string, people=[]: array[person]): int:
yadda
yadda
yadda
So, what is the int or string? the default value or the label? (Of
course it's obvious to an experienced programmer - is that the intened
audience for Python now and the python in education initiative dead?).
The last parameter is particularly arcane (and ugly!).

If this mistake looking for a place to happen has to happen, at least
put the type before the horse!:
def myFunc(int a=1, string b="hi" array[person] people) int: #note lack
of first : after "("
yadda
yadda
yadda

Of course, one could not change the language at all!:
def myFunc(a, b):
assert(type(a) == "int")
assert(type(b) == "string")
#aggrigates lose here - how do you check the type of every element?
(ensure that array[person].__add__ makes sure the rhs is of type person
so the problem never comes up in the first place!)
yadda
yadda
yadda
I know: this doesn't save you from yourself when calling myFunc from
somewhere else, but it does ensure that parameters are of the expected
type where it really counts! (People who need saiving from themselves
ought not to be programmers in the first place!)

Of course, decorators might have been done this last way too - with
predefined functions and no needed changes to the language, but maybe
that's not as cool for the dev guys. That brings up the larger problem,
as alluded to by the "python evolution: unease" thread: the dev guys
seem intent on more breadth without focusing on the depth of the language!

At some point, someone has to decide that python is feature complete!

Lua is looking better and better! ;=)
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top