caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Arrays and boxed/unboxed data
@ 2006-07-06  0:27 Erik de Castro Lopo
  2006-07-06 13:54 ` [Caml-list] " Eric Cooper
  0 siblings, 1 reply; 4+ messages in thread
From: Erik de Castro Lopo @ 2006-07-06  0:27 UTC (permalink / raw)
  To: caml-list

Hi all,

I'm about to start some work on an algorithm which will need a 
quite large 2-D array of Ocaml ints.

I assume that Arrays of ints will be unboxed. Is that correct?

What about other types? For instance:

    type my_enum = A | B | C

If I made an array of my_enum would that be unboxed?

Is there any general rule that will tell me what is boxed and
what is unboxed? If I define an Array of some data type is
there a way of figuring this out?

TIA,
Erik
-- 
+-----------------------------------------------------------+
  Erik de Castro Lopo
+-----------------------------------------------------------+
"I want to make sure (a user) can't get through ... an online
experience without hitting a Microsoft ad."
 - Microsoft CEO, Steve Ballmer on the Microsoft search engine.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] Arrays and boxed/unboxed data
  2006-07-06  0:27 Arrays and boxed/unboxed data Erik de Castro Lopo
@ 2006-07-06 13:54 ` Eric Cooper
  2006-07-08 15:25   ` Tom
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Cooper @ 2006-07-06 13:54 UTC (permalink / raw)
  To: caml-list

On Thu, Jul 06, 2006 at 10:27:21AM +1000, Erik de Castro Lopo wrote:
> Is there any general rule that will tell me what is boxed and
> what is unboxed?

Section 18.3 of the manual.

-- 
Eric Cooper             e c c @ c m u . e d u


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] Arrays and boxed/unboxed data
  2006-07-06 13:54 ` [Caml-list] " Eric Cooper
@ 2006-07-08 15:25   ` Tom
  2006-07-09 13:59     ` Jon Harrop
  0 siblings, 1 reply; 4+ messages in thread
From: Tom @ 2006-07-08 15:25 UTC (permalink / raw)
  To: caml-list

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

However, assuming you need a 2 dimensional array, that is int array array,
the second array will be boxed (elements of the first array will be pointers
to another array, but elements of these, secondary, arrays will be unboxed
integers).

You could probably use one dimensional array and use a modified getter and
setter functions that would transform 2-D indeces into 1-D indeeces. In this
way, all the elements would be unboxed.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] Arrays and boxed/unboxed data
  2006-07-08 15:25   ` Tom
@ 2006-07-09 13:59     ` Jon Harrop
  0 siblings, 0 replies; 4+ messages in thread
From: Jon Harrop @ 2006-07-09 13:59 UTC (permalink / raw)
  To: caml-list

On Saturday 08 July 2006 16:25, Tom wrote:
> You could probably use one dimensional array and use a modified getter and
> setter functions that would transform 2-D indeces into 1-D indeeces. In
> this way, all the elements would be unboxed.

Although you're likely to hit the max array length limit on 32-bit.

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-07-09 13:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-06  0:27 Arrays and boxed/unboxed data Erik de Castro Lopo
2006-07-06 13:54 ` [Caml-list] " Eric Cooper
2006-07-08 15:25   ` Tom
2006-07-09 13:59     ` Jon Harrop

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