Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-08-05 (21:38)
From: John Max Skaller <skaller@m...>
Subject: Re: [Caml-list] Please help a newbie wrote:
> Johann Spies <> 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, 
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
New generation programming language Felix
Literate Programming tool Interscript
Bug reports:  FAQ:
To unsubscribe, mail  Archives: