[
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: | -- (:) |
| From: | John Gerard Malecki <johnm@a...> |
| Subject: | RE: [Caml-list] Let-in vs beta-redex |
Lukasz Stafiniak wrote (2003-09-01T18:15:54+0200):
> Hi,
>
> Is let-in more efficient than beta-redex or are they computationally
> equivalent? Is let-in a syntax-sugar of beta-redex?
They may be conceptually different but they compile to pretty much teh
same thing. A nice trick to learn about the code that ocamlc
generates is to use 'ocaml -dinstr'. For example,
:; ocaml -dinstr
Objective Caml version 3.07+beta 2
# let x = sin 2. in x *. x *. x;;
const 2.
ccall sin_float, 1
push
acc 0
push
acc 1
push
acc 2
ccall mul_float, 2
ccall mul_float, 2
return 2
- : float = 0.751826944668992803
# (fun x -> x *. x *. x) (sin 2.);;
const 2.
ccall sin_float, 1
push
closure L1, 0
appterm 1, 2
L1: acc 0
push
acc 1
push
acc 2
ccall mul_float, 2
ccall mul_float, 2
return 1
- : float = 0.751826944668992803
#
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners