caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: John Max Skaller <skaller@maxtal.com.au>
To: md5i@cs.cmu.edu
Cc: Caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Please help a newbie
Date: Mon, 06 Aug 2001 07:37:30 +1000	[thread overview]
Message-ID: <3B6DBC9A.1E6B82A2@maxtal.com.au> (raw)
In-Reply-To: <v1t66c59f4b.fsf@miyazima.lti.cs.cmu.edu>

md5i@cs.cmu.edu wrote:
> 
> Johann Spies <jspies@maties.sun.ac.za> writes:

>(BTW, in OCaml, the type unit is
> sort of equivilent to C's void.)

	As an aside: in Felix, there are two types,
unit (which has a single value, the empty tuple),
and void, which has no values. The two are
distinct (indeed, dual): unit is the categorical terminal, void
is the categorical initial.

	In Ocaml, the categorical initial also exists,
thanks to polymorphic variants:

	type void = [] 

It is my contention that the type of procedures is wrong
in ocaml precisely because they return unit, when they
_should_ be returning void (that is, nothing).

An example of the kind of thing this typing
permits is:

	let f () = print_endline "Hi" in
	f ( f() )

This works, because the type of f is 

	unit -> unit

instead of what it should be:

	unit -> void

I note that the sequencing operator ; in such a system
can't work correctly with the type

	(;): unit -> unit -> unit

used in Ocaml. It can't be translated to

	(;): void -> void -> void

but has to be translated to

	(;): (unit->void) -> (unit->void) -> (unit->void)

which means the result is never actually executed.
You need 

	(;;): unit->void->void

for that, and call it a stamement: statements can 
be concatenated, there cannot be a 'functional'
way to execute statements in sequence, which provides
a division between expressions and statements.

I'm experimenting with a coherent syntax for this
in Felix (which distinguishes expressions from statements,
and functions from procedures).

-- 
John (Max) Skaller, mailto:skaller@maxtal.com.au 
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
New generation programming language Felix  http://felix.sourceforge.net
Literate Programming tool Interscript     
http://Interscript.sourceforge.net
-------------------
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


  reply	other threads:[~2001-08-05 21:38 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-03 10:58 Johann Spies
2001-08-03 13:26 ` [Caml-list] Re: your mail Francois Pottier
2001-08-03 17:42 ` Vitaly Lugovsky
2001-08-03 18:23 ` [Caml-list] Please help a newbie md5i
2001-08-05 21:37   ` John Max Skaller [this message]
2001-08-06 10:02     ` empty type (was [Caml-list] Please help a newbie) Hendrik Tews
2001-08-07 17:32       ` John Max Skaller
  -- strict thread matches above, loose matches on Subject: below --
2001-08-02 13:42 [Caml-list] Please help a newbie Johann Spies
2001-08-02 12:54 ` Frank Atanassow
2001-08-02 13:01 ` Francois Thomasset
2001-08-02 13:25   ` Francois Thomasset
2001-08-02 13:05 ` Sven
2001-08-02 13:37 Dave Berry
2001-08-02 16:08 ` Brian Rogoff

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=3B6DBC9A.1E6B82A2@maxtal.com.au \
    --to=skaller@maxtal.com.au \
    --cc=caml-list@inria.fr \
    --cc=md5i@cs.cmu.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;
as well as URLs for NNTP newsgroup(s).