Consider some functions:

fun f(x:string, y:string) => ...
fun f(x:string, y:int) => ..

Now, you can make a closure of each of these f's:

var fs = f of (string * string);
vart fi = f of (string * int);

But really I want to write:

        s.f "hello"
        s.f 42

so we need:

fun f(x:string) (y:string) => ...
fun f(x:string), (y:int) => ..

to make that work. All fine. But now we can't make a closure of f:

var cf = f of (string);

because it's ambiguous. Although this is a syntactic problem:
you can overload f on multiple arguments but you can't use
the "of" notation the same way (that's a bug!).

However, consider, a function is a C++ object with an apply method:

class fs { string object;  int apply(string x) { .. } };
class fi { string object; .. int apply(int i) } { .. } };

The closure is an instance of one of these.

So why not:

class f { 
  string object;
  int apply(string x) { .. }
  int apply(int x) { .. }
  ..
}

Why can't the closure of "f" be represented by an object with TWO methods?

Some hackery in the compiler would be needed to generate these things.
However the critical thing is that typesets would have to be in the type system.
In particular consider the type of the thing above:

        string -> typesetof (string, int) -> int


--
john skaller
skal...@users.sourceforge.net
http://felix-lang.org




------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to