N
Nikolai Weibull
* ES (Mar 20, 2005 18:10):
That's a very good point. There is definitely some sort of correlation
between the relationship between Fixnum and Bignum and that between
String and Rope.
Definitely. But that's due to the fact that Strings are implemented as
a sequence of bytes, where we can simply decrement RSTRING(str)->len and
write a '\0' at RSTRING(str)->ptr[RSTRING(str)->len - 1]. It's
interesting to note that chop! returns self, so that it may easily be
chained with other methods,
nikolai
Ropes are used fairly widely and would be a good solution to this
problem. In addition, I see no reason why Strings and Ropes could not
use the same idiom as Fixnum and Bignum, where the former is
automatically converted (but the latter may also be explicitly
instantiated).
That's a very good point. There is definitely some sort of correlation
between the relationship between Fixnum and Bignum and that between
String and Rope.
Interesting... I certainly see the validity of your call to optimize
the nondestructive operations; I'm sure the performance can be
reasonably close to destructive when properly designed. However, it
will still have an impact in _some_ programs even when we're dealing
with these minimal differences.
And I still assert that it's conceptually better to s.chomp! than to s
= s.chomp
Definitely. But that's due to the fact that Strings are implemented as
a sequence of bytes, where we can simply decrement RSTRING(str)->len and
write a '\0' at RSTRING(str)->ptr[RSTRING(str)->len - 1]. It's
interesting to note that chop! returns self, so that it may easily be
chained with other methods,
nikolai