On 9/19/07, skaller <[EMAIL PROTECTED]> wrote:
> For functions you can now use named arguments.

Cool!

> Argument names contribute to overload resolution.

Also cool!

> Oh well:
>
>   You can't mix positional and named arguments.
>   I doubt this would make a lot of sense with overloading.

You mean something like:

fun f(a:int, b:int) = {...}
f (1, b=2);

? Yeah, while I think it could be a useful extension, it's not that
important as long as we can still pass in a curried arguments.


>   There are no default arguments. This DOES mix with
>   overloading (see C++). It is more or less mandatory
>   for functions with many arguments, since spelling
>   out all the overloads for N defaults yields 2^N functions.

Someday. I'm doing a bit of work on those os wrappers, and it'd really
simplify the interface :)

> To consider:
>
> It would be interesting to consider automatic coercions:
>
> fun f(a:int, b:int)=> a + 2* b;
> f (a=1,b=2,c=3);
>
> This currently fails: there must be an exact match.
> However, allowing subtyping is trivial to implement, and in fact
> is simpler than the current algorithm which checks the record
> and function have the same number of arguments.


I'm undecided on this. In one respect it can be really handy in python
to pass around an option file and just use the **kwds dictionary to
query it. On the other hand, I feel like it's less safe doing this
downsizing transparently. Your example *is* interesting though, I
could see that being useful.


How would this all interact with typeclasses? Would it work
transparently, or could we extend typeclasses to make it more
typesafe? Perhaps in the record polymorphism typeclass, instead of
throwing away the extra fields as in ad hoc polymorphism, the extra
fields would be hidden unless exposed through the record typeclass?
I'm not sure if that really makes sense, so let me try an example:

typeclass Foo { ... something ... }

instance Foo[(a:int, b:int)] {
  fun foo (a:int, b:int) => a + b;
}
open Foo[(a:int, b:int)];

instance Foo[(a:int, b:int, c:int)] {
  fun foo (a:int, b:int, c:int) => a + b + c;
}
open Foo[(a:int, b:int, c:int)];

////

fun bar[T with Foo[T]] (f:x->int) (x:(a:int, b:int)) => f x;

println $ foo (the bar) (a=1, b=2, c=3);  // prints 3
println $ foo (the baz) (a=1, b=2, c=3); // prints 6

-------------------------------------------------------------------------
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
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to