From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: ** X-Spam-Status: No, score=2.2 required=5.0 tests=AWL,DNS_FROM_RFC_POST, SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 40DD1BBAF for ; Fri, 11 Sep 2009 09:14:40 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvIBAB+VqUrRVdOyi2dsb2JhbACSBYkAPwEBAQgNCgcRBa9PgSqQLQEDAgSEFAWBVA X-IronPort-AV: E=Sophos;i="4.44,369,1249250400"; d="scan'208";a="46360088" Received: from mail-yw0-f178.google.com ([209.85.211.178]) by mail4-smtp-sop.national.inria.fr with ESMTP; 11 Sep 2009 09:14:39 +0200 Received: by ywh8 with SMTP id 8so1356572ywh.14 for ; Fri, 11 Sep 2009 00:14:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=wbAzeEkeg9frCtHUZ/fwQR4hDuJuLUC6kC0AyeDyotU=; b=hvVrBapkD4g4U8dI7Ky7u+eXasKQz1UMjVZymcKZ4oPBlP3DRrAqG1F3Rq2w48FFhc 5PJ0EfggmdIBuOC82FCh34BdoO+Ew4ahbG9U7RuGGMD71IpJgv9gkvduqJa5OKKybVUg 5boViHKFNwmiYmK3zJnekP8FU1XcQktKi2sA8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=I+SA2dla0ru7SjZXM1HZXKjN9+ReZ6HinU71zg/PhQaaTKQYrS31pDrIFp/EsHifIh 96hi9mK0/aAuqM77uDIP6JklVacLxmOu2GC5DtLO+dQtV6i6ruGT+26uux/uwqO7UNSO TjPfTyUZxUPB2xYiEHLY5tHlK1mlOC+hHR168= MIME-Version: 1.0 Received: by 10.101.57.5 with SMTP id j5mr2815900ank.63.1252653247737; Fri, 11 Sep 2009 00:14:07 -0700 (PDT) In-Reply-To: <4AA95027.5050308@citycable.ch> References: <4AA8F16F.1040009@citycable.ch> <20090910.214827.104047449.garrigue@math.nagoya-u.ac.jp> <4AA8F986.1060206@citycable.ch> <20090910.232102.112610940.garrigue@math.nagoya-u.ac.jp> <4AA95027.5050308@citycable.ch> Date: Fri, 11 Sep 2009 09:14:07 +0200 Message-ID: <527cf6bc0909110014s7da89384hdd86fb87f0e1969d@mail.gmail.com> Subject: Re: [Caml-list] polymorphic method. From: blue storm To: guillaume.yziquel@citycable.ch Cc: Jacques Garrigue , caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1 X-Spam: no; 0.00; guillaume:01 guillaume:01 syntax:01 syntax:01 camlp:01 ocaml:01 camlp:01 compiler:01 typer:01 foo:01 baz:01 translated:01 foo:01 baz:01 storm:98 On Thu, Sep 10, 2009 at 9:14 PM, Guillaume Yziquel wrote: > I'm not really familiar with syntax extensions. Can this 'polymorphic' > keyword be implemented with a syntax extension? No, it can't. If you're talking about camlp4 syntax extensions, they're converted to regular OCaml programs at camlp4-time, wich is *before* the compiler see the program. It thus can't access any type information : you can have syntax extensions that send type information to the typer, but not the other way around : only purely syntaxic transformations are expressible. With a camlp4 extension, you could inspect the (syntaxically explicit) parameters of you method, and (syntaxically) generate a polymorphic type for each one : "polymorphic method foo bar baz = ..." would be translated into "method foo : 'a 'b . 'a -> 'b -> 'c = fun (bar : 'a) (baz : 'b) -> ...". This is probably not what you want. You could further enrich your extension with a "param" keyword that would not generate polymorphic types for some of the parameters "method foo bar (param baz) = ..", or have the "poly" keyword be parameter-specific "method foo (poly bar) baz = ...", but my general advice is not to try to much to do type-level transformation by syntaxic transformations : they tend to get flawed in ways you don't expect, and this is just not the right tool for the job.