From: John Max Skaller <skaller@maxtal.com.au>
To: Manuel Fahndrich <maf@microsoft.com>, caml-list@inria.fr
Subject: Re: Return type of procedures?
Date: Tue, 22 Aug 2000 11:17:08 +1000 [thread overview]
Message-ID: <39A1D494.EA23B59A@maxtal.com.au> (raw)
In-Reply-To: <2CCC2A4C8D41EC4991B547B3595F1A7251A326@red-pt-01.redmond.corp.microsoft.com>
Manuel Fahndrich wrote:
>
> We are having a related problem with unit and void in a language we design
> at MSR called Vault. The problem we ran into was with polymorphism. If you
> have a polymorphic function in your language (such as the identity id : 'a
> -> 'a), you could still end up in the situation you are trying to avoid,
> namely by saying:
>
> id (p ()),
>
> where p : unit -> void
>
> In this example, one could check the instance type, but in general, one can
> hide these instances inside other polymorphic functions and procedures and
> that approach is impractical.
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.
The instantiation is not done yet, because it is currently
a 'hack' in that it takes a listr of C++ style types as
arguments, instead of a module: this is because I haven't
defined any concept of 'interface=signature' yet.
Partly, that is because I'm unhappy with the fact that
functions are called with 'positional' arguments,
whereas modules would be called with 'named' arguments:
functor ident[<type T;>] { id: T-> T; }
x = ident[<T=void>].id(y);
Here, the contents of the [<>] brackets are a 'module expression',
which could be an anonymous module (as shown) or a named one
(not shown), and I have yet to figure out the syntax to use
so these are handled regularly. I note that functor application
should be transparent, given:
module Int { type t = int; }
we should be able to write
(ident Int) . id y
as for any 'other' function application (where . binds
tighter than application).
--
John (Max) Skaller, mailto:skaller@maxtal.com.au
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
checkout Vyper http://Vyper.sourceforge.net
download Interscript http://Interscript.sourceforge.net
next prev parent reply other threads:[~2000-08-22 8:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-08-21 21:59 Manuel Fahndrich
2000-08-22 1:17 ` John Max Skaller [this message]
-- strict thread matches above, loose matches on Subject: below --
2000-08-22 1:38 Manuel Fahndrich
2000-08-21 21:58 David McClain
2000-08-23 6:05 ` John Max Skaller
2000-08-24 8:49 ` Pierre Weis
2000-08-21 17:17 John Max Skaller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=39A1D494.EA23B59A@maxtal.com.au \
--to=skaller@maxtal.com.au \
--cc=caml-list@inria.fr \
--cc=maf@microsoft.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox