From: Tom Sawyer Date: 2002-07-08T07:44:37+09:00 Subject: Re: is there a better string.each? i think you all have taken my words much further then they were intended. please forgive me if i have mislead you in this regard. obviosuly strings can be implemented in a number of ways: arrays, linked list, etc. (i don't count hypercubes :-) but no matter these implementaions, a string is an ordered list of characters. isn' it? i have heard that its an ordered list of words, sentences, etc. but these are all made of characters. so...no matter how a string is implemented, the implementation must take into the account: order, list, and character. now, an array too, no matter its implementation (yes, they are implemented to, right?) likewise must take into account: order, list, and object. the only point i am trying to make is that in so far as both account for order and list, i want their exposed methodologies to be the same. that's it. (whihc is why .each should work differently) now as far as what is what. i don't know how it can be any clearer that since a character in a type of object, a string is a type of array -- by mere definition, irregardless of implementation. i only brought up implementation because, given this very definition, more often then not --and by a vast margin, that's exactly how a string ends up in the underbelly of all code: as an array. but, i hear you say, if a string is implemented as a linked list, then it is not an array! but you beg the question. for what makes an array an array? order, list, and object. a linked list too partkes of these qualities and thus partakes of arrayhood, as will any implementation one devises for string, for the simple fact that a string is what it is --it partakes in arrayhood. ~transami p.s. i have programmed in c/c++ some 10 odd years ago. i lean toward scripting languages now for many reasons, and ruby has become my fav. On Sun, 2002-07-07 at 16:19, Dossy wrote: > 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) > -- ~transami "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -- Benjamin Franklin