From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA11027 for caml-red; Tue, 22 Aug 2000 09:48:41 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id XAA05814 for ; Mon, 21 Aug 2000 23:59:51 +0200 (MET DST) Received: from mail1.microsoft.com (mail1.microsoft.com [131.107.3.125]) by concorde.inria.fr (8.10.0/8.10.0) with SMTP id e7LLxnf21094 for ; Mon, 21 Aug 2000 23:59:49 +0200 (MET DST) Received: from 157.54.9.101 by mail1.microsoft.com (InterScan E-Mail VirusWall NT); Mon, 21 Aug 2000 14:59:36 -0700 (Pacific Daylight Time) Received: by INET-IMC-01 with Internet Mail Service (5.5.2651.58) id ; Mon, 21 Aug 2000 14:59:37 -0700 Message-ID: <2CCC2A4C8D41EC4991B547B3595F1A7251A326@red-pt-01.redmond.corp.microsoft.com> From: Manuel Fahndrich To: "'John Max Skaller'" Cc: "'caml-list@inria.fr'" Subject: RE: Return type of procedures? Date: Mon, 21 Aug 2000 14:59:18 -0700 X-Mailer: Internet Mail Service (5.5.2651.58) Sender: weis@pauillac.inria.fr 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. -Manuel -----Original Message----- From: John Max Skaller [mailto:skaller@maxtal.com.au] Sent: Monday, August 21, 2000 10:17 AM To: caml-list@inria.fr Subject: Return type of procedures? I am designing a programming language (the compiler is written in ocaml) which is a procedural language with 'purely functional' expressions (using eager evaluation). Function closures can access their context, which procedural statements my change between building the closure and evaulating it. Procedural closures may mutate their environment. Procedures and functions are defined with distinct keywords 'procedure' and 'function'. I have given a procedure the functional type 'a -> unit (where 'a may sensibly be 'unit') whereas functions have signature 'a -> 'b where either 'a or 'b may be unit. Note that if 'a is unit, the function is not necessarily constant, since it may depend on the environment. OTOH, a function with 'b as unit is farily useless. However, as it stands, the type system fails to achieve separation of functions and procedures: procedure p: unit -> unit function f: unit -> unit f (p ()) // woops! Here is an expression (functional code) which has taken the result of calling a procedure (unit) as an argument. Proposal: just as unit is the trivial product (tuple, terminal object), so we say 'void' is the trivial sum (initial object), and make procedures have the signature procedure f: unit -> void Now, procedures cannot be used 'in' expressions anywhere, provided we do not allow the argument of a function or procedure to have 'void' type. We can also treat procedures uniformly from a typing view point. Comments? -- 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