English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Compiler feature - useful or not?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-11-14 (16:20)
From: Brian Hurt <bhurt@j...>
Subject: Re: [Caml-list] Compiler feature - useful or not?
Edgar Friendly wrote:

>Yaron Minsky wrote:
>>module type Abs_int : sig
>>type t
>>val to_int : t -> int
>>val of_int : int <- t
>>And then you write concrete module Int that implements this signature.  You
>>can then write:
>>module Row : Abs_int = Int
>>module Col : Abs_int = Int
>This approximates my idea of "optimal" well enough that I'll rewrite
>some of my old code to use it.  It loses some opportunities for compiler
>optimization, but otherwise seems perfect.  No repetitive boilerplate to
>write over and over, no unnecessary boxing, efficient conversion to the
>base type (well, it still requires a function call to find out that
>nothing needs to change, and maybe there's a shallow copy created in
>this process), easy on the eyes/fingers syntax for conversion and
>declaration and a readable type name for ocamlc to report when things go

Actually, Ocaml is pretty good at cross-module inlining, so that 
normally the function call is optimized out, and the whole conversion 
becomes a no-op.  Or, at least, such has been my experience.