|
On Aug 22, 2014 7:13 AM, "Coroutines" <coroutines@gmail.com> wrote:
>
> On Fri, Aug 22, 2014 at 3:59 AM, Jay Carlson <nop@nop.com> wrote:
> > Mutable strings are...a folly of a quaint, bygone era. They are warts on
> > otherwise timeless designs like Scheme and Smalltalk.
> >
> > Get a mutable octet-vector object type. You'll be much happier.
>
> Again I get this feeling like people love to speak in generalizations
> on this list :\
> Perhaps you know this:
Yes. "I am aware of all Internet traditions."
> In networking/socket stuff
> it's useful to reuse a buffer if you know you're receiving frames of a
> fixed size, packets of a fixed size
Yes. It is also a relatively common error to reuse bufs/pool members before all references to them have dropped.
> I work
> with other libraries that expect strings
...and may break with a mutable string type.
Changing Lua 6.0 to include a mutable string type would in turn force those libraries to change.
> Strings are a thin abstraction over userdata
No. Strings have value semantics. From a semantic point of view they are not allocated or deallocated. Nobody owns them.
IIRC a long time ago (4.0), userdata acted more like strings. You could not distinguish two userdatas if the C contents were == at the C level; however, userdata was a void*, not a block of memory.
> If I
> wanted to minimally change Lua how it is now, I'd make it so userdata
> can be used in the same places strings can.
Any userdata? Or just a specific mutable octet vector type?
Not my problem; go for it!
Jay