From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id BAA03408; Fri, 23 Jul 2004 01:01:03 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 BAA03770; Fri, 23 Jul 2004 01:01:01 +0200 (MET DST) Received: from smtp3.adl2.internode.on.net (smtp3.adl2.internode.on.net [203.16.214.203]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i6MN0wSH029938; Fri, 23 Jul 2004 01:00:59 +0200 Received: from [192.168.1.200] (ppp205-61.lns1.syd3.internode.on.net [203.122.205.61]) by smtp3.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id i6MN0nHY041505; Fri, 23 Jul 2004 08:30:50 +0930 (CST) Subject: Re: lazyness in ocaml (was : [Caml-list] kprintf with user formatters) From: skaller Reply-To: skaller@users.sourceforge.net To: Pierre Weis Cc: Daniel =?ISO-8859-1?Q?B=FCnzli?= , caml-list In-Reply-To: <20040722182851.B18239@pauillac.inria.fr> References: <200407211552.RAA04351@pauillac.inria.fr> <6DA682B9-DB3D-11D8-9D25-000393DBC266@epfl.ch> <20040722182851.B18239@pauillac.inria.fr> Content-Type: text/plain Message-Id: <1090537249.5870.168.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 23 Jul 2004 09:00:49 +1000 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 4100472A.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; lazyness:01 caml-list:01 kprintf:01 formatters:01 sourceforge:01 2004:99 pierre:01 weis:01 type-based:01 annotated:01 higher-order:01 expr:01 expr:01 lazily:01 9660:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Fri, 2004-07-23 at 02:28, Pierre Weis wrote: > In my mind, this idea would be a type-based transformation of the > source code. The typing rule for lazy function application would be: > > |~ -: (f : 'a lazy -> 'b) (e : 'a) > ---------------------------------- (lazy app) > |~ -: (f e : 'b) > > and the transformation rule on the type annotated abstract syntax > trees would be: > > (f : 'a lazy -> b) (e : 'a) => (f : 'a lazy -> b) (lazy e : 'a lazy) > > Interestingly enough, the typing rule implies that you not only can > omit the lazy keyword at application time: it would be mandatory to > omit it! Weel, not so bad, after all ... > > This has to be precisely ruled out and the necessary proofs have to be > made, but I think it could work (including for higher-order > functional, map, fold, and so on). I mean, I don't see any trivial > counter-example that would ruin this scheme. Wao! If this rule > turned out to be usable, it would be a major improvement for lazy > evaluation in our favorite language. But this looks very dangerous! Its kind of like reference parameters in C++, which make it impossible to tell if f(expr) can modifiy expr or not [without finding which 'f' it is and examining it] In the lazy case it would destroy an important identity: f x <==> let x' = x in f x' With your rule, the LHS might not evaluate x, whereas the RHS would. Of course we already have that: f x y <=/=> let x' = x in y' = y in f x' y' since the RHS guarrantees x is evaluated before y, whilst it happens by chance in the current Ocaml implementation the reverse is true for the LHS. So even if your rule is sound, it might not be a good idea because it breaks 'the substitution principle'. How about sugar: \(expr) <==> lazy expr Since arguments to be lazily evaluated are never variables, they're often going to be surrounded in brackets already, and so this is only a single character .. a lazy way to spell lazy .. and a very easy implementation :) -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners