in reply to Re: Perl vs C
in thread Perl vs C
There is no need for a "linked list" in Perl! A Perl list does what a C linked list can do and more!
Fond as I am of shiftily pushing and popping in Perl, I simply have to disagree with this.
For example, one nice property of a linked list that isn't shared by what you call Perl lists is that pointers into it are not invalidated by insert/delete operations elsewhere.
(This is actually a real-world example that has bitten me just this week: I have a list of properties, and a bunch of objects that each need to access all properties up to and including a certain point. The implementation stores the properties in an array and simply has the objects hold the index of the last property they need. Now suddenly I have a new requirement to insert properties at arbitrary positions in the list, and that means I potentially have to change the indices stored by every object. If I'd been using a linked list, I'd have got the correct behaviour by default. I'm sorely tempted to redo it that way ...)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Perl vs C
by Tanktalus (Canon) on Mar 14, 2009 at 21:19 UTC |