From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 42D9C7EE33 for ; Mon, 13 Feb 2017 20:11:23 +0100 (CET) Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=sjs429@cornell.edu; spf=Pass smtp.mailfrom=sjs429@cornell.edu; spf=Pass smtp.helo=postmaster@limerock04.mail.cornell.edu Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of sjs429@cornell.edu) identity=pra; client-ip=128.84.13.244; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="sjs429@cornell.edu"; x-sender="sjs429@cornell.edu"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of sjs429@cornell.edu designates 128.84.13.244 as permitted sender) identity=mailfrom; client-ip=128.84.13.244; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="sjs429@cornell.edu"; x-sender="sjs429@cornell.edu"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of postmaster@limerock04.mail.cornell.edu designates 128.84.13.244 as permitted sender) identity=helo; client-ip=128.84.13.244; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="sjs429@cornell.edu"; x-sender="postmaster@limerock04.mail.cornell.edu"; x-conformance=sidf_compatible; x-record-type="v=spf1" IronPort-PHdr: =?us-ascii?q?9a23=3AhAEPRBdLl7xVuxCMt+B68+QRlGMj4u6mDksu8pMi?= =?us-ascii?q?zoh2WeGdxc67ZB7h7PlgxGXEQZ/co6odzbGH7+axAidZu87J8ChbNscTB1ld0Y?= =?us-ascii?q?RetjdjKfDGIHWzFOTtYS0+EZYKf35e1Fb/D3JoHt3jbUbZuHy44G1aMBz+MQ1o?= =?us-ascii?q?Ora9QdaK3Iyfntq/8JzLYghOmCH1IfYrdE33/k3tsZw3n4JkYok21hzXqXtJZ/?= =?us-ascii?q?8ekWJ2KnqSkhvxoMCq88gw3T5Xvqca68NOX6j8N589SrhbBXxyKGUy4M7inRLY?= =?us-ascii?q?CwCI/H0RVmFQnxZVVVuWpCrmV4v853Op/tF23zOXaIivFeg5?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0CpAAD0A6JYhvQNVIBeGwEBAQMBAQEJA?= =?us-ascii?q?QEBFQEBAQECAQEBAQgBAQEBhF0DMQeDUoE2iUSRGpU2gg2ICgdBFgEBAQEBAQE?= =?us-ascii?q?BAQEBEgEBAQoJCwodL4IzBAEWAQSCFgEBBAEjVgULAQoEBwMKKgICIhIBBQEcB?= =?us-ascii?q?g4FCIlaCAWiHD+MAoIlh30Hg08BAQEBIxKLKYdagl8BBJBBizGSFJEFkU4UHoE?= =?us-ascii?q?VJgNqRCAUCBcTPRcFhkVXiF+BTgEBAQ?= X-IPAS-Result: =?us-ascii?q?A0CpAAD0A6JYhvQNVIBeGwEBAQMBAQEJAQEBFQEBAQECAQE?= =?us-ascii?q?BAQgBAQEBhF0DMQeDUoE2iUSRGpU2gg2ICgdBFgEBAQEBAQEBAQEBEgEBAQoJC?= =?us-ascii?q?wodL4IzBAEWAQSCFgEBBAEjVgULAQoEBwMKKgICIhIBBQEcBg4FCIlaCAWiHD+?= =?us-ascii?q?MAoIlh30Hg08BAQEBIxKLKYdagl8BBJBBizGSFJEFkU4UHoEVJgNqRCAUCBcTP?= =?us-ascii?q?RcFhkVXiF+BTgEBAQ?= X-IronPort-AV: E=Sophos;i="5.35,156,1484002800"; d="scan'208,217";a="260147791" Received: from limerock04.mail.cornell.edu ([128.84.13.244]) by mail2-smtp-roc.national.inria.fr with ESMTP; 13 Feb 2017 20:11:22 +0100 X-CornellRouted: This message has been Routed already. Received: from exchange.cornell.edu (sf-e2013-07.exchange.cornell.edu [10.22.40.54]) by limerock04.mail.cornell.edu (8.14.4/8.14.4_cu) with ESMTP id v1DJBL9x028303 for ; Mon, 13 Feb 2017 14:11:21 -0500 Received: from sf-e2013-07.exchange.cornell.edu (10.22.40.54) by sf-e2013-07.exchange.cornell.edu (10.22.40.54) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Mon, 13 Feb 2017 14:11:08 -0500 Received: from mail-wr0-f198.google.com (209.85.128.198) by exchange.cornell.edu (10.22.40.54) with Microsoft SMTP Server (TLS) id 15.0.1210.3 via Frontend Transport; Mon, 13 Feb 2017 14:11:08 -0500 Received: by mail-wr0-f198.google.com with SMTP id 89so39708986wrr.1 for ; Mon, 13 Feb 2017 11:11:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=vzoaPpAtmXtiJUp+IwRdM9f+HU1DoB4QwocIoi3pKbA=; b=pu4AM1CLXenCjotrcsyRgu1ydveo2XWRUNI/VbMVy/Wh291XRMJIxtcf91ej7B54ST TXoIwmSAY6q31e55uyr61EA4J27NZrAIKovWyX2mw9MSmvDrO7NwESWMdplNKrXHLDxV WFfXUSvJp87OYKQWpQSdUGXSd9NBSR/wh2CWIaFQXh/xi0/lfXHGddHGIDCdEwBRtV5f k1o4SMiQN8B+wwAvpwsIzKEvFuM51ssaMj1nFFC5jWPR0+MAIMVOj++ehCjItDWMgpFz TUJG3wRd83LPO1GYvlwqfYPTIb88Et0BMmLvHLAoQeVHQ165SHjubHc2GdgPi4zpBv56 JJpw== X-Gm-Message-State: AMke39m00B9BG02GTAlZ/wc0SYqZLGmKZh58Zvru2T0eLp3Q4kNH9g93N5tjtwZOa8ag/oEkgMX+2acoE85iZy6MDSIJbHZOH1uaBtpZkwxQVCukw57hF41Tm16k7DW08DapsSh2cByNJVMwoeeP7/OKK292yW7cLA== X-Received: by 10.28.206.136 with SMTP id e130mr39272296wmg.121.1487013079661; Mon, 13 Feb 2017 11:11:19 -0800 (PST) X-Received: by 10.28.206.136 with SMTP id e130mr39272277wmg.121.1487013079376; Mon, 13 Feb 2017 11:11:19 -0800 (PST) MIME-Version: 1.0 Sender: Received: by 10.28.87.132 with HTTP; Mon, 13 Feb 2017 11:11:18 -0800 (PST) In-Reply-To: References: From: Steffen Smolka Date: Mon, 13 Feb 2017 14:11:18 -0500 X-Google-Sender-Auth: nPI5ZVQl0g_U7OvJ2dxMXJhKiP8 Message-ID: To: Ivan Gotovchits CC: Caml List Content-Type: multipart/alternative; boundary="94eb2c1941145f752d05486e36e8" X-ORG-HybridRouting: e8f1a94984010e02e8fd51a975043b2f X-ORG-RouteOnPrem: False X-ORG-MsgSource: cmail X-PMX-CORNELL-AUTH-RESULTS: dkim-out=none; Subject: Re: [Caml-list] private object constructor? --94eb2c1941145f752d05486e36e8 Content-Type: text/plain; charset="UTF-8" Thanks, this works :) -- Steffen On Mon, Feb 13, 2017 at 1:57 PM, Ivan Gotovchits wrote: > Hi Steffen, > > Your question contains the answer :) You can indeed expose an object type > and a class type without exposing the class. > > module Example : sig > class type t = object > method print : unit > end > end = struct > class t = object > method print = print_endline "yep" > end > end > > The class implementation will not be exposed, so `new Example.t` will say > `Unbound class Example.t`. But, the class type and object type will be > exposed, > e.g, you may say `type printable = Example.t` (yes, class type declaration > declares both the type and the class type). > > Regards, > Ivan > > > On Mon, Feb 13, 2017 at 1:23 PM, Steffen Smolka > wrote: > >> Hi, >> >> Is it possible to expose an object or class type in OCaml without >> exposing the constructor, i.e. the ability to construct objects of the >> type? OCaml supports private ADTs and type synonyms, but the private >> keyword doesn't seem to work with classes or objects. >> >> Thanks, >> -- Steffen >> > > --94eb2c1941145f752d05486e36e8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks, this works :)

-- Steffen
<= /div>

On Mon, Feb = 13, 2017 at 1:57 PM, Ivan Gotovchits <ivg@ieee.org> wrote:
Hi Steffen,

Your question contains the answer=C2=A0:) You can indeed expose an object = type and a class type without exposing the class.

=
module Example : sig=C2=A0
=C2=A0 class type t =3D object
=C2=A0 =C2=A0 =C2=A0 method print : unit
=C2=A0 =C2=A0 en= d=C2=A0
end =3D struct=C2=A0
=C2=A0 =C2=A0 class t =3D = object
=C2=A0 =C2=A0 =C2=A0 method print =3D print_endline "= yep"
=C2=A0 =C2=A0 end=C2=A0
=C2=A0 end

The class implementation will not be exposed, so `new = Example.t` will say `Unbound class Example.t`. But, the class type and obje= ct type will be exposed,
e.g, you may say `type printable =3D Example.t` (yes, class type declara= tion declares both the type and the class type).

Regards,
Iva= n


On Mon, Feb 13, 2017 at = 1:23 PM, Steffen Smolka <smolka@cs.cornell.edu> wrote:
Hi,

Is it po= ssible to expose an object or class type in OCaml without exposing the cons= tructor, i.e. the ability to construct objects of the type? OCaml supports = private ADTs and type synonyms, but the private keyword doesn't seem to= work with classes or objects.

Thanks,
=
-- Steffen


--94eb2c1941145f752d05486e36e8--