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=1.1 required=5.0 tests=AWL,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 ED784BC6B for ; Sun, 4 Nov 2007 01:00:18 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAF6oLEfRVYC9kmdsb2JhbACOcQIBAQcCBhMW X-IronPort-AV: E=Sophos;i="4.21,368,1188770400"; d="scan'208";a="18910403" Received: from fk-out-0910.google.com ([209.85.128.189]) by mail4-smtp-sop.national.inria.fr with ESMTP; 04 Nov 2007 01:00:18 +0100 Received: by fk-out-0910.google.com with SMTP id b27so1354905fka for ; Sat, 03 Nov 2007 17:00:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:received:date:to:subject:message-id:references:mime-version:content-type:content-disposition:content-transfer-encoding:in-reply-to:user-agent:from; bh=FF5wCbnapJl7O1aRzQOBsD4ddHXTQDd0UnTumYqfT1Q=; b=Af6pyiYzrQ/7swFosfntc+2Nl/l5Bder0EZvlvNDXt4XOwO/QlSvPZjHTx32zijkNaT0O7f33U1xyUowLTUGJuIw/FB1mcomlng5gpj2Qgt8MoHecqYUq9yhhxDJS8nB5Rp06JRRSaOuciPW0l9yEIEtgq7542yDBc8wTVJEzLI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:date:to:subject:message-id:references:mime-version:content-type:content-disposition:content-transfer-encoding:in-reply-to:user-agent:from; b=Q1zTNVlg989CejxhS2IIYHUsu2A3mCwBUuyFuAKxcU3a0Wat0OrzOICIQ1afLf/29yxOiF4rhenCcGgt7KtYBS5R67YbvBckxRSFcuk2kWReHFiwD6mwbRd654Y1HwD8SnCLg5qGJWWAw0b3oB7hp6RkDd/VQRa9nAGak1m+Osk= Received: by 10.82.138.6 with SMTP id l6mr6618382bud.1194134417326; Sat, 03 Nov 2007 17:00:17 -0700 (PDT) Received: from localhost ( [83.201.31.218]) by mx.google.com with ESMTPS id c14sm4775201nfi.2007.11.03.17.00.13 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 03 Nov 2007 17:00:16 -0700 (PDT) Received: by localhost (sSMTP sendmail emulation); Sun, 04 Nov 2007 01:01:17 +0100 Date: Sun, 4 Nov 2007 01:01:17 +0100 To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Strategy to avoid name collision in signatures Message-ID: <20071104000116.GA2256@localhost> References: <86tzo3nf8f.fsf@Llea.celt.neu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <86tzo3nf8f.fsf@Llea.celt.neu> User-Agent: Mutt/1.5.16 (2007-06-11) From: Julien Moutinho X-Spam: no; 0.00; 0100,:01 functors:01 functor:01 orderedtype:01 struct:01 pervasives:01 functor:01 orderedtype:01 sig:01 val:01 bool:01 struct:01 sig:01 val:01 pervasives:01 On Sat, Nov 03, 2007 at 11:20:16PM +0100, Micha=C3=ABl Le Barbier wrote: > In some piece of code, I use functors combined with include as a kind > of macro facility. In this scheme, it can happen that an identifier is > exported multiple times from various include directives, this ``name > collision'' is an error, and I am looking for ways to avoid it > whithout much annoyance. (OK, this is very vague, details and example > are coming.) [...] I'm not sure if it could be of some help, but here is another scheme wherein the functor Type.Make does not include its argument PROTO, so that there is no namespace conflict with type t. However the PROTO structure can no longer be used anonymously: include OrderedType.Make(struct type t let compare : t -> t -> int =3D = Pervasives.compare end) Gives the error message: This functor has type functor (PROTO : OrderedType.PROTO) -> sig val ge : PROTO.t -> PROTO.t -> bool end The parameter cannot be eliminated in the result type. Please bind the argument to a module identifier The module identifier Type_PROTO should be ok. module OrderedType =3D struct module type PROTO =3D sig type t val compare : t -> t -> int end module Make (PROTO: PROTO) =3D struct let ge t t' =3D PROTO.compare t t' >=3D 0 end end module FunnyType =3D struct module type PROTO =3D sig type t val compare : t -> t -> int end module Make (PROTO: PROTO) =3D struct let funny_ge t t' =3D PROTO.compare t t' >=3D 0 end end module OrderedType_PROTO =3D struct type t let compare : t -> t -> int =3D Pervasives.compare end module FunnyType_PROTO =3D struct type t let compare : t -> t -> int =3D Pervasives.compare end include OrderedType.Make(OrderedType_PROTO) include FunnyType.Make(FunnyType_PROTO) Which gives: module OrderedType : sig module type PROTO =3D sig type t val compare : t -> t -> int end module Make : functor (PROTO: PROTO) -> sig val ge : PROTO.t -> PROTO.t -> bool end end module FunnyType : sig module type PROTO =3D sig type t val compare : t -> t -> int end module Make : functor (PROTO: PROTO) -> sig val funny_ge : PROTO.t -> PROTO.t -> bool end end module OrderedType_PROTO : sig type t val compare : t -> t -> int end module FunnyType_PROTO : sig type t val compare : t -> t -> int end val ge : OrderedType_PROTO.t -> OrderedType_PROTO.t -> bool val funny_ge : FunnyType_PROTO.t -> FunnyType_PROTO.t -> bool HTH, Julien.