🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fa.caml
Article #40

[Caml-list] Batteries: a question about Int32.pack, Int32.unpack

#40
From: Matej Kosik
Date: Mon, 03 Jun 2013 11:28
35 lines
4134 bytes
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?

-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs
Technical Details
Message-ID: <fa.l2lOBgXnXzs1wMgXLqPBkvP/g3I@ifi.uio.no>
Path: arc1-ca.pugleaf.net!bp1ni32672pbd.1!nntp.google.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!news.glorb.com!feeder.erje.net!us.feeder.erje.net!goblin1!goblin.stu.neva.ru!uio.no!nntp.uio.no!.POSTED!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: c0fe4b917e,9954e6b1c5cb293e,start
X-Google-Attributes: gidc0fe4b917e,public,usenet
X-Google-NewGroupId: yes
X-Google-Language: ENGLISH,ASCII-7-bit
X-Received: by 10.66.250.226 with SMTP id zf2mr3780073pac.18.1370258908098;
        Mon, 03 Jun 2013 04:28:28 -0700 (PDT)
Path: arc1-ca.pugleaf.net!bp1ni32672pbd.1!nntp.google.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!news.glorb.com!feeder.erje.net!us.feeder.erje.net!goblin1!goblin.stu.neva.ru!uio.no!nntp.uio.no!.POSTED!not-for-mail
From: Matej Kosik <5764c029b688c1c0d24a2e97cd764f@gmail.com>
Newsgroups: fa.caml
Subject: [Caml-list] Batteries: a question about Int32.pack, Int32.unpack
Date: Mon, 03 Jun 2013 11:28:27 UTC
Organization: Internet mailing list
Lines: 35
Sender: caml-list-request@inria.fr
Message-ID: <fa.l2lOBgXnXzs1wMgXLqPBkvP/g3I@ifi.uio.no>
NNTP-Posting-Host: mail-jess.uio.no
Mime-Version: 1.0
X-Trace: readme.uio.no 1370258907 15239 129.240.7.9 (3 Jun 2013 11:28:27 GMT)
X-Complaints-To: abuse@uio.no
NNTP-Posting-Date: Mon, 3 Jun 2013 11:28:27 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130116 Icedove/10.0.12
To: caml-list@inria.fr, 
 Matej Kosik <5764c029b688c1c0d24a2e97cd764f@gmail.com>
X-IronPort-AV: E=Sophos;i="4.87,792,1363129200"; 
   d="scan'208";a="20037351"
X-Original-To: caml-list@sympa.inria.fr
Delivered-To: caml-list@sympa.inria.fr
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: Aj8BAIRzrFHRVdYvjWdsb2JhbABZgh4EhAy9DhYOAQEBAQcLCwkSBiSCagEbHAIDEhAWFhgDAgECARERAQUBIgEMCAKHdgEDDwSdRIxKgn2EHwoZJw1YiCUBBQyNU4UnA5c+hh6JPT+ENg
X-IPAS-Result: Aj8BAIRzrFHRVdYvjWdsb2JhbABZgh4EhAy9DhYOAQEBAQcLCwkSBiSCagEbHAIDEhAWFhgDAgECARERAQUBIgEMCAKHdgEDDwSdRIxKgn2EHwoZJw1YiCUBBQyNU4UnA5c+hh6JPT+ENg
X-IronPort-AV: E=Sophos;i="4.87,791,1363129200"; 
   d="scan'208";a="16560819"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=message-id:date:from:user-agent:mime-version:to:subject
         :x-enigmail-version:content-type:content-transfer-encoding;
        bh=+rn3APZ1/sp2jfda9Ql1L463MSHV2xhJdwkET+tWxCc=;
        b=Y1VgVmN4vIJsIM4qq3uQg0WWKAvUtaQC6NJscnxMtUSCKUcF4bdIAabgTB9wbwIaon
         jbqxyGeYpIa/A67Ur14htNz5O04MjRTvQZPt84ejt0n32VQ04gNzSczkC2wOsi9wJTn/
         iQodcdENUPCv0t9jeWCdMvr0+jLZM2yp53pag1jOoTgc8rkEDPQ8mnFdcJ/Evzmbqd9/
         EfxTfvTdUX0DqrRoftxcA359an4Y3KyEttJwEcNaZ3pAJyCa7nUp73YHzwvRphbP3fhU
         CQQPnSVbetW4jF4D/zF8JGtfbrS+eLS7cYFRDt0NDsUJ5RRW1ApJLK2+ezHEmUO4Et/R
         XPUw==
X-Received: by 10.205.36.79 with SMTP id sz15mr6243258bkb.94.1370256329102;
        Mon, 03 Jun 2013 03:45:29 -0700 (PDT)
X-Enigmail-Version: 1.4.1
X-Sequence: 6866
X-no-archive: yes
List-Id: <caml-list.inria.fr>
List-Archive: <http://sympa.inria.fr/sympa/arc/caml-list>
List-Help: <mailto:sympa_inria@inria.fr?subject=help>
List-Owner: <mailto:caml-list-request@inria.fr>
List-Post: <mailto:caml-list@inria.fr>
List-Subscribe: <mailto:sympa_inria@inria.fr?subject=subscribe%20caml-list>
List-Unsubscribe: <mailto:sympa_inria@inria.fr?subject=unsubscribe%20caml-list>
Original-Date: Mon, 03 Jun 2013 11:47:28 +0100
Original-Message-Id: <51AC7440.8050001@gmail.com>
X-Received-Bytes: 3740
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit