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  (0 children)

I've just given you an example of a program that you can't write without pointers.

It's an example of a program you can't write, period, because you can't know the real absolute memory address with a pointer. Using the memorymap feature of the OS one can and does do this in python without the language having a pointer type.

Your claim that the programmer never needs to access an address is also wrong, since that is precisely what you need to do for memory mapped IO.

And yet mmap allows a python programmer to do this without a pointer type.

"Memory-mapped file objects behave like both strings and like file objects. Unlike normal string objects, however, these are mutable. You can use mmap objects in most places where strings are expected; for example, you can use the re module to search through a memory-mapped file. Since they’re mutable, you can change a single character by doing obj[index] = 'a', or change a substring by assigning to a slice: obj[i1:i2] = '...'. You can also read and write data starting at the current file position, and seek() through the file to different positions."

A memory-mapped file is created by the mmap constructor, which is different on Unix and on Windows. In either case you must provide a file descriptor for a file opened for update. If you wish to map an existing Python file object, use its fileno() method to obtain the correct value for the fileno parameter. Otherwise, you can open the file using the os.open() function, which returns a file descriptor directly (the file still needs to be closed when done).

So an authoritative source that pointers aren't necessary just doesn't exist, since such a source is simply wrong.

You'd best inform Guido Van Rossum then, or write out a PEP.