Markus Gerwinski wrote:
Frank Heckenbach wrote:
I don't understand. Passing a value parameter is almost the same as an assignment. I.e., if the procedure disposes of the store pointer parameter, the also store pointer in the caller gets invalid which should not happen.
Where did I say that?
Well, maybe you didn't say that, but I assumed the purpose was to make pointer access safe.
It is, but I don't see why the possibility of passing store pointers as parameters would make pointer access unsafe. So you would have the possibility of writing something like this:
...
Procedure foo ( var sp: store pointer );
I said value parameter. So let's assume you meant:
Procedure foo ( sp: store pointer );
begin (* foo *) ... dispose ( sp ); ... end (* foo *);
... foo ( some_global_sp ); (* disposes of sp, thus setting all *) ... (* pointers referencing sp^ to nil. *)
What's the problem here?
During the execution of foo you have two store pointers of the same thing, some_global_sp and sp. If this isn't a problem, then why allow this only in this special case and not allow copying store pointers in general? IOW, what's the difference why it's ok in this case, but not in other cases?
For the implementation it means that it would not only have to keep track of all reference pointers, but also of all the store pointers. I.e., if foo disposes of sp, it would also have to set some_global_sp to nil (and possibly other instances of this store pointer in other active routines as well), therefore it must be able to find them because sp and some_global_sp are not the same variable (since we're talking about value, not var, parameters).
Frank