Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* Re: bottom types and threaded exits
@ 2000-09-25 19:56 Damien Doligez
  0 siblings, 0 replies; 13+ messages in thread
From: Damien Doligez @ 2000-09-25 19:56 UTC (permalink / raw)
  To: caml-list

>From: Remi VANICAT <remi.vanicat@labri.u-bordeaux.fr>

>exception Sould_never_be_here
>
>let f () = while true do () done ; raise Sould_never_be_here

That's what "assert false" was invented for: the canonical expression
that "returns" a result of type 'a and should normally never be
evaluated.

let f () = while true do () done; assert false;;

-- Damien



^ permalink raw reply	[flat|nested] 13+ messages in thread
* bottom types and threaded exits
@ 2000-09-23 14:25 Julian Assange
  2000-09-24 19:14 ` Pierre Weis
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Julian Assange @ 2000-09-23 14:25 UTC (permalink / raw)
  To: caml-list; +Cc: proff


Pervasives.exit is of type int -> 'a

Here we see ocaml using 'a to represent _|_. This hack is presumably
so type unification still works in the face of potentially
non-terminating computations, e.g:

let f a =
        try 
          f a
        with
          Failure _ -> exit(1)

How can one force 'a? For instance, Thread.exit and

        let f () = while true do () done 

has a type of unit -> unit.

One can write something such as

        let f () = while true do () done ; Pervasives.exit (1)

But this is clearly a hack.

If the type of Pervasices.exit is traced back, it originates in the
`external affairs powers' of the ocaml type system and is thus not
prone to type inferment. Functions never normally cause an *increase*
in generality. Trying to define a type of int -> 'a naturally leads
to a compiler error of 'a being unbound.

Cheers,
Julian.



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

end of thread, other threads:[~2000-10-05 18:39 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-09-25 19:56 bottom types and threaded exits Damien Doligez
  -- strict thread matches above, loose matches on Subject: below --
2000-09-23 14:25 Julian Assange
2000-09-24 19:14 ` Pierre Weis
2000-09-25 10:08 ` Remi VANICAT
2000-09-25 18:38   ` John Prevost
2000-09-26  9:16 ` Xavier Leroy
2000-09-30  9:12   ` Julian Assange
2000-09-30 14:25     ` Pierre Weis
2000-09-30 15:19       ` Markus Mottl
2000-09-30 14:28     ` Stefan Monnier
2000-10-02 13:11       ` Patrick M Doane
2000-10-02 16:28         ` Markus Mottl
2000-10-05 18:39           ` Pierre Weis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox