Decorators and static typing.

Discussion in 'Python' started by whisper@oz.net, Jan 5, 2005.

  1. Guest

    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! ;=)
     
    , Jan 5, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Digital Puer
    Replies:
    27
    Views:
    5,119
    James Rogers
    Sep 13, 2003
  2. Arien Malec

    PEP 318 decorators are not Decorators

    Arien Malec, Aug 13, 2004, in forum: Python
    Replies:
    11
    Views:
    580
    Arien Malec
    Aug 16, 2004
  3. JimLad
    Replies:
    0
    Views:
    508
    JimLad
    Jan 26, 2010
  4. Nick Pavey
    Replies:
    3
    Views:
    159
    M. Edward (Ed) Borasky
    Dec 31, 2006
  5. Charles Oliver Nutter
    Replies:
    4
    Views:
    148
    Rick DeNatale
    Oct 2, 2007
Loading...

Share This Page