Date: Fri, 4 Oct 1996 16:33:20 +0100
From: bravier@dassault-avion.fr (Utilisateur FNET)
Message-Id: <9610041533.AA02917@fnet-ia1.dassault-avion.fr>
Subject: ocamlc syntax and -i option
961004
(* ========================================================================= *)
Hi caml community,
Here are a few suggestions about ocaml, all opinions are welcome.
Thierry Bravier
Dassault Aviation.
DGT / DTN / ELO / EAV
78, Quai Marcel Dassault
F-92214 Saint-Cloud Cedex
France
Telephone : (33) 01 47 11 53 07
Telecopie : (33) 01 47 11 52 83
E-Mail : bravier@dassault-avion.fr
===============================================================================
INFIX OPERATORS :
=================
Can `Foo.( + )' be used as an infix operator ?
# Pervasives.(+) 1 2;;
- : int = 3
# 1 Pervasives.+ 2;;
Syntax error
A prefix usage is available but a prefix usage would really be great
otherwise you'd have to open all module defining prefix operators.
Just suppose Pervasives were not open by default, you could not write
[1; 2] Pervasives.@ [3;4];;
but should write
Pervasives.( @ ) [1; 2] [3;4];;
===============================================================================
OCAMLC -i OPTION :
==================
I often find myself recompiling source code with the -i option just to
see the types.
Unfortunately this also recreates a .cmo / .cmi file as a side effect,
something not necessary (especially when you use make) when you just
want to look at types.
Would it be possible to have a `type-check-no object code' option that
could be used with or without the existing -i option ?
By the way, when using -i, if the type-checker finds a type-error you
do not get the types of previous correct values. This would be useful too
(as I often have to comment out the incorrect code to understand the error).
===============================================================================
FUNCTOR SYNTAX :
================
% cat foo.ml
module type DUMMY = sig val dummy : unit end
module type FUNCTOR_1 = functor (Dummy : DUMMY) -> DUMMY (* ok *)
module type FUNCTOR_2 (Dummy : DUMMY) = DUMMY (* why not *)
% ocamlc -c foo.ml
File "foo.ml", line 3, characters 22-23:
Syntax error
This extension would make the syntax more homogeneous and much easier
for functors with multiple arguments
module type FOO (Ma : MA) (Mb : MB) (Mc : MC) = MZ
instead of
module type FOO =
functor (Ma : MA) ->
functor (Mb : MB) ->
functor (Mc : MC) ->
MZ
===============================================================================