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 UAA28071; Fri, 16 Apr 2004 20:10:41 +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 UAA27374 for ; Fri, 16 Apr 2004 20:10:39 +0200 (MET DST) Received: from smtp3.adl2.internode.on.net (smtp3.adl2.internode.on.net [203.16.214.203]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i3GIBejq032513 for ; Fri, 16 Apr 2004 20:11:41 +0200 Received: from [192.168.1.200] (ppp117-65.lns1.syd2.internode.on.net [150.101.117.65]) by smtp3.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id i3GIAQk2076989; Sat, 17 Apr 2004 03:40:28 +0930 (CST) Subject: Re: [Caml-list] build tools - good vs. fast, both cheap From: skaller Reply-To: skaller@users.sourceforge.net To: Kenneth Knowles Cc: "Brandon J. Van Every" , caml-list In-Reply-To: <20040416160618.GA27238@tallman.kefka.frap.net> References: <20040416011616.GA13198@tallman.kefka.frap.net> <20040416160618.GA27238@tallman.kefka.frap.net> Content-Type: text/plain Message-Id: <1082139022.20063.136.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 17 Apr 2004 04:10:25 +1000 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce 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 knowles:99 monolithic:01 command-line:01 autoconf:01 interscript:01 suffices:01 interscript:01 1..10:01 endline:01 python:01 python:01 endline:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sat, 2004-04-17 at 02:06, Kenneth Knowles wrote: > These are the approaches I can see out there: > > (1) Monolithic automagical GNU Makefile > (2) O'Caml script outputing make-agnostic Makefile > (3) Command-line build-every-at-once ocaml tool > (4) Roll your own Makefile, have the user edit it - often separated into a > Makefile.config. > (5) Use autoconf (why, oh why? it doesn't offer any O'Caml support) > (6) Interscript? I don't really understand what it does and what the developer > must do. I'm against make. It just isn't necessary. Make is for C developers, not Ocaml package installation. To build a package it suffices to run a sequence of commands in a fixed order. To understand interscript .. what does it do? The answer is the same as tar -zxvf, except that 'extracting' a file can execute arbitrary code. Its that simple. Here's an example: @head(1,"My program") Its only a demo. @select(tangler("sample.ml") let f x = x + x @for i in [1..10]: tangle("print_endline (f "+i+");") @doc() This demo prints 2,4, .. 20. The Python script means: @head -- document heading level 1. The @select(tangler("sample.ml")) .. means "write the following stuff to sample.ml" The @ starts an arbitrary Python command. The select, tangler, and head functions are just interscript library functions, nothing special. The tangle() functions write a string to output. The for loop prints out print_endline(f 1); print_endline(f 2); ... etc up to 10. It is just a standard Python construction, nothing special. If you want to compile the above program instantly, here is how to do it: @os.system("ocamlc -c sample.ml") Duh. It just calls Python's system function, which is C's system function. It is more usual to do this though: @select(tangler("Makefile")) all: @tangle("\tocamlc -c sample.ml") @doc() and then after you run interscript you have a makefile, and you can compile using the ordinary 'make' command. The point of all this is: you can do anything you want. Its just Python script, with a little control loop that copies lines to the weaver for typesetting, the tangler to write a source file, or executes them (if they start with @). Oh yes, there is much more than that, but this is the basic idea... EXECISE: What does this do: @os.system("ocaml sample.ml > sample.out") @f = open("sample.out") @for i in [1..10]: tangle(f.readline()) @doc() If you want to see a more advanced use of the executable facilities, examine section 6.4 of the interscript implementation listing at http://interscript.sf.net. What you will see there is the full Unicode data, and code tables for something like 30 other standard character sets -- there are hundreds of pages of character tables, and the whole of it is generated by about a page of code which downloads and reads the unicode.org data files. Here is a real example from Felix compiler. Have you ever got annoyed at copying things in both mli and ml files?? @head(1,'Compile time exceptions') @python('//') exceptions = """ open Flx_ast open Flx_types exception SyntaxError of string exception ParseError of string exception LexError of string exception TokenError of string exception ClientError of range_srcref * string exception ClientError2 of range_srcref * range_srcref * string exception SystemError of range_srcref * string exception Exit of int exception Bad_recursion exception Expr_recursion of expr_t exception Free_fixpoint of btypecode_t exception Unresolved_return of range_srcref * string """ // @h = tangler('src/flx_exceptions.ml') @select(h) @tangle(exceptions) let clierr2 sr sr2 s = raise (ClientError2 (sr,sr2,s)) let clierr sr s = raise (ClientError (sr,s)) let syserr sr s = raise (SystemError (sr,s)) let catch s f = try f() with _ -> failwith s @h = tangler('src/flx_exceptions.mli') @select(h) @tangle(exceptions) val clierr: range_srcref -> string -> 'a val clierr2: range_srcref -> range_srcref -> string -> 'a val syserr: range_srcref -> string -> 'a val catch: string -> (unit -> 'a) -> 'a -- 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