From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.0 required=5.0 tests=AWL,HTML_MESSAGE,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 15A32BC6C for ; Tue, 2 Oct 2007 23:05:10 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAALhPAkdA6aLokGdsb2JhbACCPDWLRQEBAQEHBAQREQc X-IronPort-AV: E=Sophos;i="4.21,221,1188770400"; d="scan'208";a="17209796" Received: from nz-out-0506.google.com ([64.233.162.232]) by mail4-smtp-sop.national.inria.fr with ESMTP; 02 Oct 2007 23:05:09 +0200 Received: by nz-out-0506.google.com with SMTP id x7so2866821nzc for ; Tue, 02 Oct 2007 14:05:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; bh=uy+Oj0YGmAJ4TDY5wmr0DQVhl9keDQXHWJyDrSuM4Y0=; b=I+dEHnUyg4ceTBMznFbMadESVpFB0tGXPUjgmR7Es2LNBsgHVzlC1LygmOYbRlcuOuwjF3Ld64//mFnfNpfNlEUgV6qxF/O97764youPhVhV/6HrYiEa72viSOD/W+p222exifQHxTpWkSj6n9H7/882tb8hBYv+25wJdGc+BIE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=Bwda40SbbE0R/AMuYk5OX5JDbfzHM6SCGIea53s0uVAEDSh0lQHl0DzEQhoAPcAjYdP2WSekwWBjwITZBzjybsCB5xud3PltqnbQKnGJvd/I0opG9kn1D0joHKw8bN264/wSiudRyyD2U3BLvmxMf8lMyTuYXYfASYIaxPwRHeM= Received: by 10.114.154.1 with SMTP id b1mr3035168wae.1191359107456; Tue, 02 Oct 2007 14:05:07 -0700 (PDT) Received: by 10.114.25.8 with HTTP; Tue, 2 Oct 2007 14:05:07 -0700 (PDT) Message-ID: Date: Tue, 2 Oct 2007 23:05:07 +0200 From: kirillkh To: skaller Subject: Re: [Caml-list] best and fastest way to read lines from a file? Cc: caml-list@yquem.inria.fr In-Reply-To: <1191353751.6668.47.camel@rosella.wigram> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_20445_5908914.1191359107448" References: <779bf2730710011427g5983da4cw6ad8b715a9e38771@mail.gmail.com> <47016CEE.8010704@crans.org> <200710021239.l92CdwZ15641@virtutech.se> <47024002.2080206@janestcapital.com> <1191353751.6668.47.camel@rosella.wigram> X-Spam: no; 0.00; 0200,:01 delimited:01 unspecified:01 ocaml:01 0200,:01 delimited:01 unspecified:01 ocaml:01 suck:98 W8:98 W8:98 suck:98 sourceforge:01 sourceforge:01 polymorphic:01 ------=_Part_20445_5908914.1191359107448 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 2007/10/2, skaller : > > 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. ------=_Part_20445_5908914.1191359107448 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline

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.
------=_Part_20445_5908914.1191359107448--