From: Mattias Waldau <mattias.waldau@abc.se>
To: Brian Hurt <bhurt@janestcapital.com>, caml-list@yquem.inria.fr
Subject: Re: [Caml-list] How to refactor a large Ocaml program
Date: Thu, 14 Dec 2006 09:09:33 +0100 [thread overview]
Message-ID: <458106BD.7060103@abc.se> (raw)
In-Reply-To: <45800CD5.8050401@janestcapital.com>
Yes, editing and compiling until it works is a way to refactor, and I
used that method before. However, this only works if you know what you
are doing. In many cases you realize the change you made was stupid and
you have to roll back, i.e. undo or revert using CVS.
One problem with ocaml syntax is the open-statement, i.e. this makes it
unclear for an editor
Ocaml already has the -dtypes. Why doesn't this file contain information
about where the functions and types are defined.
For example, if you have a function call
open Filename;
let _ =
concat .........
in main.ml
the main.annot contains
"main.ml" 183 7050 7070 "main.ml" 183 7050 7085
type(
string -> string -> string
)
An improvement would be if it also contained information about the
function, i.e.
"main.ml" 183 7050 7070 "main.ml" 183 7050 7085
type(
Filename.concat: string -> string -> string
)
Then, the editor mode 'M-x goto-tag' or similar could look in the .annot
file and open the correct file and go to the definition. (Maybe more
information than Filename.concat is needed).
Also, it would be very simple to find all calls to a specific function,
for example Filename.concat, just grep through all the annot-files.
---
When I wrote this, I thought that a simple solution would be to always
write the module name first and stop using 'open Filename'. However,
this doesn't work, since you are not allowed to write Filename.concat
inside the filename.ml file. Why? Couldn't we have a special case for this?
-- Mattias
Brian Hurt wrote:
> Mattias Waldau wrote:
>
>> I have a large ocaml program and I need to make major changes.
>>
>> After using C# with ReSharper in Visual Studio I am bit spoiled :-)
>> Having a reliable "Find Usage" feature in the browser is really useful
>> when you start tearing apart a program. It is really nice to be able
>> to go to the definition of a function directly, and find all locations
>> it is used.
>
>
> I have had good experiences with the following process: 1) make major
> changes to some module, 2) recompile everything, 3) have the recompile
> fail with an error because the changes made in step 1 changed the types,
> and I forgot to fix someplace that called the changed code- but the
> compiler gives me filename and line number of where I need to go fix, 4)
> repeat steps 2 & 3 until the code compiles, 5) test the code to make
> sure I haven't broken anything subtle.
>
> The reason there isn't a seperate tool for doing this is that it's built
> in to the compiler.
>
> Brian
>
next prev parent reply other threads:[~2006-12-14 8:09 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-13 12:37 Mattias Waldau
2006-12-13 13:09 ` [Caml-list] " Pietro Abate
2006-12-13 13:46 ` Jon Harrop
2006-12-13 13:53 ` skaller
2006-12-13 13:57 ` Richard Jones
2006-12-13 14:00 ` Yann Coscoy
2006-12-13 14:09 ` Jon Harrop
2006-12-13 14:31 ` Yann Coscoy
2006-12-13 14:42 ` Mattias Engdegård
2006-12-13 16:48 ` Gerd Stolpmann
2006-12-13 17:08 ` Jon Harrop
2006-12-13 13:51 ` Jim Miller
[not found] ` <45800CD5.8050401@janestcapital.com>
2006-12-14 8:09 ` Mattias Waldau [this message]
2006-12-14 11:59 ` Bruno De Fraine
2006-12-14 13:47 ` Brian Hurt
2006-12-15 15:33 ` Florian Hars
2006-12-16 10:14 ` Remi Vanicat
2006-12-16 13:53 ` Christian Stork
2006-12-18 19:37 ` Florian Hars
2006-12-15 5:07 ` Jacques Garrigue
2006-12-15 7:49 ` Mattias Waldau
2006-12-15 12:36 ` Jan Rehders
2006-12-15 13:11 ` skaller
2006-12-14 8:21 ` Mattias Waldau
2006-12-15 17:23 ` malc
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=458106BD.7060103@abc.se \
--to=mattias.waldau@abc.se \
--cc=bhurt@janestcapital.com \
--cc=caml-list@yquem.inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox