From mboxrd@z Thu Jan 1 00:00:00 1970 X-Sympa-To: caml-list@inria.fr 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 pBALeuNN028046 for ; Sat, 10 Dec 2011 22:40:57 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtwAAE7R405KfVI0imdsb2JhbABDhDdQpW8IIgEBAQoJDQcSBiGBcgEBAQECAQwGAg8dAQE3AQQLCQILDwImAgIQBCABBQEiExQOh2YCBpgXCoozaYMzAY1OB4E0iSOBFpR1jXE9g3k X-IronPort-AV: E=Sophos;i="4.71,332,1320620400"; d="scan'208";a="122868633" Received: from mail-ww0-f52.google.com ([74.125.82.52]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-MD5; 10 Dec 2011 22:40:57 +0100 Received: by wgbdr12 with SMTP id dr12so9986997wgb.9 for ; Sat, 10 Dec 2011 13:40:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type:content-transfer-encoding; bh=p0qFvFFbRQdaZgqi+WyALfbHc1iSHGJLauEUqdCJZ8E=; b=xLFThzPkqofYJ0GnI5bdEkskkZqVLFjiLGSjpBP1dwg2Ewoa6V6dWNcKmB6JqXd0qM y8KJBvFY45Ne5oUTt6g5GzFpzz3afDYRrT9dai1f5UwiPK8WHYi2umnqtdfH4093UXn8 kmW3tbdo6PEy5Jl01JiN22RkBwqCfmRcZtJtM= Received: by 10.216.35.5 with SMTP id t5mr1018568wea.65.1323553256189; Sat, 10 Dec 2011 13:40:56 -0800 (PST) Received: from spec-desktop.danmey.org (cpc1-cmbg12-0-0-cust201.5-4.cable.virginmedia.com. [86.9.116.202]) by mx.google.com with ESMTPS id p2sm4692867wbh.22.2011.12.10.13.40.54 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 10 Dec 2011 13:40:55 -0800 (PST) From: Wojciech Meyer To: =?utf-8?B?SsOpcsOpbWll?= Dimino Cc: Wojciech Meyer , caml-list@inria.fr References: <55531934-37A5-4CC5-AB67-20CE4CCE8269@googlemail.com> <4EE37070.4010702@inria.fr> <1323541702.32136.8.camel@aurora> <1323550544.32136.19.camel@aurora> Date: Sat, 10 Dec 2011 21:40:43 +0000 In-Reply-To: <1323550544.32136.19.camel@aurora> (=?utf-8?B?IkrDqXLDqW1p?= =?utf-8?B?ZQ==?= Dimino"'s message of "Sat, 10 Dec 2011 21:55:44 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.91 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id pBALeuNN028046 X-Validation-by: wojciech.meyer@googlemail.com Subject: Re: [Caml-list] Camlp4/p5 type reflection [was: OCaml maintenance status / community fork (again)] Jérémie Dimino writes: > Le samedi 10 décembre 2011 à 19:10 +0000, Wojciech Meyer a écrit : >> I'm aware that these are huge changes to Camlp4, but it would make >> meta programming more powerful and push Camlp4 to the next level. > > Sure. But it seems that the next version of OCaml will have runtime > types, see http://www.lexifi.com/blog/runtime-types , so maybe it is not > needed to add this to camlp4. It's interesting and I didn't know about it. However, the problem is slightly different, I would like to know the typing of a freshly generated piece of code by Camlp4 in the previous phase. Then, have pattern matching against these meta types in annotated AST and produce another AST, which in turn have most likely another typing and pass to the next phase etc. I would say that Camlp4 is fine for the simpler syntax extensions and majority of small DSLs but when you start composing syntax extensions and macros it quickly becomes a problem. > > Also they are problems that i don't know how to solve with the camlp4 > approach. For example consider: > > let x = 1 > type int = A > let y = A > > The typer knows that x has the type (int, 1) and y has the type (int, > 42). But what you send to ocaml is a parse tree, and you cannot make > this difference in the parse tree. Yes, you would need a type information in the parse tree as mentioned before, so you want to feed up the compiler with AST start unrolling macros top-down and then follow up with the inferred types bottom-up. Cheers; Wojciech