In other words, in
a:="b"+"c"
IOW, does it implement the Slemiel's painting algorithm or not?
In other words, in
a:="b"+"c"
IOW, does it implement the Slemiel's painting algorithm or not?
type string struct {
data unsafe.Pointer
len int
}
The C version would be typedef struct string {
const *char data;
int len;
} string;
Edit: oh, ok. I Googled the "painting algorithm" reference. I swear I had read that before :-)I can't imagine how you would even implement a string as anything other than a rune array.
Even a Pascal string is just the string length followed by characters.
The answer is you can't. Because prefix-length strings (Pascal) are far better than null-terminated (C) strings.
You can also implement strings using a tree data structure. We do this in an implementation of Ruby that I work on because it can make concatenation faster.
So, look at text editor data structures for other representations. Examples:
- https://en.wikipedia.org/wiki/Gap_buffer
Also not a Haskell programmer, and really not meaning to criticize. Haskell seems awesome and I should learn it some day.