4 ms·
In the original pascal pointers/refs came only out of new (AFAIR), you couldn't point into structures or to local variables. That makes this trick impossible.
by apk17 10y ago
In the original pascal pointers/refs came only out of new (AFAIR), you couldn't point into structures or to local variables. That makes this trick impossible.
'Modern' 'pascals' were different.
- kwhitefoot 10y agoI'll grant that you can't do it quite as efficiently as in C but you can do the same trick as I showed for VB.Net (in another post in this thread) and create a new entry that points at the head then use that as your indirect pointer. The problem is caused not by being unable to point at locals or members but by Pascal's pointers being strongly typed so that you can't simply dereference some random word length memory cell to get a new reference. So not identical but still simpler than the tasteless version. I thought that this was such a fundamental idea that it should be on Rosetta Code but the page for it at http://rosettacode.org/wiki/Singly-linked_list/Element_removal http://rosettacode.org/wiki/Singly-linked_list/Element_remov... is empty. Perhaps we should all rush over there and fill it in. :-) Edit: See entry on RC at http://rosettacode.org/wiki/Singly-linked_list/Element_removal#.7B.7Bheader.7CVisual_Basic_.NET.7D.7D http://rosettacode.org/wiki/Singly-linked_list/Element_remov...