Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Nicholas Kidd <nakidd@gmail.com>
To: Michael Ekstrand <michael@elehack.net>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Re: Symbol type
Date: Mon, 28 Jun 2010 08:37:37 -0500	[thread overview]
Message-ID: <AANLkTilNn3cD0HgXKqwWFX-oYO8eht3i1OUUVngJYQ22@mail.gmail.com> (raw)
In-Reply-To: <i091mj$e90$1@dough.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 1118 bytes --]

On Sun, Jun 27, 2010 at 9:33 PM, Michael Ekstrand <michael@elehack.net>wrote:

> On 06/27/2010 10:15 PM, José Romildo Malaquias wrote:
> > Is there a symbol type in OCaml, with a constant time comparison
> > function? Something like symbols from Scheme and LISP or atoms from
> > Prolog. Useful in compiler construction.
>
> Not directly.  As I see it, you have two decent options:
>
> - Use/write a symbol table which "interns" symbols to integers.  The
> resulting integers can be compared.
> - Use/write a symbol table which interns symbols to unique string
> instances, so SymTbl.intern "foo" returns the existing string object if
> one already exists, and the string object passed in if it's never been
> seen before.  The resulting strings can be compared with == rather than
> = in constant time.
>
> Either of these options would be fairly similar to how symbols work
> under the hood in a Lisp implementation, I believe.
>
>

Use the Ocaml hash-consing library.

http://gallium.inria.fr/ml2006/accepted/5.html
http://www.lri.fr/~filliatr/ftp/publis/hash-consing2.pdf

Best,
-Nick

[-- Attachment #2: Type: text/html, Size: 1814 bytes --]

  reply	other threads:[~2010-06-28 13:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-28  2:15 José Romildo Malaquias
2010-06-28  2:33 ` Michael Ekstrand
2010-06-28 13:37   ` Nicholas Kidd [this message]
2010-06-28  4:56 ` [Caml-list] " bluestorm

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=AANLkTilNn3cD0HgXKqwWFX-oYO8eht3i1OUUVngJYQ22@mail.gmail.com \
    --to=nakidd@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=michael@elehack.net \
    /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