From: Dossy Date: 2002-07-08T07:19:30+09:00 Subject: Re: is there a better string.each? On 2002.07.08, Tom Sawyer wrote: > no that is not right. > > first of all, a linked list is not simply an array. a linked list holds > both an object and a link in reference to the next object in the list > (at the very least). an array is no more then an ordered collection of > objects. so a linked list is not an array. a linked list is different > kind of data structure from an array (an ordered list). A linked list maintains order. How is a linked list not an instance of an array? The kind of "array" you're thinking about is implemented only because the underlying machine has a MMU or otherwise linearly addressable memory, an allocator that returns contiguous regions of memory and employs arrays that are really linked lists with the next pointer computed at runtime rather than stored as part of the data structure. I slept through my CS undergraduate classes (literally -- to the point where professors openly ridiculed me during class which I also slept through) but even I learned this much. > but even so, your statement would still be invalid because even if a > linked list were a type of array, it would not mean a string were a > linked list. this is what i was trying to point out with cat - parrot > anology. while, a cat is an animal, and a parrot is an animal, a cat is > NOT a parrot. If it looks like a duck and quacks like a duck ... If, for some strange reason, the language you were in implemented the String class under-the-hood as a linked list of Characters. What then? If then, a String is _still_ not a linked list, then why is a String an Array in your world? -- Dossy -- Dossy Shiobara mail: dossy@panoptic.com Panoptic Computer Network web: http://www.panoptic.com/ "He realized the fastest way to change is to laugh at your own folly -- then you can let go and quickly move on." (p. 70)