On Thu, 2007-09-20 at 00:35 +1000, skaller wrote:
> On Wed, 2007-09-19 at 16:45 +1000, skaller wrote:
> Now .. whilst coding this I am thinking on this one:
>
> fun f(a:int, b:int) ..
> fun f(x:int, y:int)
>
> f(x=1, y=2) //calls the second b
OK, I'm looking at this. Some things to note:
When a function is curried, the parameter names of the
second and subsequent arguments are lost.
For the first argument, it could be a record type.
In that case, there is a confusion:
fun f(x:struct {a:int})
f (a=1)
f (x=(a=1))
Which is allowed? The first case works now, so it has
to be allowed: this is shorthand for
f (struct {a=1;})
But the second case is just a special case where the argument
list is length 1, so the usual tuple degrades to a single argument.
This has the effect that for Felix functions (but NOT primitives!!)
we can write:
f (x:int, y:int)
or
f (xy: int * int)
and they have the same (domain) type, namely int * int, and
are called the same way (with positional arguments):
f (1,2)
let ?xy = 1,2 in f xy
so it would be rather inconsistent to ban
f (x=(a=1))
just because the function happens to have only 1 argument
which happens to be a record. Note records, unlike tuples,
can have 1 component. [Also note, a record of 0 components
should be equal to the unit tuple .. not sure if it is]
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language