From: Maxence G. <max...@in...> - 2003-02-25 22:38:01
|
> > What a pity when the type of a function (for example the order of > > arguments) is *almost* what we need and we have to create a dummy > > function, for example to change the order of the arguments... > > How much of a problem is this? I mean, to do: > let foo x y = bar y x ;; > strikes me as being seriously trivial. Yes, but it really bothers me to define such functions in my code, because I must find a not conflicting and still meaningful name for these, or use a function defined "on the fly". Example : I have a set module MySet (result of the Set.Make functor), containing the function add : elt -> t -> t Now if I want to build a MySet.t from a list, I use fold_left like this : List.fold_left (fun set e -> MySet.add e set) MySet.empty my_list I could have used List.fold_right MySet.add my_list MySet.empty but fold_right is not tail-recursive, so I think MySet.add should have the type add : t -> elt -> t In this case, I would not have to pollute my code with (fun set e -> MySet.add e set) You can say the workaround is trivial, but it happens quite often. > A bigger problem for me is to make the arguments in a standard order. One > thing that *always* annoys me in C is: > fprintf(stream, "string"); > fputs("string", stream); > > I'd much perfer to have a standard order for arguments, to make them > easier to remember. For example, in data-structure oriented APIs, the > data structure to act upon/use should always be the first argument. Etc. I agree. > Having to look up the order of arguments every time you use the function > encourages programmers to not use the function. I agree again. -- Maxence Guesdon |