Python and generic programming
Hans Nowak
hans at zephyrfalcon.org
Tue Oct 26 18:42:21 EDT 2004
More information about the Python-list mailing list
Tue Oct 26 18:42:21 EDT 2004
- Previous message (by thread): Python and generic programming
- Next message (by thread): Python and generic programming
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Christophe Cavalaria wrote: > Oliver Fromme wrote: > >>The appropriate type checking is done at compile time. That >>is, if your program calls sort with two lists of different >>type (e.g. a list of strings and a list of ints), then the >>compiler will detect that and report an error. > > > This must be a bad example because I expect to be able to sort a list of > integers and a list of strings with the same sort function. You can, actually: # let l = ["foo"; "bar"; "baz"; "etc"];; val l : string list = ["foo"; "bar"; "baz"; "etc"] # sort l;; - : string list = ["bar"; "baz"; "etc"; "foo"] # sort [5; 7; 3; -3; 0; 8; 12];; - : int list = [-3; 0; 3; 5; 7; 8; 12] ...so I don't really understand what Oliver meant by that statement. The sort function will not work on lists that have different types in them, but that's a different issue. -- Hans Nowak http://zephyrfalcon.org/
- Previous message (by thread): Python and generic programming
- Next message (by thread): Python and generic programming
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list