[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Defining a library for mutable byte arrays
- From: Dirk Laurie <dpl@...>
- Date: Sun, 5 Jun 2011 10:57:49 +0200
On Sun, Jun 05, 2011 at 04:09:02AM +0200, Javier Guerra Giraldez wrote:
> the main difference is mutability. being non-interned is just a
> consequence that can be handy on some cases.
A data structure is not only about how it is stored, it is also
about what set of operations one intends to do on it. For example,
in Lua 5.2 there are two libraries that operate on numbers: math
and bit32. These think about numbers in two different ways.
I can see a possible need for two kinds of byte arrays:
1. Mutable strings, with operations rather like the string
library but modifying the string in-place rather than
returning a new string.
2. Arbitrary length bit patterns, with operations rather
like the bit32 library but not restricted to 32 bits.
But sure these can simply be implemented as userdata and brought in
by "require". No need for further Lua types.
I recently made another attempt to read "A gentle introduction to
Haskell". The previous attempt was before I learnt Lua. I was
astounded to find how much stronger than before I am put off by the
profligate proliferation of types, now that I have seen how far
one can get with eight types only.