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 RAA16629; Mon, 3 May 2004 17:08:22 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA16612 for ; Mon, 3 May 2004 17:08:21 +0200 (MET DST) Received: from smtp1.adl2.internode.on.net (smtp1.adl2.internode.on.net [203.16.214.181]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i43F8FEV014346 for ; Mon, 3 May 2004 17:08:19 +0200 Received: from [192.168.1.200] (ppp116-155.lns1.syd2.internode.on.net [150.101.116.155]) by smtp1.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id i43F8BZq009264; Tue, 4 May 2004 00:38:14 +0930 (CST) Subject: Re: [Caml-list] [ANN] The Missing Library From: skaller Reply-To: skaller@users.sourceforge.net To: "Marcin 'Qrczak' Kowalczyk" Cc: caml-list In-Reply-To: <1083588018.1643.156.camel@qrnik> References: <200404280613.19547.jdh30@cam.ac.uk> <1083141467.9537.845.camel@pelican.wigram> <200404281018.14913.jdh30@cam.ac.uk> <1083151482.9537.904.camel@pelican.wigram> <93ADD9EA-9936-11D8-BD03-000A958FF2FE@wetware.com> <1083173516.9537.1162.camel@pelican.wigram> <1083542538.9152.65.camel@qrnik> <1083570883.20722.536.camel@pelican.wigram> <1083574691.1643.55.camel@qrnik> <1083581924.20722.584.camel@pelican.wigram> <1083588018.1643.156.camel@qrnik> Content-Type: text/plain Message-Id: <1083596890.20722.766.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 04 May 2004 01:08:11 +1000 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 40966060.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 sourceforge:01 2004:99 marcin:01 'qrczak':01 kowalczyk:01 struct:01 val:01 val:01 endl:01 endl:01 pelican:01 flx:01 inference:01 bignums:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Mon, 2004-05-03 at 22:40, Marcin 'Qrczak' Kowalczyk wrote: > > In Felix this can't be a problem for functions, only for > > variables. Unlike Ocaml, > > > > fun f ... > > > > declares a class, whilst > > > > let f x = .. > > > > in Ocaml constructs a value. > > I don't understand. In Felix, fun f(x:int) = { return x; } declares a class: struct f { int apply(int x) { return x; } }; So *direct* calls are like: f().apply(1) where the closure is created on the fly. The Ocaml: let f x = x defines f as a variable already containing the closure .. so you can't call f until that variable is actually initialised. > The problem in my language is that here: > let f x {y + 1}; > let z = f 10; > let y = z + 1; > there is no single place which should be detected as an error. Same in Felix: include "std"; fun f (x:int):int= { return y + 1; } val z = f 10; val y = z + 1; print z; endl; print y; endl; [skaller@pelican] ~>flx xxx 1 2 Well, no run time error: y just happens to be zero initially :) > 2. Ordinary code uses dynamic dispatch a lot, e.g. for all arithmetic, > and currently the only way to avoid that is to use inline C code > (similar to inline asm in C). Even some type inference would not > help much because of bignums (did I say that I hate arbitrary > limitations? I can't just not have bignums!). Felix uses gmp. However it has all the C int types as well. Oh .. none of them are built in, not even bool. You *have* to 'inline C' the lot. Did I say I hate arbitrary limitations like needing to have builtin types? > Even if I implement > inlining, not much could be inlined from a dispatched function. > Performing the dispatch statically when possible would be very > hard... You'd be surprised. When I wrote Vyper, I did a lot of analysis to try to make things static. For Python, that proved almost impossible. With a little care you can probably do very much better with just a little type inference. -- 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