On Thu, 3 Nov 2011, Riccardo (Jack) Lucchetti wrote:
On Wed, 2 Nov 2011, Allin Cottrell wrote:
> Remove t1 and t2 as members of gretl_matrix and replace them with a single
> pointer member (so gretl_matrix becomes leaner by 4 bytes). This pointer
> member is just NULL by default, but one it's allocated it has space to
> record t1 and t2, as well as column and/or row names if wanted.
This sounds like a brilliant idea to me. In a typical usage scenario, the
pointer will stay NULL in most cases, but has the potential to act like a
hook for appending any sort of metadata, if needed. Did I get this right?
Just about -- except that as things stand the hook (which
usually stays NULL, yes) is specified as a pointer to a
(private) structure called matrix_info_, which includes slots
for two integers (t1 and t2) and two char ** pointers intended
for arrays of names. That is, it's not just a general void *
pointer that could be used to attach any metadata.
Allowing the more general case would obviously give more
flexibility, but it would also increase complexity. For
example, when libgretl wants to read t1 and t2 from a matrix
what happens? Right now all we have to do is check that the
"matrix_info" pointer on the matrix is non-NULL and we know it
must hold t1 and t2 values. If the metadata pointer could hold
anything, we'd need some way of finding out what the heck it
holds.
Allin