Hacker News new | ask | show | jobs
by serichsen 4687 days ago

    s = []
    for x in range(100):
        s = s.append(x)
    format s
In other words, this is something that holds just the same for vectors of any type.

The "philosophical" "argument" is really not relevant, since the difference between characters and "symbols" seems to be just what you want (whatever that is), while words and sentences can be represented by strings themselves. This is just a tangent that adds nothing to the question of how to represent a string.

1 comments

You're missing the point. If you are appending items to a sequence, you are better of using a linked list type which is why your argument doesn't hold because you wouldn't be using an array type in the first place. But with "strings are character arrays" you can't choose. In the next step you get a proliferation of competing text types all because the default one wasn't defined as an adt.

Furthermore it isn't god given that the right way to iterate a text is character by character. Word by word or line by line is equally common. It's therefore completely arbitrary whether it's a character sequence, a line sequence or something else.

No amount of abstraction will save you from finally having to determine how to represent the end result. That is totally orthogonal to the ability to delay the accumulation of something to be represented that way (which is just one strategy to achieve efficiency for this case anyway).