1) Recent c++ has several syntaxes for specifying types of functions, see e.g:
http://en.cppreference.com/w/cpp/utility/functional/function

2) C++ has the equivalent of first class functions.

One of the main problems of  functional programming in C++ is that it doesn't really
support composition of algorithms very well. This guy explains it very well:
https://www.youtube.com/watch?v=BFnhhPehpKw
Greetz,
i


On Tue, Nov 10, 2015 at 3:11 PM, Hendrik Boom <hendrik@topoi.pooq.com> wrote:
On Tue, Nov 10, 2015 at 08:27:52AM +0000, Soegtrop, Michael wrote:
> Dear Ocaml Users and Developers,
...
...
>
> Another note: it was suggested in this mail thread to enforce type
> specifications for function arguments to make the life of beginners
> easier. I would rather not do this. A functional language lives from
> function arguments and in many cases it is clear what it is and being
> forced to write this down would be just a nuisance. I enjoy the
> flexibility to give the types only at interface functions and to leave
> it away in internal functions where it is clear. People coming from
> C++, where functional style programming is turned done a lot by the
> heavy syntax required to write down what you want, will definitely
> enjoy this.

Please, the problem with C++ for functional programming isn't that you
have to specify the types of functions; it's that the syntax of types in
C++ is completely inside-out and insane.  I've been programming in C
since the 70's and I *still* find it confusing.  OCaml type notation,
like Algol 68 type notation, is a breath of fresh air by comparison.

And of course, that C++ doesn't have first-class functions.  Or has that
changed recently?

> What might help to make the life of beginners easier is to
> have a compiler option to print the types of all defined functions. I
> think many people don't start with ocamltop, but with the compiler. In
> my case I started a project where I thought it is likely easier to
> learn Ocaml and to write it in Ocaml than to write it in C++. Such
> projects you don't start with ocamltop. But for high reliability code,
> it would make sense to have a compiler option to enforce full type
> specifications of all arguments.

In any case, the problem with OCaml's apparent typelessness isn't that
you don't have to write the types, it's that when you see someone
else's code you can't read the types.

--- hendr9ik

--
Caml-list mailing list.  Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs