Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
A Question About Types and Inlining
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-12-09 (01:16)
From: Philippe Wang <lists@p...>
Subject: Re: [Caml-list] A Question About Types and Inlining

Eric Cooper a écrit :
> You can use
>   type variable = Variable of int
>   etc.
> in your signatures.
> This makes the representation visible for optimization purposes,
> incurs no representation overhead, but will catch most typing
> mistakes.

I don't get it... Can you tell how adding some boxing/unboxing matter 
can help having better performance ?

I tried this with ocamlopt -inline 4

type v = V of int
let v = V 42 ;;
let _ = match v with V x -> print_int x ;;
let _ = print_int (Obj.magic v);;
let _ = print_int (!(Obj.magic v));;

So whether the Obj.magic "tells" the compiler not to optimise the values 
of type v, whether I really don't get what you meant...

Philippe Wang