From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p9O9AfpJ000546 for ; Mon, 24 Oct 2011 11:10:44 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AogBAP4qpU5KfVI0kGdsb2JhbABDqQYIIgEBAQEJCQ0HFAQhggcCLAEbHgMSCQddAREBBQEiNZwJglgKi0+CYIQ7PYhuAgUKiDYElAmNLz2DcQ X-IronPort-AV: E=Sophos;i="4.69,397,1315173600"; d="scan'208";a="114173769" Received: from mail-ww0-f52.google.com ([74.125.82.52]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 24 Oct 2011 11:10:12 +0200 Received: by wwf25 with SMTP id 25so10022714wwf.9 for ; Mon, 24 Oct 2011 02:10:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=GIgIKaaXa/9iHWn5Q+sc5hDNOjTLzbeVH3lYOYBeEl0=; b=SIJU5III3AfkNW78kKq6tIbq0QKBs3vf72FOjJ7qssg3NYcYXhye2KYi4WPdbN9vaM GWDVEwa45Ta7wNMm+1KAaEB7P2h43fHXplSvwFkoagfUAengFG382rStPZYhSGgnNfdk kOnftlyZ2P+0qTDPX9eWngYzysWNdr5ekPWwg= MIME-Version: 1.0 Received: by 10.216.137.102 with SMTP id x80mr2776732wei.109.1319447411745; Mon, 24 Oct 2011 02:10:11 -0700 (PDT) Received: by 10.216.73.131 with HTTP; Mon, 24 Oct 2011 02:10:11 -0700 (PDT) Date: Mon, 24 Oct 2011 11:10:11 +0200 Message-ID: From: Diego Olivier Fernandez Pons To: caml-list Content-Type: multipart/alternative; boundary=0016e6d7e06046e4e904b007ca70 Subject: [Caml-list] How to write an efficient interpreter --0016e6d7e06046e4e904b007ca70 Content-Type: text/plain; charset=ISO-8859-1 Caml-list, I have to write an interpreter for a datatype rich purely applicative language. I have already written a naive interpreter (like in programming languages class) and was wondering what where the options for writing something that would perform better while keeping it maintainable by a single person < 5% dedicated and preferably only in core-ML (no C code or fancy ML extensions). The language could be described as a rich datastructure typed SQL with a programming language syntax - first class sets, arrays, dictionaries, lists and their corresponding comprehensions - tuples and records merged into a single concept (accessible per position like in (x, y) = ... or per label like in for t in tupleSet if t.label == 3 then) - only applicative functions (no lambda operator, no partial application) - simple types are int, double and string - only user declared types are tuples-records It is mainly used for data transformation : take a list of countries, extract from an database the international airports of those countries, geolocalize them using city/location table, generate a distance table using a great-circle distance, assign to each size of plane the legs they can do based on their maximum fight range, etc. The language has a JavaScript inline capability execute JavaScript { //write your javascript code here } that's typically used to define functions, unroll comprehensions to make them more efficient and to call external libraries (JavaScript has full visibility on all the language objects and can read/write directly inside, probably the existing interpreter was written in JavaScript), so I am considering allowing those features in the core language and only supporting a very slow JavaScript deprecated compatibility mode. Diego Olivier --0016e6d7e06046e4e904b007ca70 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable =A0 =A0 Caml-list,

I have to write an interpreter for a = datatype rich purely applicative language. I have already written a naive i= nterpreter (like in programming languages class) and was wondering what whe= re the options for writing something that would perform better while keepin= g it maintainable by a single person < 5% dedicated and preferably only = in core-ML (no C code or fancy ML extensions).

The language could be described as a rich datastructure= typed SQL with a programming language syntax
- first class sets,= arrays, dictionaries, lists and their corresponding comprehensions
- tuples and records merged into a single concept (accessible per posi= tion like in (x, y) =3D ... or per label like in for t in tupleSet if t.lab= el =3D=3D 3 then)
- only applicative functions (no lambda operato= r, no partial application)
- simple types are int, double and string
- only user declar= ed types are tuples-records

It is mainly used for = data transformation : take a list of countries, extract from an database th= e international airports of those countries, geolocalize them using city/lo= cation table, generate a distance table using a great-circle distance, assi= gn to each size of plane the legs they can do based on their maximum fight = range, etc.

The language has a JavaScript inline capability

=A0 =A0 execute JavaScript {=A0
=A0 =A0 =A0 =A0= //write your javascript code here=A0
=A0 =A0 }

that's typically used to define functions, unroll comprehension= s to make them more efficient and to call external libraries (JavaScript ha= s full visibility on all the language objects and can read/write directly i= nside, probably the existing interpreter was written in JavaScript), so I a= m considering allowing those features in the core language and only support= ing a very slow JavaScript deprecated compatibility mode.


=A0 =A0 =A0 =A0 =A0Diego Olivier
--0016e6d7e06046e4e904b007ca70--