Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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 ;;
print_newline();;
let _ = print_int (Obj.magic v);;
print_newline();;
let _ = print_int (!(Obj.magic v));;
print_newline();;

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

Cheers,
--
Philippe Wang