Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Evaluation Order
[ 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@o...>
Subject: Re: [Caml-list] Evaluation Order
Dave Mason wrote:

> I think the answer is that the ``effect''ness isn't simply captured in
> the type.  So the current type-inference engine would not be able to
> do it.  It would require a bit of ad-hocery in the compiler.  That
> doesn't mean that it's unsound, just that the existing compiler
> mechanisms couldn't do it.

	I think you probably _have_ to capture it in the type.
Consider a new type

	'a => 'b

where '=>' means 'function with side effects'. Now consider
the following two term constructors:

	Apply(fn1,arg1)
	Init(name,fn2,arg2)

The type-checking rules are then clear:

	fn1: 'a->'b, arg1:'a, Apply(fn1,arg1):'b
	fn2: 'a=>'b, arg2:'a, name: 'b

and

	'a->'b is a subtype of 'a=>'b'

In Felix it would be easy to verify correct usage,
but I'm not sure it is possible to verify correct
specification. In Ocaml, it may be harder, since
one can use a function before declaration in a 'let rec',
and it may be too late when spotting the type annotation
to report a wrong usage.

[OTOH, if the Ocaml compiler scanned 'let recs' for type
annotations before examining bodies, it might improve
error reporting in other circumstances??]



-- 
John (Max) Skaller, mailto:skaller@maxtal.com.au
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
checkout Vyper http://Vyper.sourceforge.net
download 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