News for hackers. Stuff that matters.
Re:Static types in Python by gpderetta on Friday October 14, 2016 @09:02AM (#12707756)
> Looking at C++, a practical example is vector. It's a useful tool (automatic memory management), and very likely to be all over in your function signatures. This is very bad in terms of modularity / reusability, because your functions are not defined using reasonably general types (pointers to arrays).

That's why you define your functions as taking generic Iterators instead, which generalize pointers to arrays. Or, in more modern style, generic containers.

You can wrap that in a type erasure layer (lookup any_iterator) if you want separate compilation.

Re:Static types in Python by jstimpfle on Friday October 14, 2016 @11:35AM (#12708765)
> That's why you define your functions as taking generic Iterators instead, which generalize pointers to arrays. Or, in more modern style, generic containers.

Or, in yet more modern style as slices. Or, ...

The only thing I miss from pointers + indices is optional bounds checking. Otherwise, it's the perfect tool for productivity (because readability, writeability, portability, modularity).

Re:Static types in Python by gpderetta on Friday October 14, 2016 @05:07PM (#12711093)
Pointer+size only allow passing memory-contiguous containers.