caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Batteries: a question about Int32.pack, Int32.unpack
@ 2013-06-03 10:47 Matej Kosik
  0 siblings, 0 replies; only message in thread
From: Matej Kosik @ 2013-06-03 10:47 UTC (permalink / raw)
  To: caml-list, Matej Kosik

Hi,

I am currently looking at:

	Int32.pack
	Int32.unpack

functions.

If I try:

	open Batteries_uni

	let s = String.create 4
	Int32.pack s 0 42_l;

everything seems fine.

However, if I try:

	let s = String.create 5
	Int32.pack s 0 42_l;

I am getting an exception:

	Fatal error: exception Failure("Int32.pack: pos + 4 not within string")

I would like to ask: is this the expected behavior?
Why doesn't /pack/ simply use the first 4 bytes to the string and ignore all the other bytes that may be part of the string?

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-06-03 11:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-03 10:47 [Caml-list] Batteries: a question about Int32.pack, Int32.unpack Matej Kosik

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).