On Sun, 2007-09-23 at 19:59 -0700, Erick Tryzelaar wrote:
> 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,
No .. see below..
> 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;);
You're confused above... what you means i BEFORE opening
the file:
"lpsrc/flx_fred.ipk" . foreach println;
might be ambiguous -- if the conflict was due to two
open modules: there's no conflict with a local definition,
they always take precedence.
One way to resolve this might be:
(name="lpsrc/flx_fred.ipk") . foreach println;
(s="a\nb\nc") . foreach println;
i.e. use records .. which suggests 'filename' might be a
better parameter name than 'name' .. this doesn't work right
now so I'll fix it..
--
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