Version française
Home     About     Download     Resources     Contact us    
Browse thread
Same label in different types, how do people solve this?
[ 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: Functions must be explicitly typed, (was Same label in different types, how do people solve this?)
Mattias Waldau wrote:
> 
> > In Felix, I compromised: functions must be explicitly typed
> > when declared, but values don't:
> >
> >       function f(a:int): int { val b = a; return b; }
> 
> Which I think is an good idea. I normally type the functions in Ocaml, but I
> don't type the local variables. 

	But everything is a compromise. I do this regularly:

let rec f (a:ta) (b:tb) (c:tc) (d:td) (e:te) =
   let ff e = f a b c d e in
   ....
	ff expr

It would be a pain to have to type 'ff' here: it's more like
a 'local variable' than a new function definition.

In Ocaml, terse expression with the _option_ of adding a type
constraint isn't that unreasonable. The real problem is that
the inference engine isn't smart enough to remember _how_ it
deduced a type, and report _both_ locations when there is a
conflict. I have a suspicion this is non-trivial: probably
worth a PhD. :-)

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