[FIX] LinkedListFix-spfa ( seems incorrect )

cdshaffer at acm.org cdshaffer at acm.org
Wed Mar 10 18:17:10 CET 2004


I don't believe that LinkedList is supposed to behave the way you
described.  You cannot add strings to linked lists, only links.  So you
need to pass some subclass of Link (or something that implements the
Link protocol) to the various LinkedList methods.   addFirst: on an
empty list works fine as long as you pass in a Link of some kind:

  LinkedList new addFirst: Link new; yourself

upon inspection gives a correctly formed LinkedList.  Unfortunately this
doesn't help you much if you want to use LinkedList since Link doesn't
hold any state except the "next" pointer.  In such a case you can
subclass Link (look at the existing subclasses in a browser to get some
examples) or, if that isn't possible implement nextLink and nextLink: in
the class of the items you are adding to the list.

My recollection is that LinkedList is primarily used for maintaining the
Process list by the scheduler and its current design seems in keeping
with that purpose.  It is not plugin replaceable for OrderedCollection,
for example.  I personally think that the current version should be
renamed and a version of LinkedList which follows a more reasonable
interpretation of the SequenceableCollection protocol should be
created...but then maybe that's my Java background speaking (in Java
LinkedList and ArrayList are almost completely interchangable).


More information about the Squeak-harvest mailing list