Russell Whitaker a écrit:
Hi Given a pointer p, dispose(p) does not set p to nil.
I do not know what side effects you might get if you caused "dispose" to set the pointer to nil.
This is not contained in the standards: it is said "after dispose the pointer is undefined", not nil. Many people complain in various pascal-like forums (delphi etc). In fact this is a matter of programming style, whether you rely on a pointer being nil to decide whether it points to a valid address. Doing that is a source of bugs: you can affect an other pointer to the same block or part of it. This new pointer will not be set to nil when disposing of the first. If you rely blindly on tests to nil you will be in trouble. This is probably the origin of this behaviour in standard pascal. If you know what you are doing, never affecting pointers, you can use wrappers like the one suggested by Adriaan. Making this mandatory in the syntax would induce other people to suppose wrongly that they can do the nil test in any case. The only way out is a much more complex "managed" language which keeps track of all the pointers in use, to be able to set to nil _all_ pointers which point somewhere into a disposed of block. This would have a strong penalty in execution time.
Maurice