Browse thread
RE: Return type of procedures?
- Manuel Fahndrich
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Manuel Fahndrich <maf@m...> |
| Subject: | RE: Return type of procedures? |
John Max Skaller wrote:
> My language supports polymorhpism, but only at the module level:
> if you want parametric polymorphism, you must put the function
> in a module, currently the slightly hacked:
>
> module ident[<T>] { id: T-> T; }
>
>This means that when the function is used, the module must
>be instantiated:
>
> x = ident[<void>].id (y);
>
>and the error is detected at instantiation time.
Again, in this example, it is easy to detect, but in general it might not
be. I'm assuming I can write something like the following in your language:
module Foo[<T>] { bar: (unit -> T) -> void; } =
struct
func localid(x : T) { return(x); }
proc bar(f : unit -> T) {
let x:T = local_id(f())
in
return();
}
end
Now suppose you have a procedure p : unit -> void and I do
Foo[<void>].bar(p);
The fact that you are instantiating 'localid' with void is no longer
obvious. In the worst case you have to fully instantiate the entire module,
including every single local definition, nested module instantiations etc...
essentially C++ template application, in order to detect the violation.
To me it looks like you want to have two distinct arrow constructors, one
for functions -f> and one for procedures -p>. Then you can't go wrong.
-Manuel