Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Brian Hurt <bhurt@spnz.org>
To: skaller <skaller@users.sourceforge.net>
Cc: "Robert M. Solovay" <solovay@Math.Berkeley.EDU>,
	David Brown <caml-list@davidb.org>,
	Jon Harrop <jon@jdh30.plus.com>, caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Polymorphism and the "for" loop
Date: Fri, 22 Oct 2004 12:06:16 -0500 (CDT)	[thread overview]
Message-ID: <Pine.LNX.4.44.0410221202480.15838-100000@localhost.localdomain> (raw)
In-Reply-To: <1098425963.7584.9.camel@pelican.wigram>

On 22 Oct 2004, skaller wrote:

> On Fri, 2004-10-22 at 12:22, Robert M. Solovay wrote:
> > How does one define a function f of type int -> void? I looked in the
> > OCaml manual and couldn't find any reference to "void". {It is, of course,
> > a familiar concept in C.}
> 
> That's right. Ocaml has no void type. I consider that a bug.

unit is Ocaml's void.  There are some subtle differences, but generally 
anything you use void for in C, you use unit for in Ocaml.

As a side note, the correct return type for functions that don't return is 
'a.  This allows code like:

let do_something = function
	| h :: _ -> h
	| [] -> invalid_arg "do_something failed!"
;;

Note that the invalid_arg function has a type string -> 'a.  

-- 
"Usenet is like a herd of performing elephants with diarrhea -- massive,
difficult to redirect, awe-inspiring, entertaining, and a source of
mind-boggling amounts of excrement when you least expect it."
                                - Gene Spafford 
Brian

-------------------
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


  parent reply	other threads:[~2004-10-22 16:57 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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
2004-10-22 14:07 Harrison, John R
2004-10-22 14:45 ` John Carr
2004-10-23 20:58   ` Christophe Raffalli
2004-10-22 14:47 ` Andreas Rossberg
2004-10-22 16:00 Harrison, John R

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=Pine.LNX.4.44.0410221202480.15838-100000@localhost.localdomain \
    --to=bhurt@spnz.org \
    --cc=caml-list@davidb.org \
    --cc=caml-list@inria.fr \
    --cc=jon@jdh30.plus.com \
    --cc=skaller@users.sourceforge.net \
    --cc=solovay@Math.Berkeley.EDU \
    /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