From: "Harrison, John R" <johnh@ichips.intel.com>
To: "caml-list" <caml-list@inria.fr>
Subject: RE: [Caml-list] Polymorphism and the "for" loop
Date: Fri, 22 Oct 2004 07:07:21 -0700 [thread overview]
Message-ID: <012676D607FCF54E986746512C22CE7D0FE7C8@orsmsx407> (raw)
| (Incidentally, O'Caml doesn't really need a type "void" since it can
convey
| a similar semantic notion using polymorphism. Consider the function
raise,
| which has type "exn -> 'a" -- in other words, given an exception, it
| produces an arbitrary value of any type. Since such a thing is
impossible
| (using the type-safe core language), we must conclude that raise does
not
| return to its call site when it executes.)
That's true. In any case I assume (given that a recursive type is some
kind of least fixed point) that you can define an empty type in OCaml
like
this:
# type void = Constr of void;;
type void = Constr of void
So the only functions into such a type are those that never terminate
and return a value, e.g.
# let rec f x = (f:int->void) x;;
val f : int -> void = <fun>
or
# let (g:int->void) = fun x -> failwith "void function";;
val g : int -> void = <fun>
or
# let (h:int->void) = fun x -> if x = 0 then f x else g x;;
val h : int -> void = <fun>
Perhaps the name "void" in C is a bit poorly chosen. It's probably meant
to say that an element of the type imparts no information, rather than
imply a semantic model based on an empty type.
John.
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next reply other threads:[~2004-10-22 14:07 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-22 14:07 Harrison, John R [this message]
2004-10-22 14:45 ` John Carr
2004-10-23 20:58 ` Christophe Raffalli
2004-10-22 14:47 ` Andreas Rossberg
-- strict thread matches above, loose matches on Subject: below --
2004-10-22 16:00 Harrison, John R
2004-10-21 18:50 Jon Harrop
2004-10-21 19:11 ` David Brown
2004-10-22 1:19 ` skaller
2004-10-22 2:22 ` Robert M. Solovay
2004-10-22 6:19 ` skaller
2004-10-22 7:38 ` Jon Harrop
2004-10-22 8:06 ` David Brown
2004-10-22 9:39 ` Andreas Rossberg
2004-10-22 8:13 ` William Lovas
2004-10-22 8:17 ` Jon Harrop
2004-10-22 14:02 ` skaller
2004-10-22 14:31 ` David Brown
2004-10-22 17:06 ` Brian Hurt
2004-10-22 4:17 ` William Lovas
2004-10-22 6:42 ` skaller
2004-10-21 19:12 ` Ville-Pertti Keinonen
2004-10-21 19:20 ` Jon Harrop
2004-10-21 19:42 ` Ville-Pertti Keinonen
2004-10-23 11:41 ` Richard Jones
2004-10-23 12:06 ` Matti Jokinen
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=012676D607FCF54E986746512C22CE7D0FE7C8@orsmsx407 \
--to=johnh@ichips.intel.com \
--cc=caml-list@inria.fr \
/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