Still toying around with os interaction ideas, and I was wondering if
we could do more to make the dot notation even more useful. Say we
wanted a ruby-like interface. We'd have a file module a little like
this:

module File
{
  type t = ...;

  fun file (name:string): File::t => ...;

  proc foreach (file:File::t) (f:line->void) => ...;
  proc foreach (name:string) (f:line->void) => ...;
}

Then, we could use the dot notation to do this:

open File;
val f = file ("foo");

f.foreach (fun (line:string) => println line;);

I believe we can do this now. The problem with this though is that we
introduce some stuff into the scope that we might not want to have
there. After opening File, it would be ambiguous what do to if there
was another foreach like this:

proc foreach (s:string) (f:line->void) => ...;

You could no longer do:

"abc\nefg".foreach (fun (line:string) => println line;)

because both functions have the same definition. So, I wonder if
there'd be a way to have the dot notation somehow implicitly include
the defining module in the lookup of a function. Then, the previous
example would look like this (with no implicit open):

val f = File::file ("foo");
f.foreach (fun (line:string) => println line;);

I'm betting that this would be rather difficult to do, but I don't
know how else we could do this without having to either open up an
entire module, or have a bunch of cruft like "val foreach =
File::foreach", which wouldn't even work if the function was generic.

I suppose you could do something like:

val f = File::file ("foo");
f.File::foreach (fun (line:string) => println line;);

but that's a little verbose.

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