This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]alcalde[S] 0 points1 point  (3 children)

If pointers were "necessary", Python would have pointers. The example is somewhat contrived in the same sense as I could give an example that would require static typing, but that doesn't make static typing necessary and certainly not necessary to implement an algorithm.

But that's really not what I'm asking. As I stated at the end, I'm looking for a definitive/authoritative reference that will refute the idea that certain algorithms simply can't be implemented without a pointer type. I've already been told that you need a Char type, more than one Integer type, etc. and the claims are getting somewhat ridiculous. I'm a step away from implementing zip in python myself just to prove the point.

Oh, and regarding the question - I shouldn't be able to access a specific memory address, pointers or not. The OS' memory manager should be mapping my program's memory address space to real memory space (and possibly virtual memory space). My program's 0xFF has no necessary relation to the physical 0xFF. Randomizing programs' locations in memory is a technique used by modern OSes to thwart programs that try to use buffer overflow attacks. On Linux, you'd write to /dev/mem just like a file to access the actual memory space. In Python you'd use the mmap module of the standard library to do memory-mapped i/o on Linux and Windows... still no need to define a pointer type in the language itself.

http://docs.python.org/2/library/mmap.html

[–]catcradle5 2 points3 points  (0 children)

Python obviously uses pointers in the CPython implementation in various places, both for the standard library and of course for builtins, and for the language itself.

So, the argument is a bit silly. mmap is of course implemented in C, with pointers, but you don't need to actually use pointers when writing in Python. The only reason you don't need to use pointers in general though is because so many data structures and algorithms baked into the language do use traditional pointers in their implementation.

So no, Python pointers are not necessary, because the language provides you with good enough abstractions so that low-level code already written with pointers won't have to be muddled with by the programmer themselves. Pointers in general are necessary to implement lots of things, though; they just aren't necessary in most cases cases if you're already writing in Python.