caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Chris King <colanderman@gmail.com>
To: David MENTRE <dmentre@linux-france.org>
Cc: "O'Caml Mailing List" <caml-list@inria.fr>
Subject: Re: [Caml-list] Sparse structure
Date: Thu, 7 Jul 2005 16:16:43 -0400	[thread overview]
Message-ID: <875c7e070507071316460ea88@mail.gmail.com> (raw)
In-Reply-To: <87r7eamlv9.fsf@linux-france.org>

On 7/7/05, David MENTRE <dmentre@linux-france.org> wrote:
> Unless I haven't understood what you want to do, you don't need the
> foo_key type. The foo_value type already contains the key through the
> sum type.
> 
> So I would use:
> type foo_value = A_value of int | B_value of float
> type sparse = (int (*or whatever is your key*), foo_value) Hashtbl.t

It's not foo_key I have a problem with (that's what I want), it's
foo_value I want to ditch.  I tried using only foo_value and Obj.tag
to generate hash keys based on the foo_value tag, which worked fine
for sticking data into the hash table but not so well for getting it
back out.

> Think also at the readability of your code. Except in very few
> situations, having maintainable code is more important that memory or
> CPU efficient code.

Memory is definitely an issue here; I'm going to have thousands of
these structures each with hundreds of unused fields.  CPU time is not
so much, which is why I'm leaning toward my initial solution, but
having to access structure fields like this:

(match Sparse.get A_key with A_value v -> v | _ -> assert false)

doesn't do much for readability (hence why I want to dump the foo_value type).

- Chris


  parent reply	other threads:[~2005-07-07 20:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-07 19:27 Chris King
     [not found] ` <1120765639.9384.42.camel@titania>
2005-07-07 20:04   ` [Caml-list] " Chris King
     [not found] ` <87r7eamlv9.fsf@linux-france.org>
2005-07-07 20:16   ` Chris King [this message]
2005-07-08  0:57 ` Jacques Garrigue
2005-07-08 13:29   ` Chris King
2005-07-08 23:29     ` Jacques Garrigue

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875c7e070507071316460ea88@mail.gmail.com \
    --to=colanderman@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=dmentre@linux-france.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).