* explict vs inexplicit constant parameters
@ 2000-08-03 4:10 Julian Assange
2000-08-04 18:23 ` Alain Frisch
0 siblings, 1 reply; 2+ messages in thread
From: Julian Assange @ 2000-08-03 4:10 UTC (permalink / raw)
To: caml-list; +Cc: proff
I often use the following:
let findpair e l =
let rec find = function
| [] -> None
| (a,b)::tl -> if a = e then Some b else findpair tl
in
find l
instead of:
let findpair e l =
let rec find e = function
| [] -> None
| (a,b)::tl -> if a = e then Some b else findpair e tl
in
find e l
Is ocaml able to generate faster code for the former?
Stylistically, I'm not sure whether these constructs are a good thing
or not. Symbolic brevity makes makes it easier to read for small
contexts. On the other hand for larger contexts, the de-localisation
of variables makes the whole thing harder to follow and dangerous to
re-order.
Cheers,
Julian.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: explict vs inexplicit constant parameters
2000-08-03 4:10 explict vs inexplicit constant parameters Julian Assange
@ 2000-08-04 18:23 ` Alain Frisch
0 siblings, 0 replies; 2+ messages in thread
From: Alain Frisch @ 2000-08-04 18:23 UTC (permalink / raw)
To: Julian Assange; +Cc: caml-list
On 3 Aug 2000, Julian Assange wrote:
> ...
> Is ocaml able to generate faster code for the former?
>
This is a FAQ:
http://caml.inria.fr/ocaml/speed.html
http://caml.inria.fr/FAQ/FAQ_EXPERT-eng.html#curry_et_rec
<< Should I use local functions to factor out invariant parameters of a
recursive function? >>
--
Alain Frisch
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2000-08-05 18:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-08-03 4:10 explict vs inexplicit constant parameters Julian Assange
2000-08-04 18:23 ` Alain Frisch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox