caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Xavier Leroy <xleroy@pauillac.inria.fr>
To: Pixel <pixel@mandrakesoft.com>
Cc: caml-list@pauillac.inria.fr
Subject: Re: [Caml-list] raise extra arg ignored
Date: Mon, 29 Oct 2001 11:26:32 +0100	[thread overview]
Message-ID: <20011029112632.A22962@pauillac.inria.fr> (raw)
In-Reply-To: <lyg084zwt2.fsf@leia.mandrakesoft.com>; from pixel@mandrakesoft.com on Sat, Oct 27, 2001 at 09:51:05PM +0200

> failwith "foo" "bar"
> failwith "foo"
> 
> are equivalent. 
> 
> exception Foo;;
> raise Foo 1
> raise Foo
> 
> same for this.

Yes.  For additional fun, you could do
        print_string (raise Foo);;
        print_int (raise Foo);;
        raise Foo + 2;;

Notice that this also works for certain non-terminating functions:
        let rec f() = f();;
        f () "bar";;
        print_string (f());;
        print_int (f());;
        f() + 2;;

> I understand why it typechecks, but couldn't there be a special
> check for this since it can't be useful (or can it??)

Possibly, but that would not be easy to do: we'd have to wait until
type inference for the phrase is completed, remember the principal
types inferred for each sub-expression, and apply ad-hoc checks such as
"warn if an expression of principal type 'a ('a being generalizable in
the context) is applied as if it were a function".  This really
doesn't fit well in the current OCaml type inference technology.

- Xavier Leroy
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


  parent reply	other threads:[~2001-10-29 10:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-27 19:51 Pixel
2001-10-27 20:30 ` Daniel de Rauglaudre
2001-10-27 23:44   ` Pixel
2001-10-28 19:47   ` Nicolas George
2001-10-29 10:26 ` Xavier Leroy [this message]
2001-10-30 21:29   ` Pierre Weis
2001-10-30 22:17     ` Dave Mason
2001-10-31 17:57       ` Daniel de Rauglaudre
2001-10-31 19:09         ` Remi VANICAT
2001-11-01 10:01           ` Daniel de Rauglaudre
2001-11-26 15:12   ` Fergus Henderson

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=20011029112632.A22962@pauillac.inria.fr \
    --to=xleroy@pauillac.inria.fr \
    --cc=caml-list@pauillac.inria.fr \
    --cc=pixel@mandrakesoft.com \
    /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).