Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0004751OCamlOCaml generalpublic2009-03-18 20:102013-10-23 17:14
Reportermottl 
Assigned Togarrigue 
PrioritynormalSeverityfeatureReproducibilityN/A
StatusassignedResolutionopen 
PlatformOSOS Version
Product Version3.11.0 
Target VersionFixed in Version 
Summary0004751: caml_hash_variant not available in standard library
DescriptionThe runtime C-function "caml_hash_variant", which takes a string and calculates the hash value associated with e.g. a polymorphic variant of that name, is currently not callable from within OCaml. Could you please add a binding for it to some module in the standard library (maybe Hashtbl, next to "hash")?
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0007497)
garrigue (manager)
2012-06-01 09:45

What would you need hash_variant for?
I see no legal use from inside ocaml.
You can already do it for fixed strings by (Obj.magic `Variant : int).
You can also copy the corresponding function from ocaml sources
(it is supposed to be fixed forever).
(0007502)
mottl (reporter)
2012-06-01 15:04

If I remember correctly, this function was needed back then for some code generation or preprocessing stuff. I implemented it in OCaml for the type_conv library, but it's actually not used by any public library anymore. It's presumably not super-important.
(0007695)
gares (reporter)
2012-07-10 18:52

+1 for this function in the Obj module.

I have a use case.
Coq marshals to disk its data structures (creating .vo files).
The coqchk tool verifies that .vo files have the right format (and also that
their content is sound). It is written in OCaml and uses Obj.* introspection facilities to verify the format (the type) of the marshaled data.

Without Obj.hash_variant polymorphic variants cannot be used in the data
structures Coq marshals to disk.
(0008973)
mbarbin (reporter)
2013-03-15 15:02

+1 for this function in the Obj module.

If you do some type related preprocessing it is likely that you'll end up needing it. I also have a use case for it in a piece of code that deals with runtime types.

> You can also copy the corresponding function from ocaml sources
> (it is supposed to be fixed forever).

this is indeed in practice what we do for now at janestreet, paired with a few unit tests to make sure this matches what the compiler does, but it seems like a binding would be better.

the stability of the computation can be discussed separately I guess.
(0010524)
hongboz (developer)
2013-10-23 17:14

I have another use case for partial evaluation, if the user knows the literal string at the compile time, we can pre-hash the string and then compare the integer instead of string, which is much faster.

- Issue History
Date Modified Username Field Change
2009-03-18 20:10 mottl New Issue
2009-04-29 15:42 doligez Status new => acknowledged
2012-06-01 09:45 garrigue Note Added: 0007497
2012-06-01 09:45 garrigue Assigned To => garrigue
2012-06-01 09:45 garrigue Status acknowledged => feedback
2012-06-01 15:04 mottl Note Added: 0007502
2012-06-01 15:04 mottl Status feedback => assigned
2012-07-10 18:52 gares Note Added: 0007695
2013-03-15 15:02 mbarbin Note Added: 0008973
2013-10-23 17:14 hongboz Note Added: 0010524


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker