caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: kirillkh <kirillkh@gmail.com>
To: skaller <skaller@users.sourceforge.net>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] best and fastest way to read lines from a file?
Date: Tue, 2 Oct 2007 23:05:07 +0200	[thread overview]
Message-ID: <e2d02be30710021405k177f1afpa9c25463ba7a885a@mail.gmail.com> (raw)
In-Reply-To: <1191353751.6668.47.camel@rosella.wigram>

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

2007/10/2, skaller <skaller@users.sourceforge.net>:
>
> On Tue, 2007-10-02 at 20:02 +0200, kirillkh wrote:
> > Replying to a private mail from Brian:
>
> > (* I couldn't figure out, how to declare a polymorphic exception
> > properly *)
> > exception Done of 'a
>
> That's easy -- you can't: even if you could, how could
> you possibly use it?
>
> This compiles fine:
>
> type t = { field : 'a. 'a }
> exception Done of t
>
> but 'field' is useless. This is not at all the same as
>
>         let f (x:'a) (g:'a -> int) =
>         match g x with
>         | 0 -> ..
>         | ..
>
> because *inside* the function, 'a is not a type variable,
> and the code is not polymorphic, it is simply a sole
> unknown type, sometimes said to be monomorphised.
>
> The problem with exceptions is that they're not captured,
> so they cannot be polymorphic. Exceptions SUCK because
> their context is not delimited -- you can throw all the way
> out of the mainline .. :)
>
> [This happens to me regularly and it can takes days to figure
> out what is Not_found ..]


Is there a way to instantiate an exception with a value of unspecified type
and then do explicit casting on catch?

Is it a deficiency in the language? I suppose OCaml could support
polymorphic exceptions, if they were checked, like in Java, and appeared in
function signatures in a similar way to parameters and return values.

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

  reply	other threads:[~2007-10-02 21:05 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-01 21:27 YC
2007-10-01 21:55 ` [Caml-list] " Daniel Bünzli
2007-10-01 22:29   ` YC
2007-10-01 21:55 ` Olivier Roussel
2007-10-02 12:39   ` Mattias Engdegård
2007-10-02 12:56     ` Brian Hurt
2007-10-02 16:15       ` kirillkh
2007-10-02 17:10         ` verlyck, Bruno.Verlyck
2007-10-02 18:02         ` kirillkh
2007-10-02 19:35           ` skaller
2007-10-02 21:05             ` kirillkh [this message]
2007-10-02 21:07               ` Jon Harrop
2007-10-02 20:23           ` Olivier Andrieu
2007-10-02 20:49             ` kirillkh
2007-10-02 21:10               ` Jon Harrop
2007-10-02 21:15               ` David Allsopp
2007-10-02 22:23                 ` skaller

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=e2d02be30710021405k177f1afpa9c25463ba7a885a@mail.gmail.com \
    --to=kirillkh@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=skaller@users.sourceforge.net \
    /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;
as well as URLs for NNTP newsgroup(s).