Difference in calling redefined functions in F# and Clojure

Posted by Michiel Borkent on Stack Overflow See other posts from Stack Overflow or by Michiel Borkent
Published on 2010-04-03T08:09:34Z Indexed on 2010/04/03 8:13 UTC
Read the original article Hit count: 196

Filed under:
|
|

In F#:

> let f x = x + 2;;

val f : int -> int

> let g x = f x;;

val g : int -> int

> g 10;;
val it : int = 12
> let f x = x + 3;;

val f : int -> int

> g 10;;
val it : int = 12

In Clojure:

(defn f [x]
  (+ x 2))

(defn g [x]
  (f x))

(g 10) ;; => 12

(defn f [x]
  (+ x 3))

(g 10) ;; => 13

Note that in Clojure the most recent version of f gets called in the last line. In F# however still the old version of f is called. Why is this?

© Stack Overflow or respective owner

Related posts about clojure

Related posts about F#