caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] How an exception could be an argument
@ 2012-02-17 18:16 Pierre-Alexandre Voye
  2012-02-17 18:33 ` Edgar Friendly
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Pierre-Alexandre Voye @ 2012-02-17 18:16 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 738 bytes --]

Hello, I'm trying to implement a scala concept "partial application" in
which one can chains pattern matching function. If the first failed, the
second is tried.
It seems it is impossible to give an exception as argument to a function.



exception Nothing;;

let (<|||>) a b = try a
with

  | Nothing ->  (try b
with

                   | Nothing -> raise
Nothing);;

val ( <|||> ) : 'a -> 'a -> 'a = <fun>


(raise Nothing) <|||>
"jj";;

Exception: Nothing.


But if I try :
try (raise Nothing)
with

  | Nothing ->  (try
"jj"with

                   | Nothing -> raise
Nothing);;

- : string = "jj"

Is there a workaround ?


Regards,
P-A
-- 
---------------------
https://twitter.com/#!/ontologiae/
http://linuxfr.org/users/montaigne

[-- Attachment #2: Type: text/html, Size: 3893 bytes --]

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

end of thread, other threads:[~2012-02-17 18:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-17 18:16 [Caml-list] How an exception could be an argument Pierre-Alexandre Voye
2012-02-17 18:33 ` Edgar Friendly
2012-02-17 18:49 ` Vincent Aravantinos
2012-02-17 19:31 ` Tiphaine Turpin

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).