[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2007-04-26 (03:13) |
From: | skaller <skaller@u...> |
Subject: | Re: [Caml-list] Function application implementation |
On Thu, 2007-04-26 at 00:38 +0200, Tom wrote: > I have a question about how are function applications compiled. In > particular, how does the program "know" the difference between f and g > in: > But obviously, this cannot be the case, as the functions aren't > determined in advance at all call sites (in a functional language). > How does the compiler deal with that? It knows the type of the function expression, and that is all that is required. Incidentally Ocaml evaluates right to left. So f x y z will be roughly: push (eval z) push (eval y) push (eval x) push (eval f) apply apply apply I guess this simple stack protocol explains why it evaluates right to left not left to right. The real compiler will of course do optimisations not shown above. -- John Skaller <skaller at users dot sf dot net> Felix, successor to C++: http://felix.sf.net