-1

I noticed that in OCaml we are allowed to use currying function like

let add = 
    fun y -> (fun x -> x + y)  
;;

But my professor stated that this kind of format is not allowed in Java. For example, given a method foo1, it is possible to have foo1 returns when foo2 is executing. Is it a valid explanation? If not, what leads to this difference between Java and OCaml?

int foo1(int a, ...) {
    int foo2(...) {
        //main body         
    }
}
objmagic
  • 1,028
  • 1
  • 9
  • 18
Yufan Fei
  • 59
  • 6
  • 2
    Because Ocaml and Java are different languages? Why do you think everything that is allowed in one language be valid in another? But do note that you actually can make it in Java 8. – Tunaki Feb 16 '16 at 23:21
  • @Tunaki I'm just wondering what's happening under the scenes. – Yufan Fei Feb 16 '16 at 23:49

1 Answers1

1

The professor should get out more. See for example Does java support Currying? (the answer is yes).

Community
  • 1
  • 1
David Soroko
  • 8,521
  • 2
  • 39
  • 51