Version française
Home     About     Download     Resources     Contact us    
Browse thread
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: John Max Skaller <skaller@m...>
Subject: Re: [Caml-list] Please help a newbie
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