Dear ocamlers,

Christophe Raffalli a écrit:

Here is a list of request for Ocaml that would really make the libray
for formal and numerical calculus better (see
http://www.raffalli.univ-savoie.fr/~RAFFALLI/formel.html) :

- include with ...

and
- include in structure.
would be great.
- Infix operator like + ...
        R.+ should be an infix operator and R.(+) would be prefix.
I would like that too.
        One could event think to reuse symbols like + for many functions.
        Here is a simple proposal on how to do it that I would really enjoy to
        see working :

        Two new commands in OCaml structure (the syntax can be changed):

        share + : 'a -> 'a -> 'a

        this makes that + exists and is type-checked with type 'a -> 'a -> 'a

        share + = add_int
        share + = add_float
        ...
 

I fear that your share proposal will not interact well with separate compiling of modules:
how can the list of all share definition be completely know to the compiler ?
It reminds me of the now obsolete overload keyword in C++.
 
        One could even allow some kind of recursive macros !

        share + = fun (x,y) (x',y') -> (x+x', y+y')
        share + = List.map2 (+)
        share + = Array.map2 (+)

        This is a bit mode difficult to implement, but it seems feasible.

This, I think, is inspired by C++ templates and specialisation issues;
I don't think it is in the spirit of ML because for instance adding a new share definition
could totally change the meaning of another previous share definition.

Maybe there is anyhow a way to find a strict, satisfying meaning to share.

Does somebody have insights ?

Cheers.

Thierry Bravier