Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Symbol type
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
José Romildo Malaquias  
View profile  
 More options Jun 27 2010, 10:13 pm
Newsgroups: fa.caml
From: José Romildo Malaquias <j.romi...@gmail.com>
Date: Mon, 28 Jun 2010 02:13:16 UTC
Local: Sun, Jun 27 2010 10:13 pm
Subject: [Caml-list] Symbol type
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.

Romildo

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Ekstrand  
View profile  
 More options Jun 27 2010, 10:34 pm
Newsgroups: fa.caml
From: Michael Ekstrand <mich...@elehack.net>
Date: Mon, 28 Jun 2010 02:34:13 UTC
Local: Sun, Jun 27 2010 10:34 pm
Subject: [Caml-list] Re: Symbol type
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.

- Michael

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
bluestorm  
View profile  
 More options Jun 28 2010, 12:56 am
Newsgroups: fa.caml
From: bluestorm <bluestorm.d...@gmail.com>
Date: Mon, 28 Jun 2010 04:56:39 UTC
Local: Mon, Jun 28 2010 12:56 am
Subject: Re: [Caml-list] Symbol type

If your set of symbol is closed, you can use a variant type (sum type).

type symbols =
| A
| B

If you really need open symbols, you can use [polymorphic variants].

Let tag_a foo = (`A, foo)

 [polymorphic variants]
http://caml.inria.fr/pub/docs/manual-ocaml/manual006.html#toc36

However, you won't have convenience functions such as string_of_symbol; you
would have to define them yourself.

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nicholas Kidd  
View profile  
 More options Jun 28 2010, 9:38 am
Newsgroups: fa.caml
From: Nicholas Kidd <nak...@gmail.com>
Date: Mon, 28 Jun 2010 13:38:01 UTC
Local: Mon, Jun 28 2010 9:38 am
Subject: Re: [Caml-list] Re: Symbol type

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

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

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »