From: "Conglun Yao" <yaoconglun@gmail.com>
To: "Jacques GARRIGUE" <garrigue@math.nagoya-u.ac.jp>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] How to handle try .... finally properly?
Date: Thu, 11 Dec 2008 00:52:49 +0000 [thread overview]
Message-ID: <f7b50d2a0812101652u1885dc38i8db446970dda9713@mail.gmail.com> (raw)
In-Reply-To: <20081211.090934.68540743.garrigue@math.nagoya-u.ac.jp>
> A usual workaround in such situations is to first partially apply your
> function to the (n-1) first arguments, as this should cause no
> side-effects. Since I suppose you are really talking about
>
> transform f x y
>
> you should rather write
>
> transform (f x) y
>
It indeed helps, forces to invoke function f (with two parameters)
inside transform.
We know how to use transform properly, passing a function with only
one parameter or passing curried f with n-1 parameters.
But what if we were providing a library, users still might use it
incorrectly, thus it will cause a runtime error rather than compile
time error.
I know it's difficult and (even) impossible to do this kind of compile
time checking,
zip1, zip2, zip3, .... zip7, mentioned by blue storm, might be a
better solution.
Ask users to follow the convention,
use zip1 if f has one parameter
use zip2 if f has two parameters
....
use zip7 if f has seven parameters
OR
transform only accepts function with one parameter, multiple
parameters must be passed as a touple type like (a, b, c)
> Note that this will not work properly if partial applications of f cause
> side-effects (i.e. f is actually "fun x -> ...; fun y -> ...").
> This is pretty rare, but I believe this is the case for printf for
> instance.
>
> Jacques Garrigue
>
prev parent reply other threads:[~2008-12-11 0:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-10 11:15 Conglun Yao
2008-12-10 22:58 ` [Caml-list] " blue storm
2008-12-11 0:09 ` Jacques GARRIGUE
2008-12-11 0:52 ` Conglun Yao [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f7b50d2a0812101652u1885dc38i8db446970dda9713@mail.gmail.com \
--to=yaoconglun@gmail.com \
--cc=caml-list@yquem.inria.fr \
--cc=garrigue@math.nagoya-u.ac.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox