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
How to refactor a large Ocaml program
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-12-14 (11:59)
From: Bruno De Fraine <Bruno.De.Fraine@v...>
Subject: Re: [Caml-list] How to refactor a large Ocaml program

I think there are a number of factors that certainly make it easier  
to develop refactoring tools for Ocaml:
- it is a static language
- there is already source code available for working with Ocaml code,  
e.g. ocamlc

> Ocaml already has the -dtypes. Why doesn't this file contain  
> information about where the functions and types are defined.

Yes, it seems like a good idea for ocamlc to emit defines/uses  
annotations, at least for lowercase identifiers in the syntax tree.  
For example, if I show these annotations in-place as comments:

let foo(* defines: _global01 *) = 12 ;;
let bar(* defines: _global02 *) x(* defines: _local01 *) =
	foo(* uses: _global01 *) + x(* uses: _local01 *) ;;
bar(* uses: _global02 *) foo(* uses: _global01 *) ;;
let foo(* defines: _global03 *) = "foo" ;;
(* etc. *)

Your editor would be able to jump from definition to usage and vice  
versa with this information.

Editing and recompiling is what we currently use to discover this  
information mechanically, but it seems better not to have to make  
destructive changes to source files.


Bruno De Fraine
Vrije Universiteit Brussel
Faculty of Applied Sciences, INFO - SSEL
Room 4K208, Pleinlaan 2, B-1050 Brussels
tel: +32 (0)2 629 29 75
fax: +32 (0)2 629 28 70