caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Style question: excessive currying confusion?
@ 2001-08-23 17:06 Brady Montz
  2001-08-23 19:13 ` Gerd Stolpmann
  0 siblings, 1 reply; 3+ messages in thread
From: Brady Montz @ 2001-08-23 17:06 UTC (permalink / raw)
  To: caml-list

[ I posted this to comp.lang.ml a few weeks ago, before I found this
  list ]

Howdy ya'll. I'm a long time C and lisp programmer who's taken on
learning CAML for real. I played with ML a bit a few years ago in grad
school.

So I'm working through lots of CAML code now, and I find code which
"excessively" uses currying to be a bit hard to read. I'm curious if
this gets better with practice, and if anyone has some good style
rules about this.

So, here's an extremely simple example:

let fun1 x y z =
  [ x; y; z];;

let fun2 x = 
  fun1 (x + 1);;

(* alternative implementation of fun2 *)
let fun3 x y z = 
  fun1 (x + 1) y z;;

Suppose I'm reading through someone else's program, and I come across
the definition for fun2, and I want to know what it does. I can't even
know how many parameters fun2 takes until I refer to the definition of
fun1. The confusion is worst when I don't even know I'm confused about
the number of args fun2 can take.

Now, in most cases I've hit the confusion would have been much
lessened with proper function naming and commenting, but not always. 

Now, on the other hand, there are times when currying is obviously
great. For example, if it is really important to me that fun2 always
have a similar signature to fun1, then this seems fine to me. Also,
there is benefit to keeping the code succinct.

So, anyhoo, if anyone has helpful advise to this ML newbie, I'd much
appreciate it. 

-- 
 Brady Montz
 bradym@balestra.org
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-08-23 19:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <Pine.LNX.4.21.0108231312400.32015-100000@kinsman.panasas.com>
2001-08-23 18:16 ` [Caml-list] Style question: excessive currying confusion? Brady Montz
2001-08-23 17:06 Brady Montz
2001-08-23 19:13 ` Gerd Stolpmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).